OpenMDAO / build_pyoptsparse

python script to build/install pyoptsparse with IPOPT (and optionally SNOPT)
Apache License 2.0
9 stars 15 forks source link

Fatal Error after attempting to compile HSL linear solvers. #14

Closed ghost closed 3 years ago

ghost commented 3 years ago

I'm trying to run the script with no flags to get IPOPT with Mumps. However, when it attempts to compile the linear solver many error messages pop up such as these:

IpMa57TSolverInterface.cpp:784:4: error: ‘HSL_FUNC’ was not declared in this scope HSL_FUNC (ma57cd, MA57CD)(&job, &n, wd_fact_, &wd_lfact_, wd_ifact_, &wd_lifact_, &nrhs_X, rhs_vals, &lrhs, work, An after that these messages come up:

Makefile:571: recipe for target 'IpMa57TSolverInterface.lo' failed make[2]: *** [IpMa57TSolverInterface.lo] Error 1 make[2]: Leaving directory '/home/rory/Documents/build_pyoptsparse-master/build_pyoptsparse.6019ef86/Ipopt/src/Algorithm/LinearSolvers' Makefile:696: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/rory/Documents/build_pyoptsparse-master/build_pyoptsparse.6019ef86/Ipopt/src/Algorithm' Makefile:647: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1 FATAL ERROR: The command failed with error 2 at line 1. The command I'm running is

sudo ./build_pyoptsparse.sh

I'm using sudo because earlier it was failing due to a lack of permissions to remove a folder. Specifically $build_dir/ipopt/lib/libcoinmetis.so.0.0.0'.

I'm new to Linux so I don't know what information I need to provide. I am not trying to install HSL linear solvers though, and I didn't include any flags.

tadkollar commented 3 years ago

Although updates to the dependencies occasionally break the script, everything appears to be building normally right now. You shouldn't need to install with sudo unless you intend to make it available system-wide with the -p switch. Running sudo will also replace much of the environment that you may have configured, so the script could have trouble finding certain packages. For instance, if you're using Anaconda, that env wouldn't be carried over with sudo, and the installation would attempt to build with system utilities.

My suggestion would be to use sudo to rename the $build_dir/ipopt folder, then, with your regular user account, create a new empty folder and put a fresh, unmodified copy of build_pyoptsparse.sh in it. Set up your Python environment if necessary, cd to the empty folder, and run ./build_pyoptsparse.sh (again, without sudo).

ghost commented 3 years ago

@tadkollar Thanks, there have been a bunch of issues that came up due to me trying to fix the problems in a number of ways. I think using sudo was the issue here, it seems to have executed properly.

I'm not sure i this needs a new thread but one issue that I'm unsure about is that I've edited all the 'python -m pip install' lines to 'python3', because on my computer python leads to version 2.7. Is this something I'm supposed to do, or will this cause issues?

I'm using an example to verify if IPOPT is installed properly (here, run problemSolver.py) and it doesn't seem to work with this example. The error I get is:

+------------------------------------------------------------------------------+
| pyOptSparse Error: There was an error importing the compiled IPOPT module    |
+------------------------------------------------------------------------------+

Traceback (most recent call last):
  File "/home/rory/.local/lib/python3.6/site-packages/openmdao/drivers/pyoptsparse_driver.py", line 406, in run
    opt = getattr(_tmp, optimizer)()
  File "/home/rory/.local/lib/python3.6/site-packages/pyoptsparse/pyIPOPT/pyIPOPT.py", line 80, in __init__
    raise Error("There was an error importing the compiled IPOPT module")
pyoptsparse.pyOpt_error.Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "problemSolver.py", line 138, in <module>
    p.run_driver()
  File "/home/rory/.local/lib/python3.6/site-packages/openmdao/core/problem.py", line 663, in run_driver
    return self.driver.run()
  File "/home/rory/.local/lib/python3.6/site-packages/openmdao/drivers/pyoptsparse_driver.py", line 412, in run
    raise ImportError(msg)
ImportError: Optimizer IPOPT is not available in this installation.
tadkollar commented 3 years ago

Changing python to python3 in the script is fine - users frequently install their own version of Python (e.g. via Anaconda) so they don't need to rely on the system version, but maybe that's a change we should make to the script.

Try doing this first before running the example: export LD_LIBRARY_PATH=$HOME/ipopt/lib (assuming that's where your ipopt directory is)

ghost commented 3 years ago

@tadkollar Hey thanks I decided the issue was with the script so I brought it up in the pyoptshare repository. It got solved here: https://github.com/mdolab/pyoptsparse/issues/199

Part of the issue was what you said, I needed to have my env set up correctly for the shell that was running my script. Also my python was importing pyoptsparse from a place that wasn't receiving IPOPT files when I attempted to reinstall pyoptsparse. I deleted the folder that python was importing from then reinstalled, and set my environment correctly. Works now. Thanks for the help.