Ubuntu下tensorflow-gpu只能在CPU上运行的解决方案
系统信息:
- 操作系统:Ubuntu16.04
- TensorFLow安装方式:pip install tensorflow-gpu
- TensorFLow版本:1.5.0
- Python版本:Python 2.7
- CUDA版本:8.0
- cuDNN版本:7.0
问题
1.在运行一个去噪自编码器程序时,通过系统监视器观察到CPU占用率接近100%
2.通过watch -n 1 nvidia-smi #1s更新一次
监测GPU占用率,基本为0
3.利用官方推荐的log_device_placement
查看可用设备
import tensorflow as tf
with tf.device('/gpu:0'):
a = tf.constant([1.0, 2.0, 3.0], shape=[3], name='a')
b = tf.constant([1.0, 2.0, 3.0], shape=[3], name='b')
c = a + b
# 通过log_device_placement参数来输出运行每一个运算的设备。
sess= tf.Session(config=tf.ConfigProto(log_device_placement=True))
print sess.run(c)
返回错误信息Device mapping: no known devices.
解决方法
抱歉
重装
从cuda和cudnn开始
记得装正确的版本
跟着这个教程 https://www.tensorflow.org/install/install_linux#InstallingAnaconda
加油,我相信你
有问题可以留言,我会回的