InsightSoftwareConsortium / InsightSoftwareConsortium/ITK
ITK Python `ImportError` with `ITK_USE_CUFFTW=ON`
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 748
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 64
Description
### Description
`ITKFFT` fails to lazily import in ITK Python if built with `ITK_USE_CUFFTW`.
### Steps to Reproduce
1. Build ITK with `ITK_USE_CUFFTW=ON` and `ITK_WRAP_PYTHON=ON`
2. Create a new Python virtual environment and add `WrapITK.pth` to `site-packages`
3. Run the Python console and force ITKFFT to import by calling an FFT filter
### Expected behavior
ITKFFT imports successfully.
### Actual behavior
```python
Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import itk
>>> itk.auto_progress(2)
>>> itk.ComplexToComplex1DFFTImageFilter
Loading ITKPyBase... done
Loading ITKCommon... done
Loading ITKStatistics... done
Loading ITKImageFilterBase... done
Loading ITKTransform... done
Loading ITKImageFunction... done
Loading ITKImageGrid... done
Loading ITKFFT... Traceback (most recent call last):
File "", line 1, in
File "D:\repos\ITK-GPU-bld\Wrapping\Generators\Python\itk\support\lazy.py", line 138, in __getattribute__
base.itk_load_swig_module(module, namespace)
File "D:\repos\ITK-GPU-bld\Wrapping\Generators\Python\itk\support\base.py", line 132, in itk_load_swig_module
l_module = loader.load(swig_module_name)
File "D:\repos\ITK-GPU-bld\Wrapping\Generators\Python\itk\support\base.py", line 291, in load
l_spec.loader.exec_module(l_module) # pytype: disable=attribute-error
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "D:\repos\ITK-GPU-bld\Wrapping\Generators\Python\itk\support\..\ITKFFTPython.py", line 13, in
from . import _ITKFFTPython
ImportError: DLL load failed while importing _ITKFFTPython: The specified module could not be found.
```
### Reproducibility
100%
### Versions
ITK@815d0f0531 (`main`)
### Environment
Windows 11
Python 3.10.9
CMake 3.24.3
### Additional Information
[CMakeCache.txt](https://github.com/InsightSoftwareConsortium/ITK/files/11322452/CMakeCache.txt)
Error persists after adding the NVIDIA GPU Computing Toolkit x64 directory to system `PATH` and restarting the console.
ITK FFT C++ tests all pass, the problem is limited to importing ITKFFT.
```sh
> ctest -C Release -R FFT
...
97% tests passed, 3 tests failed out of 94
...
Total Test time (real) = 16.51 sec
The following tests FAILED:
3034 - PythonFFTImageFilterTest (Failed)
3035 - PythonFFTObjectFactoryTest (Failed)
3076 - PythonFFTConvolutionImageFilterTest (Failed)
Errors while running CTest
```
Contributor guide
Assessment
This issue has not been assessed yet.