我在 docker 镜像上,所以我无法访问 docker 镜像的“外部”。我想安装带有 gpu 支持的 tensorflow,所以使用:
pip install tensorflow-gpu
cudnn 和 CUDA 已安装并运行。映像中提供了一个旧版本 (0.11),并且可以与 CUDA 和 cudnn 一起运行,但我需要升级到版本 1 或更高版本。我有两个英伟达泰坦。
使用显示的 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)
在此之后我只得到输出
没有名为 tensorflow 的模块
如果我检查点列表:
pip list | grep tensorflow
我得到输出:
张量流-GPU(1.0.1)
这是一个简单的错误导入吗?
如果我使用非 gpu-support 安装pip install tensorflow
,上面的代码给出:
设备映射:没有已知设备。
这当然是由于不支持gpu。总而言之,我如何让 tensorflow 的 GPU 版本与简单的 pip 安装和 1.0 以上的版本一起工作?
安装它
conda install tensorflow-gpu
解决了所有问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句