TensorFlow 1.14.0 没有使用 GPU

新手上路,请多包涵

我在我的 Ubuntu 19.04 笔记本电脑上使用 pip install --user tensorflow-gpu 设置了 TensorFlow。所有依赖项,如 CUDA、CUDNN 都已安装并正常工作。但是,当导入 TensorFlow 并检查 tf.test.is_gpu_available() 时,仍然给出 False。我试过完全卸载并重新安装 TensorFlow,但没有用。 tf.test.is_gpu_available() 的输出:

2019-06-27 14:06:18.359739: I tensorflow/core/platform/cpu_feature_guard.cc:142] 您的 CPU 支持此 TensorFlow 二进制文件未编译使用的指令:AVX2 FMA 2019-06-27 14:06:18.611194 : I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU 频率:2194885000 Hz 2019-06-27 14:06:18.621295: I tensorflow/compiler/xla/service/service.cc:168] XLA 服务 0x19d54e0在平台主机上执行计算。设备:2019-06-27 14:06:18.621339: I tensorflow/compiler/xla/service/service.cc:175]

StreamExecutor device (0): , 2019-06-27 14:06:18.742193: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] 成功打开动态库libcuda.so.1 2019-06-27 14:06 :18.869601: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1005] 从 SysFS 读取成功的 NUMA 节点具有负值 (-1),但必须至少有一个 NUMA 节点,因此返回 NUMA 节点零 2019-06-27 14:06:18.870469: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] 找到具有属性的设备 0:名称:GeForce 920M 主要:3 次要:5 memoryClockRate(GHz):0.954 pciBusID:0000:08:00.0 2019-06-27 14:06:18.870675: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] 无法打开库 ‘libcudart.so.10.0’; dlerror:libcudart.so.10.0:无法打开共享对象文件:没有这样的文件或目录; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64 2019-06-27 14:06:18.870812: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] 无法打开库’libcublas.so。 10.0’; dlerror: libcublas.so.10.0: 无法打开共享对象文件:没有那个文件或目录; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64 2019-06-27 14:06:18.870973: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] 无法打开库’libcufft.so。 10.0’; dlerror:libcufft.so.10.0:无法打开共享对象文件:没有这样的文件或目录; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64 2019-06-27 14:06:18.871111: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] 无法打开库’libcurand.so。 10.0’; dlerror: libcurand.so.10.0: 无法打开共享对象文件:没有那个文件或目录; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64 2019-06-27 14:06:18.871228: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] 无法打开库’libcusolver.so。 10.0’; dlerror:libcusolver.so.10.0:无法打开共享对象文件:没有这样的文件或目录; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64 2019-06-27 14:06:18.871352: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] 无法打开库’libcusparse.so。 10.0’; dlerror:libcusparse.so.10.0:无法打开共享对象文件:没有这样的文件或目录; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64 2019-06-27 14:06:20.233321: I tensorflow/stream_executor/platform/default/dso_loader.cc:42]成功打开动态库libcudnn.so.7 2019-06-27 14:06:20.233363: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1663] 无法打开某些 GPU 库。跳过注册 GPU 设备… 2019-06-27 14:06:20.407248: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] 具有强度 1 边缘矩阵的设备互连 StreamExecutor:2019-06-27 14:06 :20.407318: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0 2019-06-27 14:06:20.407351: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N 2019- 06-27 14:06:20.441266: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1005] 从 SysFS 读取成功的 NUMA 节点有负值 (-1),但必须至少有一个 NUMA 节点,所以返回 NUMA 节点零 2019-06-27 14:06:20.443613: I tensorflow/compiler/xla/service/service.cc:168] XLA 服务 0x4ed6d40 在平台 CUDA 上执行计算。设备:2019-06-27 14:06:20.443670: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor 设备(0):GeForce 920M,计算能力 3.5 False

CUDA 样本的 deviceQuery 输出:

CUDA 设备查询(运行时 API)版本(CUDART 静态链接)

检测到 1 个支持 CUDA 的设备

设备 0:“GeForce 920M”CUDA 驱动程序版本/运行时版本

10.1 / 10.1 CUDA 能力主要/次要版本号:3.5 全局内存总量:4046 兆字节(4242341888 字节)(2) 多处理器,(192) CUDA 核心/MP:384 CUDA 核心 GPU 最大时钟频率:954 MHz(0.95 GHz) )

内存时钟速率:900 Mhz 内存总线宽度:64 位二级缓存大小:

524288 字节最大纹理尺寸大小 (x,y,z)

1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096) 最大分层一维纹理大小,(num) 层 1D=(16384), 2048 层最大分层二维纹理大小,(num) layers 2D=(16384, 16384), 2048 层常量内存总量:65536 字节每个块的共享内存总量:49152 字节每个块可用的寄存器总数:65536 Warp 大小:

32 每个多处理器的最大线程数:2048 每个块的最大线程数:1024 线程块的最大维度大小 (x,y,z):(1024, 1024, 64) 网格大小的最大维度大小 (x,y ,z): (2147483647, 65535, 65535) 最大内存间距:

2147483647 字节纹理对齐:512 字节并发复制和内核执行:有 1 个复制引擎内核运行时间限制:是

集成 GPU 共享主机内存:否支持主机页面锁定内存映射:是表面对齐要求:是设备具有 ECC 支持:

已禁用设备支持统一寻址 (UVA):是设备支持计算抢占:否支持合作内核启动:不支持多设备合作内核启动:无设备 PCI 域 ID/总线 ID/位置 ID:0 / 8 / 0 计算模式: < 默认值(多个主机线程可以同时对设备使用 ::cudaSetDevice() )>

deviceQuery、CUDA 驱动程序 = CUDART、CUDA 驱动程序版本 = 10.1、CUDA 运行时版本 = 10.1、NumDevs = 1 结果 = PASS

原文由 Kirill O. 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1k
2 个回答

我的特殊问题是 TensorFlow 1.14.0 正在寻找 CUDA 10.0 二进制文件,而我只安装了 10.1 。出于某种原因,CUDA 10.0 无法安装在我的 Ubuntu 19.04 上,所以我安装了 18.04 ,并按照标准方法使 TF 与 GPU 一起工作(安装 CUDA 10.0 ,安装 CUDNN 等),一切正常。

此表显示了 TF 版本与所需的 CUDA 版本: https ://www.tensorflow.org/install/source#linux

以下是 TF 的说明: https ://www.tensorflow.org/install/gpu#ubuntu_1804_cuda_10

您也可以降级到 TF 1.12 (CUDA 9.0): https ://www.tensorflow.org/install/gpu#ubuntu_1604_cuda_90_for_tensorflow_1130

原文由 Kirill O. 发布,翻译遵循 CC BY-SA 4.0 许可协议

conda install -c anaconda tensorflow-gpu=1.14.0 似乎安装支持 CUDA 10.1 的 tensorflow 1.14.0。

可以在 此处 找到更多详细信息。

原文由 Peixiang Zhong 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题