首页 > 解决方案 > Python3 找不到 CUDA dll 文件

问题描述

我遇到一个问题,当我尝试将 tensorflow 与我的 gpu 一起使用时,它说找不到。这是我正在运行的代码,以查看我有多少 GPU 可用

import tensorflow as tf
import tensorflow_datasets as tfds
    
    
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

我运行时收到的消息$ python3 main.py如下:

2021-09-04 16:52:04.477828: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-09-04 16:52:04.477963: 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.
2021-09-04 16:52:07.179742: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
...
2021-09-04 16:52:07.182033: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1835] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
Num GPUs Available:  0

跑步$ nvcc -V给了我

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Wed_Jul_14_19:47:52_Pacific_Daylight_Time_2021
Cuda compilation tools, release 11.4, V11.4.100
Build cuda_11.4.r11.4/compiler.30188945_0

我已按照 tensorflow 网站和 nvidia 网站上的说明进行操作。我的路径包含CUDA_PATH并且CUDA_PATH_V11_4都指向C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4cudart64_110.dll错误消息说找不到的文件在C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin

我想知道为什么我不能用它python3来运行我的程序。我已经尝试了各种各样的东西,但无法弄清楚我错过了什么。任何帮助,将不胜感激。

编辑:当我使用或通过 Jupyter 笔记本运行它时,它似乎工作正常。$ python main.py这似乎$ python3 main.py是唯一不起作用的情况。

标签: pythonpython-3.xtensorflow

解决方案


这是适用于 Tensorflow-gpu 版本的 CUDA 版本列表。 https://www.tensorflow.org/install/source#linux
检查安装和下载该版本。


推荐阅读