Python 无法在 tensorflow CPU-only 安装上加载动态库“cudart64_101.dll”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/59823283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation
提问by GPhilo
I just installed the latest version of Tensorflow via pip install tensorflow
and whenever I run a program, I get the log message:
我刚刚通过安装了最新版本的 Tensorflow pip install tensorflow
,每当我运行程序时,我都会收到日志消息:
W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库“cudart64_101.dll”;dlerror: 找不到 cudart64_101.dll
Is this bad? How do I fix the error?
这很糟糕吗?如何修复错误?
回答by GPhilo
Tensorflow 2.1+
TensorFlow 2.1+
What's going on?
这是怎么回事?
With the new Tensorflow 2.1 release, the default tensorflow
pip package contains both CPU and GPU versions of TF. 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 Win the beginning stands for warnings, errors have an E(or Ffor 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):
在新的 Tensorflow 2.1 版本中,默认的tensorflow
pip 包包含 TF 的 CPU 和 GPU 版本。在以前的 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'; dlerror: cudart64_101.dll not found
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.554767: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库“cudart64_101.dll”;dlerror: 找不到 cudart64_101.dll
2020-01-20 12:27:44.554964: I tensorflow/stream_executor/cuda/cudart_stub.cc:29]如果你的机器上没有设置 GPU,请忽略上面的 cudart dlerror。
Should I worry? How do I fix it?
我应该担心吗?我如何解决它?
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. If, on the other hand, you installed tensorflow and wanted GPU acceleration, check your CUDA installation (TF 2.1 requires CUDA 10.1, not10.2 or 10.0).
如果您的机器上没有支持 CUDA 的 GPU,或者您不在乎没有 GPU 加速,则无需担心。另一方面,如果您安装了 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 levelto suppress warnings, but that might be overkill, as it will silence allwarnings.
如果您只是想摆脱警告,您可以调整 TF 的日志记录级别来抑制警告,但这可能有点矫枉过正,因为它会使所有警告静音。
Tensorflow 1.X or 2.0:
Tensorflow 1.X 或 2.0:
Your CUDA setup is broken, ensure you have the correct version installed.
您的 CUDA 设置已损坏,请确保您安装了正确的版本。
回答by Shantanu Nath
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 工作顺利。
N.B. Sorry for Bad English
NB 抱歉英语不好
回答by Chayan Bansal
To install the prerequisites for GPU support in TensorFlow 2.1:
要在 TensorFlow 2.1 中安装 GPU 支持的先决条件:
- Install your latest GPU drivers.
- Install CUDA 10.1.
- If the CUDA installer reports "you are installing an older driver version", you may wish to choose a custom installation and deselect some components. Indeed, note that software bundled with CUDA including GeForce Experience, PhysX, a Display Driver, and Visual Studio integration are not required by TensorFlow.
- Also note that TensorFlow requires a specific version of the CUDA Toolkit unless you build from source; for TensorFlow 2.1 and 2.2, this is currently version 10.1.
- Install cuDNN.
- Download cuDNNv7.6.4 for CUDA 10.1. This will require you to sign up to the NVIDIA Developer Program.
- Unzip to a suitable location and add the bin directory to your PATH.
- Install tensorflow by
pip install tensorflow
. - You may need to restart your PC.
- 安装最新的 GPU 驱动程序。
- 安装CUDA 10.1。
- 如果 CUDA 安装程序报告“您正在安装较旧的驱动程序版本”,您可能希望选择自定义安装并取消选择某些组件。实际上,请注意 TensorFlow 不需要与 CUDA 捆绑的软件,包括 GeForce Experience、PhysX、显示驱动程序和 Visual Studio 集成。
- 另请注意,除非您从源代码构建,否则 TensorFlow 需要特定版本的 CUDA Toolkit;对于 TensorFlow 2.1 和 2.2,这是当前版本 10.1。
- 安装cuDNN。
- 通过 .tensorflow 安装 tensorflow
pip install tensorflow
。 - 您可能需要重新启动 PC。
回答by Sritanu Chakraborty
Tensorflow 2.1 works with Cuda 10.1.
Tensorflow 2.1 适用于 Cuda 10.1。
If you want a quick hack:
如果你想快速破解:
- Just download
cudart64_101.dll
from here. Extract the zip file and copy thecudart64_101.dll
to your CUDAbin
directory
- 只需
cudart64_101.dll
从这里下载。解压 zip 文件并将其复制cudart64_101.dll
到您的 CUDAbin
目录
Else:
别的:
- Install Cuda 10.1
- 安装 Cuda 10.1
回答by Nicolas Gervais
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
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
Then I double checked that it worked:
然后我再次检查它是否有效:
import tensorflow as tf
tf.config.experimental.list_physical_devices('GPU')
回答by Akilion
为我工作:https: //www.joe0.com/2019/10/19/how-resolve-tensorflow-2-0-error-could-not-load-dynamic-library-cudart64_100-dll-dlerror-cudart64_100-找不到 dll/
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 文件夹中
回答by Dan Marinescu
a simpler way would be to create a link called cudart64_101.dll to point to 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)
一种更简单的方法是创建一个名为 cudart64_101.dll 的链接以指向 cudart64_102.dll。这不是很正统,但由于 tensorflow 正在寻找 cudart64_101.dll 导出的符号,而 nvidia 的人不是业余爱好者,他们很可能不会将符号从 101 删除到 102。基于这个假设,它是有效的(里程可能会有所不同)