UsingNet / nvjpeg-python

nvjpeg for python
MIT License
91 stars 24 forks source link

Import Error on Windows #12

Closed kyleb-imp closed 2 years ago

kyleb-imp commented 2 years ago

I was able to install the package through pip, but I am getting an error when importing the package: ImportError: DLL load failed while importing nvjpeg: The specified module could not be found.

I have verified that I have Cuda and Nvjpeg installed and my Cuda environment variables are pointing to the right place.

I appreciate any help getting this working. Thanks!

kyleb-imp commented 2 years ago

The error message doesn't specify which module could not be found.

kyleb-imp commented 2 years ago

I found the issue! Python 3.8 or newer does not read the Windows PATH variable, so it was unable to find the nvidia dlls. The solution is to use os.add_dll_directory before importing.


import os
os.add_dll_directory('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/bin')

from nvjpeg import NvJpeg