我在一个docker镜像上,所以我无法访问docker镜像的“外部”。我想安装tensorflow与所支持的CPU支持:用pip为gpu安装后找不到tensorflow
pip install tensorflow-gpu
cudnn和CUDA已安装并正在运行。旧版本(0.11)在图像中可用,并且正在使用CUDA和cudnn运行,但我需要升级到版本1或更高版本。我有两个Nvidia Titans。
使用显示PIP命令我使用下面的脚本,看看我是否启用了GPU的支持,同时也看看NVIDIA-SMI后:
import tensorflow as tf
# Creates a graph.
with tf.device('/gpu:0'):
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)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print sess.run(c)
在此之后我只得到输出
No module named tensorflow
如果我检查与PIP列表:
pip list | grep tensorflow
我得到的输出:
tensorflow-gpu (1.0.1)
这是一个简单的错误导入吗?
如果我使用非GPU支持安装pip install tensorflow
上面的代码给出:
Device mapping: no known devices.
这当然是由于不支持GPU的。所以总结一下,我如何获得tensorflow的GPU版本以使用简单的pip安装和1.0以上的版本?
我会用'pip install tensorflow-gpu -log'来检查pip的完整安装日志。 – fedterzi
您绝对需要GPU版本。 “no module”错误似乎表明您可能使用了错误版本的python。你确定你用来安装tensorflow的pip使用的是你运行代码的python吗? –