Code Monkey home page Code Monkey logo

Comments (11)

jfowkes avatar jfowkes commented on August 18, 2024

Hi, that's because for some reason Anaconda thinks it's okay to append .cpython-37m-x86_64-linux-gnu to the end of the compiled extension (regular python does not do this).

As a quick fix you can rename _pycutestitf.cpython-37m-x86_64-linux-gnu.so to _pycutestitf.so while we investigate the root cause of this and find a way to resolve the issue.

@lindonroberts: any thoughts on this?

from pycutest.

pjssilva avatar pjssilva commented on August 18, 2024

You mean doing something like

$PYCUTEST_CACHE/pycutest_cache_holder/HS110/_pycutestitf.cpython-37m-x86_64-linux-gnu.so $PYCUTEST_CACHE/pycutest_cache_holder/HS110/_pycutestitf.so

?

I tried this but it didn't work. Also, sometimes I get a segfault instead of the data file not found error.

from pycutest.

jfowkes avatar jfowkes commented on August 18, 2024

So that's what I meant, but that doesn't seem to be the issue after all. It turns out that I can run PyCUTEst fine on a fresh install of Anaconda (specifically using the latest Minconda installer):

Python 3.7.1 (default, Dec 14 2018, 19:28:38) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycutest
/home/fowkes/miniconda3/lib/python3.7/site-packages/pycutest/__init__.py:28: RuntimeWarning: the PYCUTEST_CACHE environment variable is not set; current folder will be used for caching.
  warnings.warn("the PYCUTEST_CACHE environment variable is not set; current folder will be used for caching.", RuntimeWarning)
>>> p = pycutest.import_problem('ROSENBR')
>>> p.x0
array([-1.2,  1. ])
>>>

and I also have the same as you in the ~/pycutest_cache_holder/ROSENBR directory:

AUTOMAT.d  build  cutestitf.c  ELFUN.f  ELFUN.o  EXTER.f  EXTER.o  GROUP.f  GROUP.o  __init__.py  OUTSDIF.d  __pycache__  PyCUTEst_automatic_test_function_interface_builder-1.0-py3.7.egg-info  _pycutestitf.cpython-37m-x86_64-linux-gnu.so  RANGE.f  RANGE.o  setup.py

Could you try running without setting PYCUTEST_CACHE in your .bashrc? I'm wondering if it's the cache folder handling that's causing the issue here.

from pycutest.

pjssilva avatar pjssilva commented on August 18, 2024

I tried, but no luck:

Python 3.7.1 (default, Dec 14 2018, 19:28:38) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pycutest                                                                                                                                                                                      
/opt/continuum/anaconda3/lib/python3.7/site-packages/pycutest/__init__.py:28: RuntimeWarning: the PYCUTEST_CACHE environment variable is not set; current folder will be used for caching.
  warnings.warn("the PYCUTEST_CACHE environment variable is not set; current folder will be used for caching.", RuntimeWarning)

In [2]: p = pycutest.import_problem("HS110")                                                                                                                                                                 
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-2-82d3da318ed4> in <module>
----> 1 p = pycutest.import_problem("HS110")

/opt/continuum/anaconda3/lib/python3.7/site-packages/pycutest/build_interface.py in import_problem(problemName, destination, sifParams, sifOptions, efirst, lfirst, nvfirst, quiet, drop_fixed_variables)
    334         problemDir = destination
    335     # Import the module CACHE_SUBFOLDER.problemDir, and return a wrapper
--> 336     return CUTEstProblem(__import__('%s.%s' % (CACHE_SUBFOLDER, problemDir), globals(), locals(), [str(problemDir)]),
    337                          drop_fixed_variables=drop_fixed_variables)
    338 

~/documentos/pesquisa/splitLP/pycutest_cache_holder/HS110/__init__.py in <module>
     61 
     62 # Get problem dimension
---> 63 (n, m)=_pycutestitf._dims()
     64 
     65 # Set up the problem and get basic information

Exception: Failed to open data file

In [3]: 

from pycutest.

jfowkes avatar jfowkes commented on August 18, 2024

Ok let's try debugging the exception: "Failed to open data file" means that OUTSDIF.d cannot be found or read, so the first thing to check is that __init.py__ is looking for it in the correct place. Could you edit HS110/__init.py__ after line 46 to print out _directory and _module?

