Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow not recognising cudart64_101.dll

I have a DLL file in the path: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\cudart64_101.dll, but TensorFlow doesn't seem to recognize it:

2020-03-11 14:39:19.815880: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found

I made sure that the PATH variable contains the path to the DLL:

>>> l = os.environ['PATH'].split(';')
>>> for s in l:
...     print(s)
...
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin

The weird part is that if I include it manually with ctypes it gets loaded successfully:

>>> import ctypes
>>> hllDll = ctypes.WinDLL("C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.1\\bin\\cudart64_101.dll")
>>> import tensorflow as tf
2020-03-11 15:05:26.907300: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll

Why is that? How can I fix it?

like image 493
Omer Lubin Avatar asked Mar 11 '20 13:03

Omer Lubin


1 Answers

In my case, the problem was from the python was installed from Windows Store!

See @smreichling's comment on tensorflow's GitHub (issue 36111):

The problem turned out to be that the version of python I had installed was the one from the Microsoft Store and not the one from python.org. As it turns out, apps installed from the Microsoft Store are sandboxed. Windows restricts where they can load DLLs from pretty severely. Among the restrictions: Windows does not search the directories in the PATH env var for the DLLs. So app store python will never be able to find CUDA DLLs this way.

So I installed the one that's downloadable from https://www.python.org.

like image 85
Mir-Ismaili Avatar answered Sep 18 '22 16:09

Mir-Ismaili