python - TensorFlow GPU 无法识别 GPU dll
问题描述
我按照以下网站为 Tensorflow 2.4.1 安装了必要的 GPU 支持:https : //www.tensorflow.org/install/gpu,然后是实际的 Tensorflow 安装:https ://www.tensorflow.org/install/pip . 然后我运行一个示例代码片段,它应该检查 GPU 并尝试运行一个张量。它说它看不到某些 CUDA 文件,我粘贴了下面的所有文件(也与路径匹配)。我在下面粘贴了我能想到的所有相关信息。
我检查以确保正确创建了所有 dll:
PS C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin> ls
Directory: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2/13/2021 10:04 PM crt
-a---- 7/23/2020 6:58 AM 203776 bin2c.exe
-ar--- 7/27/2020 4:11 PM 58 compute-sanitizer.bat
-a---- 8/4/2020 1:57 AM 89057280 cublas64_11.dll
-a---- 8/4/2020 1:57 AM 167523328 cublasLt64_11.dll
-a---- 7/23/2020 6:58 AM 373248 cuda-memcheck.exe
-a---- 7/23/2020 6:58 AM 4604928 cudafe++.exe
-a---- 7/23/2020 6:59 AM 335872 cudart32_110.dll
-a---- 7/23/2020 6:59 AM 401408 cudart64_110.dll
-a---- 2/13/2021 8:49 PM 222720 cudnn64_8.dll
-a---- 2/13/2021 8:49 PM 99908096 cudnn_adv_infer64_8.dll
-a---- 2/13/2021 8:49 PM 65183232 cudnn_adv_train64_8.dll
-a---- 2/13/2021 8:49 PM 508834304 cudnn_cnn_infer64_8.dll
-a---- 2/13/2021 8:49 PM 51145728 cudnn_cnn_train64_8.dll
-a---- 2/13/2021 8:49 PM 240333312 cudnn_ops_infer64_8.dll
-a---- 2/13/2021 8:49 PM 25651712 cudnn_ops_train64_8.dll
-a---- 7/23/2020 6:59 AM 162878976 cufft64_10.dll
-a---- 7/23/2020 6:59 AM 272896 cufftw64_10.dll
-a---- 7/23/2020 6:59 AM 1305600 cuinj64_110.dll
-a---- 7/23/2020 6:58 AM 2828800 cuobjdump.exe
-a---- 7/23/2020 6:59 AM 52446720 curand64_10.dll
-a---- 7/23/2020 6:59 AM 525173248 cusolver64_10.dll
-a---- 7/23/2020 6:58 AM 314601984 cusolverMg64_10.dll
-a---- 7/23/2020 6:59 AM 159789568 cusparse64_11.dll
-a---- 7/23/2020 6:58 AM 302080 fatbinary.exe
-a---- 7/23/2020 6:59 AM 232448 nppc64_11.dll
-a---- 7/23/2020 6:59 AM 10907648 nppial64_11.dll
-a---- 7/23/2020 6:59 AM 4569600 nppicc64_11.dll
-a---- 7/23/2020 6:59 AM 7840256 nppidei64_11.dll
-a---- 7/23/2020 6:59 AM 51866112 nppif64_11.dll
-a---- 7/23/2020 6:59 AM 26065920 nppig64_11.dll
-a---- 7/23/2020 6:59 AM 6411264 nppim64_11.dll
-a---- 7/23/2020 6:59 AM 20231168 nppist64_11.dll
-a---- 7/23/2020 6:59 AM 203264 nppisu64_11.dll
-a---- 7/23/2020 6:59 AM 2856960 nppitc64_11.dll
-a---- 7/23/2020 6:59 AM 8873472 npps64_11.dll
-a---- 8/4/2020 1:57 AM 299520 nvblas64_11.dll
-a---- 7/23/2020 6:58 AM 408576 nvcc.exe
-a---- 7/23/2020 6:58 AM 334 nvcc.profile
-a---- 7/23/2020 6:58 AM 28080128 nvdisasm.exe
-a---- 7/23/2020 6:58 AM 3133952 nvjpeg64_11.dll
-a---- 7/23/2020 6:58 AM 7523328 nvlink.exe
-a---- 7/23/2020 6:58 AM 2173440 nvprof.exe
-a---- 7/23/2020 6:58 AM 225792 nvprune.exe
-a---- 7/23/2020 6:58 AM 5118976 nvrtc-builtins64_110.dll
-a---- 7/23/2020 6:58 AM 16161792 nvrtc64_110_0.dll
-a---- 7/23/2020 6:58 AM 53 nvvp.bat
-a---- 7/23/2020 6:58 AM 7407104 ptxas.exe
这是我的路径:
C:\Users\jnels>echo %PATH% C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\libnvvp;C :\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86) \NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\Nsight Compute 2020.1.2;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C: \Users\jnels\AppData\Local\Microsoft\WindowsApps;
然后我按照说明运行示例代码,该代码将测试 GPU 和 Tensorflow 以查看它是否有效。我应该期望看到一个张量返回:
PS C:\Users\jnels> python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
2021-02-13 23:24:28.372069: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-02-13 23:24:28.372201: 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-02-13 23:24:29.637123: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-02-13 23:24:29.638344: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll
2021-02-13 23:24:29.692627: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:0b:00.0 name: GeForce RTX 3080 computeCapability: 8.6
coreClock: 1.71GHz coreCount: 68 deviceMemorySize: 10.00GiB deviceMemoryBandwidth: 707.88GiB/s
2021-02-13 23:24:29.692892: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-02-13 23:24:29.694758: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cublas64_11.dll'; dlerror: cublas64_11.dll not found
2021-02-13 23:24:29.695158: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cublasLt64_11.dll'; dlerror: cublasLt64_11.dll not found
2021-02-13 23:24:29.695609: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cufft64_10.dll'; dlerror: cufft64_10.dll not found
2021-02-13 23:24:29.696010: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'curand64_10.dll'; dlerror: curand64_10.dll not found
2021-02-13 23:24:29.696368: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cusolver64_10.dll'; dlerror: cusolver64_10.dll not found
2021-02-13 23:24:29.696722: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cusparse64_11.dll'; dlerror: cusparse64_11.dll not found
2021-02-13 23:24:29.697079: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found
2021-02-13 23:24:29.697327: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1757] 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...
2021-02-13 23:24:29.698128: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-02-13 23:24:29.699113: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-02-13 23:24:29.699192: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267]
2021-02-13 23:24:29.699571: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
tf.Tensor(1250.3312, shape=(), dtype=float32)
解决方案
您尚未将所有必需的安装目录添加到您的路径环境变量以支持tensorflow_gpu
.
将CUDA®
、CUPTI
和cuDNN
安装目录添加到%PATH%
环境变量中,如下所示并更新您%PATH%
的匹配:
SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin;%PATH%
SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\extras\CUPTI\lib64;%PATH%
SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include;%PATH%
SET PATH=C:\tools\cuda\bin;%PATH%
您可以参考此链接以获取更多详细信息。
推荐阅读
- salesforce - 在 Apex 类上接收错误以匹配两个不同自定义对象的字段
- php - 使用 PHP 在 Apache 中运行 Node.js
- r - 如何在 R 中使用 GAM 拟合 Poisson(x1/f(x2, x3))
- c++ - 模板类——构造函数后的分号?
- javascript - 使用带有 div 和页脚的 display none 时出现问题
- jquery - react bootstrap tabs 默认显示所有选项卡而不是目标选项卡
- android - 如何在 Jetpack Compose 中传递条件参数?
- javascript - 我在制作 loginPage 时从控制台收到错误,但我不知道出了什么问题(React.js)
- c# - 将 DateTime 参数设置为仅日期
- python-3.x - 将类变量传递给方法