Danielaleite / Nextrout

MIT License
6 stars 1 forks source link

Issues when compiling #5

Open thisisas opened 2 weeks ago

thisisas commented 2 weeks ago

Hello, The f2py_interface_dmk is missing when compiling. The following appears when running python setup.py:

No rule to make target 'f2py_interface_dmk'.

I have tried troubleshooting with the instructions at gitlab.com/enrico_facca/dmk_solver but get the same error. Would appreciate any suggestions to help resolve this issue!

diegoabt commented 2 weeks ago

Hi @thisisas,

thank you for reporting the issue! I would be very happy to assist you with the installation. For that, could you please send me the logs you see when you run the setup.py?

Thank you!

thisisas commented 2 weeks ago

Hi @diegoabt , Here is the log from running setup.py:

make[3]:***[python/fortran_python_interface/CMakeFiles/f2py_interface_dmk.dir/build.make:88:python/fortran_python_interface/_dmk.so] Error 1

make[2]: *** [CMakeFiles/Makefile2:2524:python/fortran_python_interface/CMakeFiles/f2py_interface_dmk.dir/all] Error 2

make[1]: *** [CMakeFiles/Makefile2:2531:python/fortran_python_interface/CMakeFiles/f2py_interface_dmk.dir/rule] Error 2 make: *** [Makefile:982: f2py_interface_dmk] Error 2

Installation finished! In case of errors, please check the Troubleshooting section at https://gitlab.com/enrico_facca/dmk_solver

Thank you!

diegoabt commented 2 weeks ago

Hi @thisisas , thank you for the logs. I think I'll need some more info to understand/reproduce the error. Did you manage to install all the dependencies without problem? Which OS are you using? Which version of gfortran do you have?

thisisas commented 2 weeks ago

Hi @diegoabt , Yes I was able to install all the dependencies without any issues. I am using Ubuntu 22.04.5 and the gfortran version is 11.4.0.

diegoabt commented 1 week ago

Hi @thisisas,

I'm trying to replicate the error you are finding. Could you please tell me which python version you are currently using?

thisisas commented 1 week ago

Hi @diegoabt , I am using Python 3.9.0

diegoabt commented 1 week ago

Hi @thisisas ,

Thank you for your patience. I'm back with a few ideas/suggestions:

  1. I'm not sure if it is gonna work with py3.9. I would be happy to make it work for that and newer versions but that's gonna take a bit longer. At the moment, it probably works with py3.6 or py3.7 (and maybe py3.8).
  2. Regardless of that, the errors seem to be related to the installation of the python interface. To solve this, you could do the following:
    • Run setup.py
    • If it breaks again when running f2py_interface_dmk, go to the build dir inside dmk_solver, and run cmake again, but this time pass the absolute paths to blas and lapack:
      cmake -DBLAS_DIR=/usr/lib/x86_64-linux-gnu/blas -DLAPACK_DIR=/usr/lib/x86_64-linux-gnu/lapack ../
      make

      If it all works out, you should see something like this when it finishes running:

      [100%] Linking Fortran executable dmk_graph_from_file.out

      If that all works out, you can go to the nextrout-core and run the test.py. Please let me know if it works.

thisisas commented 1 week ago

Hi @diegoabt , I installed Python3.6 and tried running the code with that. I also ran the cmake in the build directory in dmk_solver as you suggested. I did see [100%] Linking Fortran executable dmk_graph_from_file.out but still got the same make errors as earlier. I tried running test.py and I got this error, which seems to be an issue with the fortran_python_interface again:

/dmk_utilities/dmk_solver/build/python/fortran_python_interface/dmk.py", line 2, in <module> import _dmk ModuleNotFoundError: No module named '_dmk'

diegoabt commented 1 week ago

Hi @thisisas ,

I see! I think that happens when the interface is not properly compiled. Could you please go to the dmk_solver/build, and run cmake with the paths to blas and lapack again, and then send me the logs? Maybe there's a problem with the paths that point to them (I just noticed that I sent you the paths to my installations :sweat_smile: , I should have told you to find which these paths were in your machine).

Could you also send me the what you get when you run the following commands?

whereis lapack
whereis blas

Thank you.

thisisas commented 1 week ago

Hi @diegoabt , I ran cmake with the path to my installations of blas and lapack:

** WRAPPERS FOR PYTHON-FORTRAN INTERFACE FOUND
-- F2py interface
CMAKE_Fortran_COMPILER /usr/bin/gfortran
BLAS   LIBS  DIR /usr/lib/x86_64-linux-gnu/blas
LAPACK LIBS  DIR /usr/lib/x86_64-linux-gnu/lapack
Doxygen build started
**
-- Configuring done
-- Generating done
-- Build files have been written to: ~/Desktop/dmk/dmk_solver/build

These are the outputs for the whereis commands:

whereis lapack
lapack: /usr/lib/x86_64-linux-gnu/lapack
whereis blas
blas: /usr/lib/x86_64-linux-gnu/blas
diegoabt commented 1 week ago

