简体   繁体   English

无法在 tensorflow 仅 CPU 安装上加载动态库“cudart64_101.dll”

[英]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?如何修复错误?

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.新的 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。

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.如果您的机器上没有支持 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 的日志记录级别来抑制警告,但这可能有点矫枉过正,因为它会使所有警告静音。


Tensorflow 1.X or 2.0: Tensorflow 1.X 或 2.0:

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 支持的先决条件:

  1. Install your latest GPU drivers.安装最新的 GPU 驱动程序。
  2. Install CUDA 10.1 .安装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.如果 CUDA 安装程序报告“您正在安装较旧的驱动程序版本”,您可能希望选择自定义安装并取消选择某些组件。 Indeed, note that software bundled with CUDA including GeForce Experience, PhysX, a Display Driver, and Visual Studio integration are not required by TensorFlow.实际上,请注意 TensorFlow 不需要与 CUDA 捆绑的软件,包括 GeForce Experience、PhysX、显示驱动程序和 Visual Studio 集成。
    • Also note that TensorFlow requires a specific version of the CUDA Toolkit unless you build from source;另请注意,除非您从源代码构建,否则 TensorFlow 需要特定版本的 CUDA Toolkit; for TensorFlow 2.1 and 2.2, this is currently version 10.1.对于 TensorFlow 2.1 和 2.2,这是当前版本 10.1。
  3. Install cuDNN.安装cuDNN。
    1. Download cuDNN v7.6.4 for CUDA 10.1.下载适用于 CUDA 10.1 的cuDNN v7.6.4。 This will require you to sign up to the NVIDIA Developer Program.这将要求您注册 NVIDIA 开发人员计划。
    2. Unzip to a suitable location and add the bin directory to your PATH.解压缩到合适的位置并将 bin 目录添加到您的 PATH。
  4. Install tensorflow by pip install tensorflow .通过pip install tensorflow
  5. You may need to restart your PC .可能需要重新启动 PC

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

  1. Downloaded it from dll-files.com/CUDART64_100.DLLdll-files.com/CUDART64_100.DLL下载

  2. 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

Solution解决方案

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:如果你想快速破解:

  • Just download cudart64_101.dll from here .只需从这里下载cudart64_101.dll Extract the zip file and copy the cudart64_101.dll to your CUDA bin directory解压 zip 文件并将cudart64_101.dll复制到您的 CUDA bin目录

Else:别的:

  • Install Cuda 10.1安装 Cuda 10.1

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”]

Tensorflow gpu 2.2 and 2.3 nightly Tensorflow GPU 2.2 和 2.3 每晚

(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 修复了它。

Was able to fix the issue by updating NVIDIA device drivers to the latest (v446.14).能够通过将 NVIDIA 设备驱动程序更新到最新版本 (v446.14) 来解决该问题。 NVIDIA drivers download link here . NVIDIA 驱动程序下载链接在这里

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,您将错过这些文件

在此处输入图像描述

Solution解决方案

* just open tensoboard from anaconda * 只需从 anaconda 打开张量板

1-or just download the last Cuda toolkit and add it to paths 1-或者只是下载最后一个 Cuda 工具包并将其添加到路径

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.

相关问题 无法加载动态库“cudart64_101.dll”; 错误 - Could not load dynamic library 'cudart64_101.dll'; dlerror Tensorflow 无法识别 cudart64_101.dll - Tensorflow not recognising cudart64_101.dll TensorFlow / Keras 错误:dlerror:cudart64_101.dll 未找到 - TensorFlow / Keras Error : dlerror: cudart64_101.dll not found Python Tensorflow-GPU:“成功打开动态库cudart64_101.dll” - Python Tensorflow-GPU: "Successfully opened dynamic libraray cudart64_101.dll" Tensorflow 每次导入时都会发出警告 - 'cudart64_101.dll not found'。 有没有办法摆脱这个警告? - Tensorflow Warning every time I import it - 'cudart64_101.dll not found'. Is there a way to get rid of only this warning? tensorflow:无法加载动态库“cudart64_110.dll”; dlerror: 未找到 cudart64_110.dll - tensorflow: Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found Tensorflow 导入错误:找不到“cudart64_101.dll”(Windows 10) - Tensorflow import error: “cudart64_101.dll” not found (Windows 10) Python,tensorflow没有属性graphdef和cudart64_101.dll未找到 - Python, tensorflow has no attribute graphdef and cudart64_101.dll not found 无法加载动态库“cudart64_110.dll”; dlerror: cudart64_110.dll 未找到,我有 tensorflow.version==2.6.0 - Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found ,and i have tensorflow.version==2.6.0 Tensorflow 警告 - 无法加载动态库“cupti64_101.dll”; dlerror:cupti64_101.dll 未找到 - Tensorflow Warning - Could not load dynamic library 'cupti64_101.dll'; dlerror: cupti64_101.dll not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM