OpenMDAO: pyOptSparse building script

Question:

So I am opening this new thread about how to build pyOptSparse and use it within the OpenMDAO framework. The OpenMDAO team released a scrip which should build pyOptSparse by integrating IPOPT as well: https://github.com/OpenMDAO/build_pyoptsparse

I followed their instructions on a Ubuntu virtual machine. Unfortunately, when it comes to run the scrip, something goes wrong and prevent pyOptSparse to be installed.

I don’t know if I am forgetting something, but I am stuck. Does anyone know how to solve this problem ?

Many thanks in advance for your help. Here is the strange error message that I got this:

File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command ‘[‘./configure’, ‘–with-metis’, ‘–with-metis-lflags=-L/root/pyoptsparse/lib -lcoinmetis’, ‘–with-metis-cflags=-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis’, ‘–prefix=/root/pyoptsparse’, ‘CFLAGS=-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis’, ‘FCFLAGS=-fallow-argument-mismatch -w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis’]’ returned non-zero exit status 1.

enter image description here

EDIT: So I ran build_pyoptsparse -v twice: the first time I got an error message which were telling me that the package LAPCK was missing. Therefore, I did an apt-get install libblas-dev liblapack-dev to install it. Then I ran again the pyoptsparse command and I got this:

...
checking for LAPACK... yes: generic module (lapack.pc blas.pc)
checking for function dgemmt_ in -llapack -lblas  ... no
checking for function dgemmt in -llapack -lblas  ... no
checking for function DGEMMT_ in -llapack -lblas  ... no
checking for function DGEMMT in -llapack -lblas  ... no
checking for function dgemmt__ in -llapack -lblas  ... no
checking for function dgemmt_ in -llapack -lblas  ... no
checking for function DGEMMT__ in -llapack -lblas  ... no
checking for function DGEMMT_ in -llapack -lblas  ... no
checking for library containing cos... -lm
checking for library Metis with combined link and compile check... no (link with header)
configure: Compiler flags were "-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis". Use --with-metis-cflags to overwrite. Check config.log for details of failed compile attempt.
configure: Linker flags are "-L/root/pyoptsparse/lib -lcoinmetis". Use --with-metis-lflags to overwrite. Check config.log for details of failed link attempt.
configure: error: user-specified flags for Metis do not work.
Traceback (most recent call last):
File "/usr/local/bin/build_pyoptsparse", line 8, in <module>
sys.exit(perform_install())
File "/usr/local/lib/python3.9/site-packages/build_pyoptsparse.py", line 1118, in perform_install
install_with_mumps()
File "/usr/local/lib/python3.9/site-packages/build_pyoptsparse.py", line 642, in install_with_mumps
install_mumps_from_src()
File "/usr/local/lib/python3.9/site-packages/build_pyoptsparse.py", line 579, in install_mumps_from_src
run_cmd(cmd_list=cnf_cmd_list)
File "/usr/local/lib/python3.9/site-packages/build_pyoptsparse.py", line 335, in run_cmd
subprocess.run(cmd_list, check=do_check)
File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['./configure', '--with-metis', '--with-metis-lflags=-L/root/pyoptsparse/lib -lcoinmetis', '--with-metis-cflags=-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis', '--prefix=/root/pyoptsparse', 'CFLAGS=-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis', 'FCFLAGS=-fallow-argument-mismatch -w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis']' returned non-zero exit status 1.
Asked By: Quentin Tiefaine

||

Answers:

The build_pyoptsparse script was intended to be run as a normal user rather than root – it hasn’t been tested that way and may have unintended impacts on your system.

Ideally it should be run in a virtual Python environment, either with conda (Anaconda / miniconda / miniforge) or venv. In a conda environment, several of the packages can be installed from the repository rather than having to build them. If run outside of a virtual environment, it will install under your home directory. The exact path can be modified with -p.

Having said that, there’s not a lot of info in your screenshot except that an error occurred. If there’s a different version of METIS already installed on your system, that could be causing problems with the MUMPS configuration. Try removing the other version of METIS and building again. If you’re still getting an error, run build_pyoptsparse -v so that the complete error text is printed, and post it here.

Answered By: Tad Kollar

I ran into a similar issue when trying to install this package to use it with openmdao/dymos. I’m using Linux Mint with conda 22.9.0. These are the steps that I followed to fully set up my environment, answering yes to all prompts:

#Create and activate new environment with python 3.10 and pip
conda create -n py310
conda activate py310
conda install python=3.10
conda install pip

close your shell and reopen it

# install dymos
conda activate py310
git clone https://github.com/OpenMDAO/dymos.git ./dymos.git
python -m pip install -e dymos.git
# install build_pyoptsparse
git clone https://github.com/OpenMDAO/build_pyoptsparse.git
python -m pip install ./build_pyoptsparse
# install gfortran and swig as they will be required by build_pyoptsparse
conda install -c conda-forge gfortran
conda install -c anaconda swig
# install MUMPS, METIS, and IPOPT using the conda-forge channel
conda install -c conda-forge MUMPS
conda install -c conda-forge METIS
conda install -c conda-forge IPOPT
# run build_pyoptsparse
build_pyoptsparse -v
Answered By: Jorge Valderrama
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.