Tensorflow 无法识别 cudart64_101.dll [英] Tensorflow not recognising cudart64_101.dll
问题描述
我在路径中有一个 DLL 文件:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\cudart64_101.dll
,但是 TensorFlow
好像没认出来:
2020-03-11 14:39:19.815880: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库cudart64_101.dll";dlerror: 找不到 cudart64_101.dll
我确保 PATH 变量包含 DLL 的路径:
<预><代码>>>>l = os.environ['PATH'].split(';')>>>对于 l 中的 s:... 印刷)...C:\Program Files\NVIDIA GPU 计算工具包\CUDA\v10.1\bin奇怪的是,如果我用 ctypes
手动包含它,它会成功加载:
这是为什么?我该如何解决?
就我而言,问题出在python是从Windows应用商店安装的!
参见 @smreichling 对 tensorflow 的 GitHub(问题 36111):
<块引用>问题是我安装的 python 版本是来自 Microsoft Store 的版本,不是来自 python.org 的版本.事实证明,从 Microsoft Store 安装的应用程序是沙盒化的.Windows 非常严格地限制了它们可以从何处加载 DLL.在限制中:Windows不会在 PATH
环境变量中搜索 DLL 的目录.所以应用商店python永远无法通过这种方式找到CUDA DLL.
所以我安装了可从 https://www.python.org 下载的那个.
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?
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.
这篇关于Tensorflow 无法识别 cudart64_101.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!