python - tensorflow-gpu 找不到 GPU
问题描述
经过多次尝试,即使我做了所有写在这个链接https://www.tensorflow.org/install/gpu 上的事情;我无法使用我的 GPU。我尝试了许多版本的 Cuda(11.0 11.1,最后一个是 10.1),但 TensorFlow 没有检测到 GPU(Geforce Gtx 1050 ti)。
import tensorflow as tf
tf.test.is_built_with_cuda()
返回真。
tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)
输出:
2020-10-07 20:14:11.242732: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
WARNING:tensorflow:From C:/Users/Lenovo/PycharmProjects/AI/test.py:2: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2020-10-07 20:14:13.554045: 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.
2020-10-07 20:14:13.563910: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1e9683ca5f0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-07 20:14:13.564367: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2020-10-07 20:14:13.565594: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library nvcuda.dll
2020-10-07 20:14:13.586511: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1050 Ti computeCapability: 6.1
coreClock: 1.62GHz coreCount: 6 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.43GiB/s
2020-10-07 20:14:13.587248: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
2020-10-07 20:14:13.592223: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cublas64_10.dll
2020-10-07 20:14:13.596083: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cufft64_10.dll
2020-10-07 20:14:13.597794: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library curand64_10.dll
2020-10-07 20:14:13.602129: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusolver64_10.dll
2020-10-07 20:14:13.604848: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusparse64_10.dll
2020-10-07 20:14:13.607078: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found
2020-10-07 20:14:13.607657: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] 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...
2020-10-07 20:14:13.686263: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-10-07 20:14:13.686660: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263] 0
2020-10-07 20:14:13.686904: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0: N
2020-10-07 20:14:13.689990: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1e97492faf0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-10-07 20:14:13.690470: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): GeForce GTX 1050 Ti, Compute Capability 6.1
3天后,我别无选择,也不知道。你能帮我解决问题吗?
编辑:我解决了这个问题。TensorFlow 搜索“cudnn64_7.dll”文件名。如果找不到搜索的文件名,则 cuDNN 不起作用(即使您将 cuDNN 文件添加到 Cuda 文件中)。我下载的 CuDNN 有一个名为“cudnn64_8.dll”的文件。我找到了文件并重命名了它。所以TensorFlow可以找到GPU。
解决方案
你可以试试蟒蛇。它是python的包管理器。它允许您安装 tensorflow 以准备使用您的 gpu 进行处理,而不会遇到 CUDA 和 cuDNN 版本的问题。我将在这里留下 Anaconda 安装程序的链接以及如何从中安装 tensorflow-gpu 包。
推荐阅读
- javascript - 如何减小 Node.js 应用程序大小(或构建它)
- python - 如何在 pytorch 模型中初始化权重
- java - 为什么我的服务器(在线程中运行)没有收到 DatagramPackage?
- pandas - Pandas 过滤最大分组方式
- mapreduce - 检查列表的所有元素是否在 Raku 中都是素数
- ios - 我需要用字符串返回当前分数,但是当我快速点击按钮时,我看不到任何这样做的选项
- python - gpu 未完全使用,模型在 cpu 中的运行时间与在 gpu 中运行的时间相同
- reactjs - 带有 babel 的 webpack 显示错误模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):
- activerecord - Yii2 activerecord不返回数据库触发值
- go - go-run 在相对子模块上给我一个错误“找不到包”