python - TensorFlow 不能使用 GPU。tf.test.is_gpu_available() 显示 GPU 但不能使用
问题描述
我有 Ubuntu 18.04。Python 3.7.3、张量流 2.0.0
这是我的 cuda 版本:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85
我的电脑是UX430UQ,显卡是GeForce 940MX
这是 nvidia-smi 的输出:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.87.01 Driver Version: 418.87.01 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce 940MX On | 00000000:01:00.0 Off | N/A |
| N/A 45C P0 N/A / N/A | 283MiB / 2004MiB | 9% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1014 G /usr/lib/xorg/Xorg 24MiB |
| 0 1164 G /usr/bin/gnome-shell 47MiB |
| 0 1440 G /usr/lib/xorg/Xorg 123MiB |
| 0 1615 G /usr/bin/gnome-shell 84MiB |
+-----------------------------------------------------------------------------+
这是我时的输出run sudo apt-get install cuda
:
Reading package lists...
Building dependency tree...
Reading state information...
cuda is already the newest version (10.1.243-1).
0 upgraded, 0 newly installed, 0 to remove and 138 not upgraded.
这是我运行时的输出tf.test.is_gpu_available()
2019-10-08 21:04:37.186069: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1006] 从 SysFS 读取的成功 NUMA 节点具有负值 (-1),但必须至少有一个 NUMA 节点,所以返回NUMA 节点零
2019-10-08 21:04:37.188434:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] 找到具有以下属性的设备 0:
名称:GeForce 940MX 主要:5 次要:0 memoryClockRate(GHz):1.2415
pciBusID: 0000:01:00.0
2019-10-08 21:04:37.188863:W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库“libcudart.so.10.0”;dlerror:libcudart.so.10.0:无法打开共享对象文件:没有这样的文件或目录;LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
2019-10-08 21:04:37.189156:W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库“libcublas.so.10.0”;dlerror:libcublas.so.10.0:无法打开共享对象文件:没有这样的文件或目录;LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
2019-10-08 21:04:37.189426:W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库“libcufft.so.10.0”;dlerror:libcufft.so.10.0:无法打开共享对象文件:没有这样的文件或目录;LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
2019-10-08 21:04:37.189687:W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库“libcurand.so.10.0”;dlerror:libcurand.so.10.0:无法打开共享对象文件:没有这样的文件或目录;LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
2019-10-08 21:04:37.189946:W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库“libcusolver.so.10.0”;dlerror:libcusolver.so.10.0:无法打开共享对象文件:没有这样的文件或目录;LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
2019-10-08 21:04:37.190202:W tensorflow/stream_executor/platform/default/dso_loader.cc:55] 无法加载动态库“libcusparse.so.10.0”;dlerror:libcusparse.so.10.0:无法打开共享对象文件:没有这样的文件或目录;LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
2019-10-08 21:04:37.190236: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] 成功打开动态库 libcudnn.so.7
2019-10-08 21:04:37.190244: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1641] 无法打开某些 GPU 库。如果您想使用 GPU,请确保正确安装了上述缺少的库。按照https://www.tensorflow.org/install/gpu上的指南,了解如何为您的平台下载和设置所需的库。
跳过注册 GPU 设备...
2019-10-08 21:04:37.190261: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] 设备互连 StreamExecutor 与强度 1 边缘矩阵:
2019-10-08 21:04:37.190268: 我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0
2019-10-08 21:04:37.190276: 我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N
解决方案
你应该使用 cuda10 和 cudnn7.4 参考这个网站
推荐阅读
- mysql - MySQL UPDATE 与 CAST/CONVERT
- powershell - 无法使用 Set-WebConfiguration system.web 在 LocalHost 级别使用 PS 更改表单或 ASP.NET
- javascript - ReactJS - 道具和组件不同步
- java - 如何使用 Get Metod 从海量中提取价值?
- javascript - 如何在生成器中测试无限循环?
- scopes - 如果我已经有 ../auth/documents.currentonly 范围,我还需要 ../auth/documents 吗?
- jsonpath - 使用 JSONPath 在多个键中查找值
- c++ - 在两个窗口中连接到相同的信号
- python - 芹菜节拍任务未执行
- ruby-on-rails - 是否允许在没有主键的情况下使用 ActiveRecord 功能?