【发布时间】:2019-05-10 19:42:23
【问题描述】:
按照answer from SO,我已经跑了:
# confirm TensorFlow sees the GPU
from tensorflow.python.client import device_lib
assert 'GPU' in str(device_lib.list_local_devices())
# confirm Keras sees the GPU
from keras import backend
assert len(backend.tensorflow_backend._get_available_gpus()) > 0
# confirm PyTorch sees the GPU
from torch import cuda
assert cuda.is_available()
assert cuda.device_count() > 0
print(cuda.get_device_name(cuda.current_device()))
第一个测试有效,而其他测试无效。
运行nvcc --version 给出:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176
nvidia-smi 也可以。
list_local_devices() 提供:
[名称:“/设备:CPU:0”设备类型:“CPU”内存限制:268435456 地点 {} 化身:459307207819325532,名称: "/device:XLA_GPU:0" device_type: "XLA_GPU" memory_limit: 17179869184 位置 {} 化身:9054555249843627113 物理设备描述: “设备:XLA_GPU 设备”,名称:“/device:XLA_CPU:0” 设备类型: "XLA_CPU" memory_limit: 17179869184 locality { } 化身: 5902450771458744885 physical_device_desc:“设备:XLA_CPU设备”]
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
返回:
设备映射: /job:localhost/replica:0/task:0/device:XLA_GPU:0 -> 设备:XLA_GPU 设备 /job:localhost/replica:0/task:0/device:XLA_CPU:0 -> 设备:XLA_CPU 设备
为什么 Keras 和 PyTorch 无法在我的 GPU 上运行? (RTX 2070)
【问题讨论】:
-
这是什么keras版本?
-
实际上它也不适用于 tf
tf.test.is_gpu_available()返回 False -
@ParitoshSingh keras 是 2.2.4
-
哦,好的,如果它也不能与 tensorflow 一起使用,那么您需要为 gpu 安装 tensorflow。它涉及的步骤不仅仅是 pip 安装。
-
什么意思?我用 pip 安装了 tensorflow-gpu
标签: python tensorflow keras gpu