0

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.
1
  • Try running the script with the -v (aka --verbose) option to see what the error is... Commented Sep 28, 2022 at 13:02

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

0

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.

5 Comments

Thanks for your help. 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: configure: error: user-specified flags for Metis do not work.
I highly recommend taking the first two paragraphs in my answer seriously - don't run as root, and try installing with some form of conda instead of building it all from source. You can obtain Miniforge from here. I suggest using the Mambaforge version of the installer.
Thanks for your help Mr Kollar. For your root privileges concern, I should mention that I am using a docker container with an Ubuntu image, so I think there is nothing to be afraid of. Is it possible to use Mambaforge without using Conda ? Unfortuantely I am not allowed to use Conda since we have some licenses issues with it
The official Anaconda repository is only free for academic/hobbyist use, and in the past it was suggested they would close access to anyone abusing it. However, the conda-forge repo does not have that restriction. Mini-forge uses the conda-forge repo by default; mamba-forge is just mini-forge with mamba preinstalled. Mamba is an accelerated version of conda - instead of running conda install numpy you can run mamba install numpy and it will process dependencies faster. The build_pyoptsparse script uses mamba by default if it finds it.
Thank you very much for your answer Mr Kollar, I did not realize that you answer me. I have been able to solve my problem by replacing conda with mamba. Thanks again! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.