modelon-community / Assimulo

Assimulo is a simulation package for solving ordinary differential equations.
https://jmodelica.org/assimulo/index.html
GNU Lesser General Public License v3.0
66 stars 16 forks source link

Installation issues #95

Closed isaacbasil closed 1 month ago

isaacbasil commented 1 month ago

Hello,

I am trying to get an Assimulo installation set up, with no success. Any advice would be appreciated. Please let me know if there's a more appropriate place that I should put this. I have tried both using pip, and also installing the latest version (3.5.0) using setup.py with the path to my sundials library provided. My setup details and the error that I get are below:

Ubuntu 22.04 running on WSL python 3.10 numpy 1.26.4 scipy 1.13.0 cython 3.0.10 matplotlib 3.9.0 sundials7.0.0, installed with LAPACK and CFLAGS=”-fPIC” CMake 3.29 make 4.3 gfortran 11.4.0 libopenblas-dev 0.3.20 liblapack-dev 3.10.0

The final error message is: Error: Rank mismatch in argument ‘cont’ at (1) (scalar and rank-1) error: Command "/usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops -I/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/assimulo/thirdparty/hairer -I/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.10/numpy/distutils/include -I/home/isaac_basil/Documents/python_projects/test_assimulo/venv/include -I/usr/include/python3.10 -c -c assimulo/thirdparty/hairer/radau_decsol.f -o build/temp.linux-x86_64-cpython-310/assimulo/thirdparty/hairer/radau_decsol.o" failed with exit status 1

Before that, there are also other warnings:

WARN: CCompilerOpt.dist_test[637] : CCompilerOpt._dist_test_spawn[771] : Command (x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/isaac_basil/Documents/python_projects/test_assimulo/venv/include -I/usr/include/python3.10 -c /home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c -o /tmp/tmp8m9dxqha/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.o -MMD -MF /tmp/tmp8m9dxqha/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.o.d -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -mavx512f -mno-mmx -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512vnni -mavx512ifma -mavx512vbmi -mavx512vbmi2 -mavx512bitalg -mavx512vpopcntdq -Werror) failed with exit status 1 output -> /home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c: In function ‘main’: /home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:22:5: error: unknown type name ‘m512h’; did you mean ‘m512bh’? 22 | m512h a = _mm512_loadu_ph((void*)argv[argc-1]); | ^~~ | __m512bh /home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:22:17: error: implicit declaration of function ‘_mm512_loadu_ph’; did you mean ‘_mm512_loadu_ps’? [-Werror=implicit-function-declaration] 22 | m512h a = _mm512_loadu_ph((void)argv[argc-1]); | ^~~~~~~ | _mm512_loadu_ps /home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:23:5: error: unknown type name ‘m512h’; did you mean ‘m512bh’? 23 | m512h temp = _mm512_fmadd_ph(a, a, a); | ^~~ | __m512bh /home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:23:20: error: implicit declaration of function ‘_mm512_fmadd_ph’; did you mean ‘_mm512_fmadd_ps’? [-Werror=implicit-function-declaration] 23 | m512h temp = _mm512_fmadd_ph(a, a, a); | ^~~~~~~ | _mm512_fmadd_ps /home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:24:5: error: implicit declaration of function ‘_mm512_storeu_ph’; did you mean ‘_mm512_storeu_ps’? [-Werror=implicit-function-declaration] 24 | _mm512_storeu_ph((void)(argv[argc-1]), temp); | ^~~~ | _mm512_storeu_ps cc1: all warnings being treated as errors

WARN: CCompilerOpt.feature_test[1576] : testing failed

PeterMeisrimelModelon commented 1 month ago

Hi isaacbasil,

sounds like it the issue reported in https://github.com/modelon-community/Assimulo/issues/88, can you try with invoking setup.py with an additional --extra-fortran-compile-flags=-std=legacy?

/Peter

isaacbasil commented 1 month ago

Thanks so much! That worked and I now have Assimulo installed in my venv. So I'm one step closer. But I just tried running one of the IDA examples and I still have some problems. Would you prefer I make a new issue? For some reason it cannot find some things in my sundials library, which is strange because I'm pretty sure they're there (see screenshot). The error when I run this example is:

Could not find libsundials_cvodes.so.7: cannot open shared object file: No such file or directory Could not find libsundials_kinsol.so.7: cannot open shared object file: No such file or directory Could not find GLIMDA. Traceback (most recent call last): File "/home/isaac_basil/Documents/python_projects/test_assimulo/main.py", line 2, in from assimulo.solvers import IDA ImportError: cannot import name 'IDA' from 'assimulo.solvers' (/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/assimulo/solvers/init.py)

sundials_lib

PeterMeisrimelModelon commented 1 month ago

This should be fixed by https://github.com/modelon-community/Assimulo/pull/94 with the upcoming Assimulo 3.5.1 release.

Could you try with the current master version?

/Peter

isaacbasil commented 1 month ago

I just tried reinstalling with the latest master version. Unfortunately, I still get an error, not quite the same this time though.

Could not find No module named 'assimulo.solvers.sundials' Could not find No module named 'assimulo.solvers.kinsol' Could not find GLIMDA. Traceback (most recent call last): File "/home/isaac_basil/Documents/python_projects/test_assimulo/main.py", line 2, in from assimulo.solvers import IDA ImportError: cannot import name 'IDA' from 'assimulo.solvers' (/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/assimulo/solvers/init.py)

PeterMeisrimelModelon commented 1 month ago

@jschueller Do you have time to look at this? Sounds like there might be some more build issues with Sundials 7.

jschueller commented 1 month ago

the sundials libs must be in a default location or reachable via LD_LIBRARY_PATH else you can just use libsundials-dev from the ubuntu archive

isaacbasil commented 1 month ago

I just tried uninstalling Assimulo from my venv, and then reinstalling after I had run: export LD_LIBRARY_PATH=~/sundials/sundials-7.0.0-install/lib:$LD_LIBRARY_PATH

I then tried uninstalling again, and doing: sudo apt update sudo apt install libsundials-dev python3 setup.py install --extra-fortran-compile-flags=-std=legacy

However with both attempts, when I try to run the example script that I mentioned above I get the same error as before (in my previous comment)

isaacbasil commented 1 month ago

Got it working now :) I think it was a problem with my blas and lapack libraries not being in the right location, as they weren't being found when I was installing Assimulo. Using --blas-home and --lapack-home worked for me.

Thanks so much for your help, I really appreciated the quick responses!

PeterMeisrimelModelon commented 1 month ago

Happy you could resolve it!

Thanks @jschueller for looking into it!