[英]Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation
I just installed the latest version of Tensorflow via pip install tensorflow
and whenever I run a program, I get the log message:我刚刚通过
pip install tensorflow
并且每当我运行程序时,我都会收到日志消息:
W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll';
W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
dlerror: 未找到 cudart64_101.dll
Is this bad?这很糟糕吗? How do I fix the error?
如何修复错误?
With the new Tensorflow 2.1 release , the default tensorflow
pip package contains both CPU and GPU versions of TF.在新的 Tensorflow 2.1 版本中,默认的
tensorflow
pip 包包含 TF 的 CPU 和 GPU 版本。 In previous TF versions, not finding the CUDA libraries would emit an error and raise an exception, while now the library dynamically searches for the correct CUDA version and, if it doesn't find it, emits the warning (The W in the beginning stands for warnings, errors have an E (or F for fatal errors) and falls back to CPU-only mode. In fact, this is also written in the log as an info message right after the warning (do note that if you have a higher minimum log level that the default, you might not see info messages). The full log is (emphasis mine):在以前的 TF 版本中,找不到 CUDA 库会发出错误并引发异常,而现在库会动态搜索正确的 CUDA 版本,如果找不到,则会发出警告(开头的W表示对于警告,错误有一个E (或F表示致命错误)并回退到 CPU-only 模式。事实上,这也在警告之后作为信息消息写入日志(请注意,如果您有更高的默认的最低日志级别,您可能看不到信息消息。完整的日志是(强调我的):
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';
2020-01-20 12:27:44.554767: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库“cudart64_101.dll”; dlerror: cudart64_101.dll not found
dlerror: 找不到 cudart64_101.dll
2020-01-20 12:27:44.554964: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2020-01-20 12:27:44.554964: I tensorflow/stream_executor/cuda/cudart_stub.cc:29]如果你的机器上没有设置 GPU,请忽略上面的 cudart dlerror。
If you don't have a CUDA-enabled GPU on your machine, or if you don't care about not having GPU acceleration, no need to worry.如果您的机器上没有支持 CUDA 的 GPU,或者您不在乎没有 GPU 加速,则无需担心。 If, on the other hand, you installed tensorflow and wanted GPU acceleration, check your CUDA installation (TF 2.1 requires CUDA 10.1 , not 10.2 or 10.0).
另一方面,如果您安装了 tensorflow 并想要 GPU 加速,请检查您的 CUDA 安装(TF 2.1 需要 CUDA 10.1 ,而不是10.2 或 10.0)。
If you just want to get rid of the warning, you can adapt TF's logging level to suppress warnings, but that might be overkill, as it will silence all warnings.如果您只是想摆脱警告,您可以调整 TF 的日志记录级别来抑制警告,但这可能有点矫枉过正,因为它会使所有警告静音。
Your CUDA setup is broken, ensure you have the correct version installed.您的 CUDA 设置已损坏,请确保您安装了正确的版本。
To install the prerequisites for GPU support in TensorFlow 2.1:要在 TensorFlow 2.1 中安装 GPU 支持的先决条件:
pip install tensorflow
.pip install tensorflow
。TensorFlow 2.3.0 works fine with CUDA 11. But you have to install tf-nightly-gpu (after you installed tensorflow and CUDA 11): https://pypi.org/project/tf-nightly-gpu/ TensorFlow 2.3.0 在 CUDA 11 上运行良好。但是你必须安装 tf-nightly-gpu(在你安装了 tensorflow 和 CUDA 11 之后): https ://pypi.org/project/tf-nightly-gpu/
Try:尝试:
pip install tf-nightly-gpu
Afterwards you'll get the message in your console:之后,您将在控制台中收到消息:
I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_110.dll
I solved this another way.我用另一种方式解决了这个问题。 First of all I installed cuda 10.1 toolkit from this link
首先,我从此链接安装了 cuda 10.1 工具包
Where i selected installer type(exe(local)) and installed 10.1 in custom mode means (without visual studio integration, NVIDIA PhysX because previously I installed CUDA 10.2 so required dependencies were installed automatically)我选择安装程序类型(exe(本地))并在自定义模式下安装 10.1 意味着(没有 Visual Studio 集成,NVIDIA PhysX 因为以前我安装了 CUDA 10.2 所以需要的依赖项会自动安装)
After installation, From the Following Path (C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.1\\bin) , in my case, I copied 'cudart64_101.dll' file and pasted in (C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2\\bin).安装后,从以下路径 (C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.1\\bin) ,在我的例子中,我复制了“cudart64_101.dll”文件并粘贴到 (C:\\Program Files\\ NVIDIA GPU 计算工具包\\CUDA\\v10.2\\bin)。
Then importing Tensorflow worked smoothly.然后导入 Tensorflow 工作顺利。
NB Sorry for Bad English NB 抱歉英语不好
In a conda
environment, this is what solved my problem (I was missing cudart64-100.dll
:在
conda
环境中,这就是解决我的问题的原因(我缺少cudart64-100.dll
:
Downloaded it from dll-files.com/CUDART64_100.DLL从dll-files.com/CUDART64_100.DLL下载
Put it in my conda environment at C:\\Users\\<user>\\Anaconda3\\envs\\<env name>\\Library\\bin
把它放在我的 conda 环境中
C:\\Users\\<user>\\Anaconda3\\envs\\<env name>\\Library\\bin
That's all it took!这就是全部! You can double check if it's working:
您可以仔细检查它是否有效:
import tensorflow as tf
tf.config.experimental.list_physical_devices('GPU')
In my case the tensorflow install was looking for cudart64_101.dll在我的情况下,tensorflow 安装正在寻找 cudart64_101.dll
The 101 part of cudart64_101 is the Cuda version - here 101 = 10.1 cudart64_101 的 101 部分是 Cuda 版本 - 这里 101 = 10.1
I had downloaded 11.x, so the version of cudart64 on my system was cudart64_110.dll我下载的是11.x,所以我系统上cudart64的版本是cudart64_110.dll
This is the wrong file!!这是错误的文件!! cudart64_101.dll ≠ cudart64_110.dll
cudart64_101.dll ≠ cudart64_110.dll
Download Cuda 10.1 from https://developer.nvidia.com/从https://developer.nvidia.com/下载 Cuda 10.1
Install (mine crashes with NSight Visual Studio Integration, so I switched that off)安装(我的 NSight Visual Studio 集成崩溃了,所以我把它关掉了)
When the install has finished you should have a Cuda 10.1 folder, and in the bin the dll the system was complaining about being missing安装完成后,您应该有一个 Cuda 10.1 文件夹,并且在 bin 中系统抱怨缺少 dll
Check that the path to the 10.1 bin folder is registered as a system environmental variable, so it will be checked when loading the library检查10.1 bin文件夹的路径是否注册为系统环境变量,所以在加载库时会检查
You may need a reboot if the path is not picked up by the system straight away如果系统没有立即选择该路径,您可能需要重新启动
This answer might be helpful if you see above error but actually you have CUDA 10 installed:如果您看到上述错误,但实际上您安装了 CUDA 10,此答案可能会有所帮助:
pip install tensorflow-gpu==2.0.0
output:输出:
I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
which was the solution for me.这对我来说是解决方案。
This solution worked for me :这个解决方案对我有用:
I preinstalled the environnement with anaconda (here is the code)我用 anaconda 预装了环境(这是代码)
conda 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
but after I had still these warnings但在我仍然收到这些警告之后
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
How I solved the first warning : I just download a zip file wich contained all the cudnn files (dll, etc) here : https://developer.nvidia.com/cudnn我如何解决第一个警告:我只是下载一个包含所有 cudnn 文件(dll 等)的 zip 文件: https : //developer.nvidia.com/cudnn
How I solved the second warning : I looked the last missing file (cudart64_101.dll) in my virtual env created by conda and I just copy/pasted it in the same lib folder than for the .dll cudnn我如何解决第二个警告:我在由 conda 创建的虚拟环境中查看了最后一个丢失的文件(cudart64_101.dll),我只是将它复制/粘贴到与 .dll cudnn 相同的 lib 文件夹中
Tensorflow 2.1 works with Cuda 10.1. Tensorflow 2.1 适用于 Cuda 10.1。
If you want a quick hack:如果你想快速破解:
cudart64_101.dll
from here .cudart64_101.dll
。 Extract the zip file and copy the cudart64_101.dll
to your CUDA bin
directorycudart64_101.dll
复制到您的 CUDA bin
目录Else:别的:
I installed cudatoolkit 11 and copy dll C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.1\\bin
to C:\\Windows\\System32
.我安装了 cudatoolkit 11 并将 dll
C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.1\\bin
复制到C:\\Windows\\System32
。 It fixed for PyCharm but not for Anaconda jupyter:它适用于 PyCharm,但不适用于 Anaconda jupyter:
[name: "/device:CPU:0" device_type: "CPU" memory_limit: 268435456 locality { } incarnation: 6812190123916921346 , name: "/device:GPU:0" device_type: "GPU" memory_limit: 13429637120 locality { bus_id: 1
[name: "/device:CPU:0" device_type: "CPU" memory_limit: 268435456 locality { } 化身:6812190123916921346 , name: "/device:GPU:0" device_type: "GPU" memory_limit: 1342963 bus_id: locality1
links { } } incarnation: 18025633343883307728 physical_device_desc: "device: 0, name: Quadro P5000, pci bus id: 0000:02:00.0, compute capability: 6.1" ]链接 { } } 化身:18025633343883307728 physical_device_desc:“设备:0,名称:Quadro P5000,pci 总线 ID:0000:02:00.0,计算能力:6.1”]
(along CUDA Toolkit 11.0 RC) (沿 CUDA 工具包 11.0 RC)
To solve the same issue as OP, I just had to find cudart64_101.dll on my disk (in my case C:\\Program Files\\NVIDIA Corporation\\NvStreamSrv ) and add it as variable environment (that is add value C:\\Program Files\\NVIDIA\\Corporation\\NvStreamSrv)cudart64_101.dll to user's environment variable Path ).为了解决与 OP 相同的问题,我只需要在我的磁盘上找到cudart64_101.dll (在我的情况下C:\\Program Files\\NVIDIA Corporation\\NvStreamSrv )并将其添加为变量环境(即添加值C:\\Program Files \\NVIDIA\\Corporation\\NvStreamSrv)cudart64_101.dll到用户的环境变量Path )。
This could be caused by the version of python you are running as well, I was using the python 3.7 from the microsoft store and I run into this error, switching to python 3.10 fixed it.这可能是由您正在运行的 python 版本引起的,我使用的是来自微软商店的 python 3.7,我遇到了这个错误,切换到 python 3.10 修复了它。
download CUDA Toolkit 11.0 RC下载 CUDA 工具包 11.0 RC
To solve the issue, I just find cudart64_101.dll on my disk ( C:\\Program Files\\NVIDIA Corporation\\NvStreamSrv) and add it as variable environment that is add value (C:\\Program Files\\NVIDIA\\Corporation\\NvStreamSrv)cudart64_101.dll to user's environment variable Path).为了解决这个问题,我只是在我的磁盘上找到 cudart64_101.dll(C:\\Program Files\\NVIDIA Corporation\\NvStreamSrv)并将其添加为变量环境,即添加值(C:\\Program Files\\NVIDIA\\Corporation\\NvStreamSrv)cudart64_101 .dll 到用户的环境变量 Path)。
I ran into this problem when mixing pip & conda to get tensorflow 2.3 installed.我在混合 pip 和 conda 以安装 tensorflow 2.3 时遇到了这个问题。 (I used pip to install tensorflow 2.3 b/c at the time conda's install of tensorflow 2.3 was broken.)
(在 conda 安装 tensorflow 2.3 时,我使用 pip 安装了 tensorflow 2.3 b/c。)
I ended up with the incorrect versions of cudatoolkit and cudnn installed.我最终安装了不正确版本的 cudatoolkit 和 cudnn。
To solve the problem, I simply did conda install
with specific versions of cudatoolkit and cuda specified.为了解决这个问题,我只是使用特定版本的 cudatoolkit 和 cuda 指定了 conda
conda install
。
Look at https://www.tensorflow.org/install/source_windows?force_isolation=true#tested_build_configurations for info on tensorflow, cudatoolkit, and cuda versions that should work together.查看https://www.tensorflow.org/install/source_windows?force_isolation=true#tested_build_configurations了解有关 tensorflow、cudatoolkit 和应该一起工作的 cuda 版本的信息。
I don't know if this is optimal in the long run.我不知道从长远来看这是否是最佳选择。 But for me, only need to run the this project once, so this way is very fast.
但是对我来说,这个项目只需要运行一次,所以这种方式非常快。
Add the 2 lines below at the beginning of your code:在代码开头添加以下 2 行:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
It's best to put it at the beginning of the code, I tried putting it after importing all the libraries, but it still says waiting.
最好放在代码的开头,我试着把所有的库都导入后放,但还是说等待。
I think I should still dig deeper into this error, it seems to be related to my computer, but I'm very busy right now:D lol
我想我还是应该深入挖掘一下这个错误,它似乎与我的电脑有关,但我现在很忙:D lol
I had this error here with tensorboard, it happen after I update the GPU driver the thing is i was running tensorboard from the cmd where I didn't install any CUDA since I was using anaconda when you install TensorFlow using anaconda all the required cuda and cudnn are downloaded for you
you will miss the files if you didn't use anaconda env where you install TensorFlow in it I had this error here with tensorboard, it happen after I update the GPU driver the thing is i was running tensorboard from the cmd where I didn't install any CUDA since I was using anaconda
when you install TensorFlow using anaconda all the required cuda and cudnn are downloaded for you
如果您没有使用 anaconda 环境,您将在其中安装 TensorFlow,您将错过这些文件
https://developer.nvidia.com/cuda-toolkit-archive https://developer.nvidia.com/cuda-toolkit-archive
and use this 2- conda install -c anaconda cudatoolkit
并使用这个 2-
conda install -c anaconda cudatoolkit
3-then restart your pc 3-然后重启你的电脑
A simpler way would be to create a link called cudart64_101.dll
to point to cudart64_102.dll
.一种更简单的方法是创建一个名为
cudart64_101.dll
的链接以指向cudart64_102.dll
。 This is not very orthodox but since TensorFlow is looking for cudart64_101.dll
exported symbols and the nvidia folks are not amateurs, they would most likely not remove symbols from 101 to 102. It works, based on this assumption (mileage may vary).这不是很正统,但由于 TensorFlow 正在寻找
cudart64_101.dll
导出的符号,而 nvidia 的人不是业余爱好者,他们很可能不会从 101 到 102 中删除符号。它的工作原理基于这个假设(里程可能会有所不同)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.