Hi @thisisas ,

Thank you for providing the information. The paths of your lapack and blas seem to be the same I have. Another thing that could help is to use the absolute path to cmake as explained by Enrico. For that you need to run the next line but using the path to your gfortran instead of what shown there:

cmake -DMy_Fortran_Compiler="absolute complier path" ..

Given that we have tried many things, it might make sense to remove the build dir inside dmk_solver and have a fresh start. As said, I think you problem is related to the installation of the python interface, which is the last step to make it work. We should be almost there.

thisisas commented 1 week ago

Hi @diegoabt , I think that worked, I am no longer getting the module not found error for _dmk. However, I am still getting an error related to dmk. Here is the log from running test.py:

Compile with:
mkdir build; cd build; cmake f2py_interface_dmk../; make 
Traceback (most recent call last):
  File "~/Desktop/next/Nextrout/nextrout_core/test.py", line 3, in <module>
    from main import nextrout
  File "~/Desktop/next/Nextrout/nextrout_core/main.py", line 2, in <module>
    import dmk_cont
  File "~/Desktop/next/Nextrout/nextrout_core/dmk_cont.py", line 35, in <module>
    from dmk import (Dmkcontrols,    # controls for dmk simulations)
  File "~/.local/lib/python3.10/site-packages/dmk/__init__.py", line 3, in <module>
    from .dmk import SpaceDiscretization
  File "~/.local/lib/python3.10/site-packages/dmk/dmk.py", line 47, in <module>
    from linear_algebra import transpose
ModuleNotFoundError: No module named 'linear_algebra'

Thank you again for helping!

diegoabt commented 1 week ago

Hi @thisisas ,

Happy to hear that's solved!

I am not sure if this is the cause but it seems you are using py3.10 to run it. If changing back to py3.6 does not solve the issue, you might want to go to the linear_algebra dir and delete the build dir, and repeats the usual steps cmake (with the path option on) and make.

No worries!

thisisas commented 1 week ago

Hi @diegoabt, I was able to solve that error with a clean build, thank you for helping with it. Currently, I am getting an error related to the main.py file (when running test.py with Python 3.6):

~/Desktop/next/dmk_utilities/dmk_solver/build/python/fortran_python_interface
mkdir: cannot create directory ‘outputs/dirac’: File exists
len_attributes 1259
1259 665 3
 grid from data
 grid sizecell
 grid done
 subgrid refined
 subgrid nodenode
 subgrid genrcm
 subgrid renumber
Traceback (most recent call last):
  File "test.py", line 207, in <module>
    storing = storing)
  File "~/Desktop/next/Nextrout/nextrout_core/main.py", line 42, in nextrout
    tdpot, timefun = dmk_cont.dmk_cont(forcing,beta_c, ndiv, storing = storing)
TypeError: dmk_cont() missing 1 required positional argument: 'extra_info'
diegoabt commented 4 days ago

Hi @thisisas , Sorry for the late answer. I'm myself having some issues with the installation :sweat_smile: .

Could you please send me the output of pip list? I would like to see if the versions you got in your virtual env.

Thank you.

thisisas commented 4 days ago

Hi @diegoabt , Here are the packages and their versions in my virtual env:

Package            Version
------------------ -------------------
appdirs            1.4.4
attrs              22.2.0
certifi            2021.5.30
click              7.1.2
cycler             0.11.0
dataclasses        0.8
decorator          4.4.2
f90wrap            0.2.7
gmsh-interop       2021.1.1
importlib-metadata 4.8.3
iniconfig          1.1.1
kiwisolver         1.3.1
matplotlib         3.2.2
MeshPy             2020.1
networkx           2.5.1
numpy              1.19.5
packaging          21.3
pandas             1.1.5
pip                21.3.1
platformdirs       2.4.0
pluggy             1.0.0
py                 1.11.0
pyparsing          3.1.4
pytest             7.0.1
python-dateutil    2.8.2
pytools            2022.1.2
pytz               2024.2
scipy              1.5.3
setuptools         49.6.0.post20210108
six                1.16.0
tomli              1.2.3
tornado            6.1
typing_extensions  4.1.1
wheel              0.34.2
zipp               3.6.0
diegoabt commented 4 days ago

Hi @thisisas ,

Thank you so much. I solved my issue with the installation and updated the setup.py (and I merged it into main too).

Regarding the error during the test: I've also seen that it is not working. I'm currently fixing it. I will let you know later once it is finished.

Thank you for the help!

diegoabt commented 3 days ago

Hi @thisisas ,

I've just fixed the problems with the test. It should be working now. You can pull from master.

Let me know how it goes.

thisisas commented 1 day ago

Hi @diegoabt, Yes it is working now, thanks a lot! Also, I had a question. I am trying to use my data to run the tests. Do you think that is possible with the code provided? Thank you again for all the help!