我刚刚通过pip install tensorflow
安装了最新版本的Tensorflow,但是每当我运行程序时,我会收到以下日志信息:
W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态链接库'cudart64_101.dll'; dlerror:找不到cudart64_101.dll
这是有问题的吗?我该如何修复错误?
我刚刚通过pip install tensorflow
安装了最新版本的Tensorflow,但是每当我运行程序时,我会收到以下日志信息:
W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态链接库'cudart64_101.dll'; dlerror:找不到cudart64_101.dll
这是有问题的吗?我该如何修复错误?
最新发布的 TensorFlow 2.1版本,默认的 tensorflow
pip 包同时包含了 CPU 和 GPU 版本。在以前的版本中,若未找到 CUDA 库,将会出现错误并引发异常。而现在,该库会动态搜索正确的 CUDA 版本,如果未找到,则会发出警告(开头的W代表警告,错误则为或表示致命错误),并回退到仅使用CPU模式。事实上,在警告之后,完整日志中还会记录此信息(请注意,默认情况下,如果您设置了更高的最小日志级别,则可能无法看到信息消息)。完整日志如下(强调为自己添加):
2020-01-20 12:27:44.554767: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-01-20 12:27:44.554964: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] 如果您的机器上没有设置GPU,请忽略上述 cudart 错误信息。
如果你的电脑没有支持CUDA的GPU,或者你不在意没有GPU加速,那么就不用担心。但是如果你安装了tensorflow并想要使用GPU加速,请检查你的CUDA安装情况(TF 2.1需要CUDA 10.1,而不是10.2或10.0)。
如果你只是想消除警告,可以调整TF的日志级别以抑制警告,但这可能有些过度,因为它将使所有警告都被静默处理。
你的CUDA设置有问题,请确保你已安装正确版本。
pip install tensorflow
安装tensorflow。nvidia-smi
显示我的CUDA版本是11.2(TF 2.4需要CUDA 11),但实际安装和使用的CUDA版本是10.1。因此,永远不要跳过CUDA安装步骤,并始终确保您的PATH设置正确。 - NerxisTensorFlow 2.3.0可与CUDA 11良好配合使用。但您必须在安装tensorflow和CUDA 11之后安装tf-nightly-gpu:
https://pypi.org/project/tf-nightly-gpu/尝试:
pip install tf-nightly-gpu
之后您将在控制台中收到这条消息:
I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_110.dll
tf-nightly-gpu
,2)使用自定义安装方式安装最新的 Nvidia CUDA 工具包(11.2+),但不要覆盖较新的驱动程序(取消选择),3)重新启动终端,4)如果上述步骤导致 Nvidia 驱动程序出现问题,则重新安装。例如,nvidia-smi 的结果为“无法初始化 NVML:GPU 访问被操作系统阻止”。 - BSalita我选择了安装程序类型:exe(local) (适用于Windows),并以自定义模式安装了10.1(不包括Visual studio集成、NVIDIA PhysX,因为之前我安装了CUDA 10.2,所以必要的依赖项已经自动安装)。
安装完成后,在以下路径中(C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
),在我的情况下,我复制了cudart64_101.dll
文件并将其粘贴到(C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin
)。
然后导入Tensorflow就能顺利进行了。
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
添加到 PATH
中也是可行的(而且是推荐的方法),这样可以避免干扰 CUDA 安装。 - GPhilo在我的情况下,tensorflow的安装需要cudart64_101.dll文件。
{{cudart64_101}}的101部分是Cuda版本号,这里的101代表10.1。这是错误的文件!! cudart64_101.dll ≠ cudart64_110.dll
从https://developer.nvidia.com/下载Cuda 10.1
安装(我的安装在NSight Visual Studio Integration时崩溃了,所以我将其关闭)
安装完成后,您应该有一个Cuda 10.1文件夹,在bin目录中会有系统报告缺失的dll文件。
请检查10.1二进制文件夹的路径是否已注册为系统环境变量,这样加载库时就会进行检查。
如果系统没有立即捕获路径,则您可能需要重新启动
conda
环境中,以下操作解决了我的问题(我缺少 cudart64-100.dll
文件):
将该文件放入我的 conda 环境目录下的
C:\Users\<user>\Anaconda3\envs\<env name>\Library\bin
。
import tensorflow as tf
tf.config.experimental.list_physical_devices('GPU')
如果您看到以上错误,但实际上已经安装了CUDA 10,则此答案可能会有所帮助:
pip install tensorflow-gpu==2.0.0
输出:
I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
这对我来说是一个解决方案。
[名称:"/device:CPU:0" 设备类型:"CPU" 内存限制:268435456 位置 { } 化身:6812190123916921346 , 名称:"/device:GPU:0" 设备类型:"GPU" 内存限制:13429637120 地点 { bus_id: 1
links { } } 化身:18025633343883307728 物理设备描述: "device: 0, name: Quadro P5000, pci bus id: 0000:02:00.0, compute capability: 6.1"]
Tensorflow 2.1 支持 Cuda 10.1。
如果您想要快速的解决方案:
cudart64_101.dll
。解压缩文件并将 cudart64_101.dll
复制到 CUDA 的 bin
目录中否则:
bin
目录位于哪里? - Mafconda create -n YOURENVNAME python=3.6 // 3.6> incompatible with keras
conda activate YOURENVNAME
conda install tensorflow-gpu
conda install -c anaconda keras
conda install -c anaconda scikit-learn
conda install matplotlib
2020-02-23 13:31:44.910213: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-02-23 13:31:44.925815: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-02-23 13:31:44.941384: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-02-23 13:31:44.947427: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-02-23 13:31:44.965893: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-02-23 13:31:44.982990: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-02-23 13:31:44.990036: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found
我如何解决第一个警告: 我只是下载了一个包含所有cudnn文件(dll等)的压缩文件,链接在此:https://developer.nvidia.com/cudnn
我如何解决第二个警告: 我在通过conda创建的虚拟环境中查找了最后一个缺失的文件(cudart64_101.dll),然后将其复制/粘贴到与cudnn .dll相同的lib文件夹中即可。