python需要cpu还是显卡问题_Tensorflowgpu仅在CPU上运行
我运行的是tensorflow 1.8.0,它是由“pip-install tensorflow gpu”和cuda9.0以及windows10上的cudn7.1.4一起安装的,我一直在尝试让tensorflow与我的NVIDIA GeForce GTX 860M显卡一起工作。我正在使用IDLE来运行和编写代码。在当我运行任何代码时,它只在我的CPU上执行。在我的gpu上运行MNIST tenso
我运行的是tensorflow 1.8.0,它是由“pip-install tensorflow gpu”和cuda9.0以及windows10上的cudn7.1.4一起安装的,我一直在尝试让tensorflow与我的NVIDIA GeForce GTX 860M显卡一起工作。我正在使用IDLE来运行和编写代码。在
当我运行任何代码时,它只在我的CPU上执行。在我的gpu上运行MNIST tensorflow教程之前,我运行的一些示例代码是:import tensorflow as tf
# Initialize two constants
x1 = tf.constant([1,2,3,4])
x2 = tf.constant([5,6,7,8])
# Multiply
result = tf.multiply(x1, x2)
# Intialize the Session
sess = tf.Session()
# Print the result
print(sess.run(result))
# Close the session
sess.close()
当我运行这个时,我得到这个失败的创建会话错误:
^{pr2}$
所以我在代码的开头添加了以下几行import os
os.environ["CUDA_VISIBLE_DEVICES"] = '1'
现在代码以正确的输出成功运行[ 5 12 21 32]
但它只在我的CPU上运行,当我在IDLE命令行中尝试以下命令时from tensorflow.python.client import device_lib
device_lib.list_local_devices()
输出是[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 1631189080169918107
]
我试着重启我的电脑,卸载并重新安装tensorflow gpu,并删除了我之前安装的CUDA的其他版本,但我无法让我的程序识别我的NVIDIA显卡,我查找了它,它是一个受支持的卡。在
我还能做些什么来让代码识别并在显卡上运行?在
更多推荐
所有评论(0)