Menu

Using PyDSTool at Sage Math Cloud

Help
2015-07-02
2015-07-06
  • Evgenij Gr.

    Evgenij Gr. - 2015-07-02

    Hello!

    Recently PyDSTool has been added as one of system-wide packages for Sage Math Cloud, so I've decided to try it. However, I've got a problem using integrators other than VODE. For example, if I take PyCont_SaddleNode.py, copy & paste its content into IPython notebook and run it, I get following message:

    ---------------------------------------------------------------------------
    UnsupportedOperation                      Traceback (most recent call last)
    <ipython-input-1-a066e7c23ce4> in <module>()
         19 DSargs.ics = icdict
         20 
    ---> 21 testDS = Generator.Radau_ODEsystem(DSargs)
         22 # testDS = Generator.Vode_ODEsystem(DSargs)
         23
    
    /projects/5f8ce768-886a-49f8-b780-9882671103e9/.local/lib/python2.7/site-packages/PyDSTool/Generator/Radau_ODEsystem.pyc in __init__(self, kw)
        487             print("stages using the makeLibSource and compileLib methods.")
        488         else:
    --> 489             self.makeLib()
        490 
        491     @property
    
    /projects/5f8ce768-886a-49f8-b780-9882671103e9/.local/lib/python2.7/site-packages/PyDSTool/Generator/mixins.pyc in makeLib(self, libsources, libdirs, include)
        100             self.forceLibRefresh()
        101         self.makeLibSource(include)
    --> 102         self.compileLib(libsources, libdirs)
        103 
        104     @property
    
    /projects/5f8ce768-886a-49f8-b780-9882671103e9/.local/lib/python2.7/site-packages/PyDSTool/Generator/mixins.pyc in compileLib(self, libsources, libdirs)
         80           precompiled libraries."""
         81 
    ---> 82         self._builder.build(libsources, libdirs, self._compiler)
         83 
         84     def forceLibRefresh(self):
    
    /projects/5f8ce768-886a-49f8-b780-9882671103e9/.local/lib/python2.7/site-packages/PyDSTool/Generator/mixins.pyc in build(self, libsources, libdirs, compiler)
        184             libraries=self.libs
        185         )
    --> 186         with RedirectStdout(os.path.join(self.tempdir, 'build.log')):
        187             setup(name=self.description,
        188                 author="PyDSTool (automatically generated)",
    
    /projects/sage/sage-6.7/local/lib/python/contextlib.pyc in __enter__(self)
         15     def __enter__(self):
         16         try:
    ---> 17             return self.gen.next()
         18         except StopIteration:
         19             raise RuntimeError("generator didn't yield")
    
    /projects/5f8ce768-886a-49f8-b780-9882671103e9/.local/lib/python2.7/site-packages/PyDSTool/core/context_managers.pyc in _stdchannel_redirected(stdchannel, dest_filename, mode)
         27             yield iter([None])
         28         else:
    ---> 29             oldstdchannel = os.dup(stdchannel.fileno())
         30             dest_file = open(dest_filename, mode)
         31             os.dup2(dest_file.fileno(), stdchannel.fileno())
    
    /projects/sage/sage-6.7/local/lib/python2.7/site-packages/IPython/kernel/zmq/iostream.py in fileno(self)
        203 
        204     def fileno(self):
    --> 205         raise UnsupportedOperation("IOStream has no fileno.")
        206 
        207     def write(self, string):
    
    UnsupportedOperation: IOStream has no fileno.
    

    As far as I see, the radau5_temp directory has been created, radau5_SaddleNode_vf.i and SaddleNode_vf.c have been generated, but no compiled code has been generated.

    So, could you help me to figure out what went wrong and what should be done in order to fix it? Thanks in advance!

     
    • Vladimir Zakharov

      On Thu, Jul 02, 2015, Evgenij Gr. wrote:

      So, could you help me to figure out what went wrong and what should be
      done in order to fix it? Thanks in advance!

      If possible try to switch to version from github repository. This has
      been fixed there, but the fix is not released yet.

      --
      Regards,
      Vladimir Zakharov

       
      • Evgenij Gr.

        Evgenij Gr. - 2015-07-03

        Hm, it seems that I've managed to use the latest version of PyDSTool from GitHub (I see this because of the path from which package is loaded; pyDSTool.version shows something that looks like NumPy version) and now I don't have the error that I've described earlier, but there's a new one:

        /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o: In function `_start':
        /build/buildd/glibc-2.21/csu/../sysdeps/x86_64/start.S:114: undefined reference to `main'
        collect2: error: ld returned 1 exit status
        

        This error prevents further execution of IPython notebook. I've attached the full log to the post.

         
        • Vladimir Zakharov

          Same problem like in this issue on Github: gfortran call doesn't have "-shared" option and tries to build executable instead of shared lib. I still can't reproduce this bug in my environments.

           
          • Evgenij Gr.

            Evgenij Gr. - 2015-07-03

            So, finding compiler options environment variable and changing it might fix this issue? Or is it deeper?
            If you have an account and want to take a look, I can share you my project at Sage Math Cloud.

             
            • Vladimir Zakharov

              Unfortunately, I don't have any ideas. Possibly CFLAGS and/or FFLAGS are polluted in your environment. Maybe not..

              This is broken gfortran call from your log:

              /usr/bin/gfortran -Wall <files> -L<paths> -l<libs> <libname>.so -w
              

              And this is from mine:

              /usr/bin/gfortran -Wall -g -Wall -g -shared <files> -L<paths> -l<libs> <libname>.so -w -m32
              

              Ending flags ("-w" in your case and "-w -m32" in mine) are added by PyDSTool. All others come from environment (setuptools?).

              I don't have account at Sage Math Cloud.

               
              • Evgenij Gr.

                Evgenij Gr. - 2015-07-04

                As far as I see, executing "echo $CFLAGS" and "echo $FFLAGS" in SMC terminal shows empty string in both cases. However, looking at "gcc -v" I see that option --enable-shared is checked (though I was told by someone that this means nothing and it won't automatically tell compiler to make a shared library). I also have no idea why it works this way. Anyway, thank you for your help and for your time!

                Also, does compiling external integrator always create such long paths inside build directory? I mean, that part of log

                creating build
                creating build/temp.linux-x86_64-2.7
                creating build/temp.linux-x86_64-2.7/projects
                creating build/temp.linux-x86_64-2.7/projects/53906413-8c66-4349-9620-7b6f9f11396f
                creating build/temp.linux-x86_64-2.7/projects/53906413-8c66-4349-9620-7b6f9f11396f/.local
                creating build/temp.linux-x86_64-2.7/projects/53906413-8c66-4349-9620-7b6f9f11396f/.local/lib
                creating build/temp.linux-x86_64-2.7/projects/53906413-8c66-4349-9620-7b6f9f11396f/.local/lib/python2.7
                creating build/temp.linux-x86_64-2.7/projects/53906413-8c66-4349-9620-7b6f9f11396f/.local/lib/python2.7/site-packages
                creating build/temp.linux-x86_64-2.7/projects/53906413-8c66-4349-9620-7b6f9f11396f/.local/lib/python2.7/site-packages/PyDSTool-0.90.0-py2.7.egg
                creating build/temp.linux-x86_64-2.7/projects/53906413-8c66-4349-9620-7b6f9f11396f/.local/lib/python2.7/site-packages/PyDSTool-0.90.0-py2.7.egg/PyDSTool
                creating build/temp.linux-x86_64-2.7/projects/53906413-8c66-4349-9620-7b6f9f11396f/.local/lib/python2.7/site-packages/PyDSTool-0.90.0-py2.7.egg/PyDSTool/integrator
                

                looks strange for me (but maybe that's because I rarely use gcc and I'm newcomer to PyDSTool and have no experience to compare with).

                 
                • Rob Clewley

                  Rob Clewley - 2015-07-05

                  Hi Evgenij, if you have access to the source or know the folk that do, maybe you could try editing utils.py in the main PyDSTool directory in the function extra_arch_arg and, in the same way that '-m32' is added, add '-shared' to both possible returns. We could theoretically add it to the repo ourselves, since I don't think it could do any harm.

                   
                  • Evgenij Gr.

                    Evgenij Gr. - 2015-07-06

                    Hello Rob, thanks for suggestion! I've made changes locally, installed PyDSTool and after that using Radau integrator finally worked. I can make it as a pull request at GitHub, should I? (However, I think that changes won't be applied system-wide at SMC until update of package at PyPI)

                     
                • Vladimir Zakharov

                  Ok, I've managed to reproduce bug locally (inside "sage -sh"). Sage sets LDFLAGS environment variable to empty string. Python distutils uses it to tune linker command.

                  (sage-sh) $ env | grep LDF
                  LDFLAGS=
                  (sage-sh) $ python examples/PyCont_SaddleNode.py
                  /usr/lib/i386-linux-gnu/crt1.o: In function `_start':
                  /build/buildd/glibc-2.21/csu/../sysdeps/i386/start.S:111: undefined   reference to `main'
                  collect2: error: ld returned 1 exit status
                  error: <...> failed with exit status 1
                  

                  Unsetting "LDFLAGS" fixed problem for me.

                  (sage-sh) $ unset LDFLAGS
                  (sage-sh) $ python examples/PyCont_SaddleNode.py
                  Computing equilibrium curve...
                  done in 0.270 seconds!
                  (sage-sh) $
                  
                   
                  • Evgenij Gr.

                    Evgenij Gr. - 2015-07-06

                    Thank you Vladimir! I've tried your suggestion (with one modification only - after unsetting LDFLAGS I'm running the PyCont_SaddleNode.py straight from command line without creating new Sage process) and it worked too. Jupyter notebooks, however, still have the same problem, but I think I'll ask SMC support about this.

                     

Log in to post a comment.