CERN / TIGRE

TIGRE: Tomographic Iterative GPU-based Reconstruction Toolbox
BSD 3-Clause "New" or "Revised" License
550 stars 182 forks source link

unable to run tigre demos on windows 10 following windows installation documentation given in doc #349

Closed alpxpatx closed 2 years ago

alpxpatx commented 2 years ago

Code to reproduce the problem (If applicable) running following on windows 10 cmd line

C:\Users\Admin\TIGRE\Python\demos>python d01_CreateGeometry.py

output Traceback (most recent call last): File "d01_CreateGeometry.py", line 25, in import tigre File "C:\Users\Admin\AppData\Roaming\Python\Python38\site-packages\pytigre-2.1.0-py3.8-win-amd64.egg\tigre__init__.py", line 4, in from .utilities.Ax import Ax File "C:\Users\Admin\AppData\Roaming\Python\Python38\site-packages\pytigre-2.1.0-py3.8-win-amd64.egg\tigre\utilities\Ax.py", line 4, in from _Ax import _Ax_ext ImportError: DLL load failed while importing _Ax: The specified module could not be found.



## Specifications 
-------------------------------------------------------------------------------------------------------------------------------
C:\Users\Admin\TIGRE\Python\demos>path
PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.4.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Users\Admin\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\Admin\AppData\Local\Programs\Python\Python38\;C:\Users\Admin\AppData\Local\Microsoft\WindowsApps;
---------------------------------------------------------------------------------------------------------------------------------------
  C:\Users\Admin\TIGRE\Python\demos>python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z

--------------------------------------------------------------------------------------------
- OS: windows 10 pro
- --------------------------------------------------------------------
  - CUDA version: 10.1 update 2
  - -----------------------------------------------------------
Microsoft Visual Studio Community 2019
Version 16.11.7
-----------------------------------------------------
AnderBiguri commented 2 years ago

247

It seems that there is something for python 3.8 and 3.9 that makes it not work on Windows. I am sure there is something in the setup.py that can be changed to fix this, but I honestly don't know how to. My suggestions: install a python virtual environment for python 3.7 and get TIGRE there.

Or if you have any idea how to fix this, do let me know!

broooooot commented 2 years ago

Hi there,

are there any news on this topic? Unfortunately, I have the same problem. Tigre runs fine with Python 3.7, but using 3.8, 3.9 or 3.10 compiling works fine, but the import fails with the following message:

`Python 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:17:03) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import tigre Traceback (most recent call last): File "", line 1, in File "C:\Users*\Documents\xray_simulation\TIGRE\Python\tigre__init__.py", line 4, in from .utilities.Ax import Ax File "C:\Users*\Documents\xray_simulation\TIGRE\Python\tigre\utilities\Ax.py", line 4, in from _Ax import _Ax_ext ImportError: DLL load failed while importing _Ax: Das angegebene Modul wurde nicht gefunden.`

The last sentence means basically module not found. A workaround would be highly appreciated since another package I'm using doesn't support 3.7 anymore.

Thanks a lot and cheers!

AnderBiguri commented 2 years ago

Hi @broooooot ,

Unfortunately my python is not good enough to know why this is happening. It seems like when compiled with python 3.8 or higher, the compiled object (DLL) is not found anymore when trying to run the code. This means that something in Setup.py doesn't really work well, but I have no idea what. Let me dig a bit to see if I can fix that....

AnderBiguri commented 2 years ago

@broooooot try pip install .

Alternatively, I think it works well in a conda enviroment, but I have not tried it myself.

AnderBiguri commented 2 years ago

Hint to fix:

https://docs.python.org/3.8/library/os.html#os.add_dll_directory

New in version 3.8: Previous versions of CPython would resolve DLLs using the default behavior for the current process. This led to inconsistencies, such as only sometimes searching PATH or the current working directory, and OS functions such as AddDllDirectory having no effect.

https://docs.python.org/3.8/whatsnew/3.8.html#bpo-36085-whatsnew

Can't try now, but it seems that we may need to explicitly load the dlls somewhere in the __init__

broooooot commented 2 years ago

Hi @AnderBiguri and thank you for your response,

I will have a look into that matter and try to figure something out. Actually, I am using a conda environment but for some reason I am not able to use pip install . because then the installer can't find Cython, though of course it is installed in the environment. Instead, I'm installing TIGRE via python setup.py install which works. Maybe that might even be the cause of the problem. Thanks again, hopefully you'll find something. In the meantime I'm trying to make everything work using wsl and ubuntu ..

Cheers!

AnderBiguri commented 2 years ago

Closing this from lack of response, but feel free to reopen it if you still have this issues.