在Thinkpad E470中安装Tensorflow后无法使用GPU

问题描述 投票:0回答:1

我是TensorFlow的初学者。我的电脑是Thinkpad E 470.我的电脑显示器是Inter HD Graphics 620,我的电脑渲染是NVIDIA GeForce 940 MX,它应该支持TensorFlow(GPU版本)。

但是,在安装TensorFlow之后。当我尝试运行以下代码时:

import tensorflow as tf
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"   # see issue #152
#os.environ["CUDA_VISIBLE_DEVICES"]="-1"
os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2,3,4,5"
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
[![enter image description here][1]][1]

反馈是:

print(device_lib.list_local_devices())
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 8429792091945466266
]

这是另一个代码及其结果:

with tf.device('/gpu:1'):
  a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
  b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
  c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print (sess.run(c))

InvalidArgumentError: Cannot assign a device for operation 'MatMul_1': 
Operation was explicitly assigned to /device:GPU:1 but available devices 
are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device 
specification refers to a valid device.
 [[Node: MatMul_1 = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, 
_device="/device:GPU:1"](a_1, b_1)]]

我的GPU在哪里?谢谢!

python-3.x tensorflow
1个回答
1
投票

在双GPU系统上,您需要确保在运行张量流之前或运行时激活离散GPU。在linux上,您需要安装bumblebee并使用optirun为命令添加前缀。在Windows上,我没有使用过自己,但本指南看起来很相关:https://devtalk.nvidia.com/default/topic/1025951/unable-to-install-cuda-8-0-properly-in-optimus-windows-10-laptop/

© www.soinside.com 2019 - 2024. All rights reserved.