You should get something like ~/pycutest_cache_holder/HS110 for _directory and _pycutestitf.cpython-37m-x86_64-linux-gnu.so for _module.

from pycutest.

lindonroberts avatar lindonroberts commented on August 18, 2024

Hi, just to confirm, have you confirmed the underlying CUTEst install is working correctly? You can test with (from https://github.com/ralna/CUTEst/blob/master/doc/README):

cd $SIFDECODE/src ; make -f $SIFDECODE/makefiles/$MYARCH test
cd $CUTEST/src ; make -f $CUTEST/makefiles/$MYARCH test

from pycutest.

pjssilva avatar pjssilva commented on August 18, 2024

Here goes the output with the prints. I have also tried to test CUTEst but it says that the test target is not in the Makefile. I even tried to recompile it. It works with the Algencan interface, so sifdecoder is working and the CUTEst library should also be working. The output of the _module and _directory look OK.

ython 3.7.1 (default, Dec 14 2018, 19:28:38) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pycutest                                                                                                                                                                                                                                                             
/opt/continuum/anaconda3/lib/python3.7/site-packages/pycutest/__init__.py:28: RuntimeWarning: the PYCUTEST_CACHE environment variable is not set; current folder will be used for caching.
  warnings.warn("the PYCUTEST_CACHE environment variable is not set; current folder will be used for caching.", RuntimeWarning)

In [2]: p = pycutest.import_problem("HS110")                                                                                                                                                                                                                                        
******************** /home/pjssilva/documentos/pesquisa/splitLP/pycutest_cache_holder/HS110
******************** _pycutestitf.cpython-37m-x86_64-linux-gnu.so
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-2-82d3da318ed4> in <module>
----> 1 p = pycutest.import_problem("HS110")

/opt/continuum/anaconda3/lib/python3.7/site-packages/pycutest/build_interface.py in import_problem(problemName, destination, sifParams, sifOptions, efirst, lfirst, nvfirst, quiet, drop_fixed_variables)
    334         problemDir = destination
    335     # Import the module CACHE_SUBFOLDER.problemDir, and return a wrapper
--> 336     return CUTEstProblem(__import__('%s.%s' % (CACHE_SUBFOLDER, problemDir), globals(), locals(), [str(problemDir)]),
    337                          drop_fixed_variables=drop_fixed_variables)
    338 

~/documentos/pesquisa/splitLP/pycutest_cache_holder/HS110/__init__.py in <module>
     63 
     64 # Get problem dimension
---> 65 (n, m)=_pycutestitf._dims()
     66 
     67 # Set up the problem and get basic information

Exception: Failed to open data file

In [3]:                                                                                                                                                                                                                                                                             
Do you really want to exit ([y]/n)? y
pjssilva@trinity:~/documentos/pesquisa/splitLP$ ls /home/pjssilva/documentos/pesquisa/splitLP/pycutest_cache_holder/HS110
AUTOMAT.d  build  cutestitf.c  ELFUN.f  ELFUN.o  EXTER.f  EXTER.o  GROUP.f  GROUP.o  __init__.py  OUTSDIF.d  __pycache__  PyCUTEst_automatic_test_function_interface_builder-1.0-py3.7.egg-info  _pycutestitf.cpython-37m-x86_64-linux-gnu.so  RANGE.f  RANGE.o  setup.py

from pycutest.

jfowkes avatar jfowkes commented on August 18, 2024

Looks like a Fortran issue to me then: the "Failed to open data file" exception is thrown on line 115 of c_interface.py and indicates that the FORTRAN_open call on line 113 is failing for some reason. This could be due to incompatible Fortran compilers being used for CUTEst and PyCUTEst. At the moment we only support gfortran for PyCUTEst, are you using a different Fortran compiler for CUTEst itself?

from pycutest.

pjssilva avatar pjssilva commented on August 18, 2024

I used gfortran 8.2 to compile CUTEst. Maybe some incompatibility between this gfortran version and the one Anaconda used? I will try today to install it using Ubuntu's Python and see how it goes.

from pycutest.

jfowkes avatar jfowkes commented on August 18, 2024

Yes I suspect that's the issue: Anaconda uses gfortran 7.3 (as you can see from the first line of your initial code listing).

from pycutest.

jfowkes avatar jfowkes commented on August 18, 2024

Did that fix your issue? I have updated the README with a note to ensure that PyCUTEst and CUTEst use the same version of gfortran.

from pycutest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.