pyinstaller with RTK+VTK

I use pyinstaller to generate a demo that can reconstruction data and show the result. The reconstruction is similar to FirstCudaReconstruction.py. My list of installed package is below.

Package                   Version
------------------------- ----------
altgraph                  0.17.4
certifi                   2021.10.8
click                     8.1.7
colorama                  0.4.6
contourpy                 1.2.0
cycler                    0.12.1
fonttools                 4.47.2
importlib_metadata        7.1.0
importlib-resources       6.1.1
itk                       5.4rc1
itk-core                  5.4rc1
itk-cudacommon-cuda116    1.0.1
itk-filtering             5.4rc1
itk-io                    5.4rc1
itk-numerics              5.4rc1
itk-registration          5.4rc1
itk-rtk-cuda116           2.5.0
itk-segmentation          5.4rc1
Jinja2                    3.1.3
kiwisolver                1.4.5
MarkupSafe                2.1.5
matplotlib                3.8.4
numpy                     1.24.1
nvidia-ml-py3             7.352.0
opencv-python             4.9.0.80
packaging                 23.2
pefile                    2023.2.7
pillow                    10.2.0
pip                       23.3.2
pyinstaller               5.9.0
pyinstaller-hooks-contrib 2024.3
pyparsing                 3.1.1
pypiwin32                 223
PyQt5                     5.15.9
pyqt5-plugins             5.15.9.2.3
PyQt5-Qt5                 5.15.2
PyQt5-sip                 12.13.0
pyqt5-tools               5.15.9.3.3
python-dateutil           2.8.2
python-dotenv             1.0.1
pywin32                   306
pywin32-ctypes            0.2.2
qt-material               2.14
qt5-applications          5.15.2.2.3
qt5-tools                 5.15.2.1.3
scipy                     1.12.0
setuptools                58.0.4
six                       1.16.0
vtk                       9.3.0
wheel                     0.37.0
wincertstore              0.2
zipp                      3.17.0

I use pyinstaller XX.spec to generate .exe file. The folder didn’t contain itk first, and I append hiddenimports=['itk'] on the .spec file.
The demo can run correctly on my computer, but an error occurred on other computers when the code runs to

itk.RTK.CudaImage[itk.F, 3]

企业微信截图_17125625312832
I think may I didn’t correct pyinstaller itk, but I don’t know how to solve it. Any help would be appreciated.

I don’t know pyinstaller but it seems related to inability to locate Cuda DLLs, which is solved in the example with the following line:

os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin'))
1 Like

I print the path of Cuda when the demo run in other computer. It seems related to inability to locate Cuda DLLs.
企业微信截图_20240409091000
Should the DLL used in code itk.RTK.CudaImage[itk.F, 3] not be _ITKCommonPython instead of _CudaCommonPython?

I copyed all the files about itk from site-packages, and replace the files on the exe folder.
Before this operation, I also made the following attempts:

  1. Pip uninstall itk and reinstall itk;
  2. Add itk’s path to .spec;
  3. Try pyinstaller from begin;

There was no error reported in the end.

Hi,

This post is helpful for the pyinstaller + ITK + RTK process:

Thank you for your reply. I have try this method on the fist, but it didn’t work.

But when I try the three attempts and then use that method again. It works. I don’t know why, but at least the result is good.

1 Like