配个TensorFlow_gpu折腾了差不多两天,真是醉了。现在总结一下,以防自己在后面再次掉坑。
原本电脑安装的TensorFlow是CPU版的,所以直接用命令 "pip uninstall tensorflow"将原来的TensorFlow卸载。卸载完后安装tensorflow_gpu版本。
掉的坑1:下载好文件“tensorflow_gpu-1.7.0-cp35-cp35m-win_amd64.whl”,将其放在c盘的根目录下,然后用命令“pip install c:\tensorflow_gpu-1.7.0-cp35-cp35m-win_amd64.whl”安装,运行后发现需要cuda9.0的版本,但是由于本人电脑早已安装了cuda8.0,然后自己猜想,可能是TensorFlow的版本太高了,所以对应的才需要cuda9.0。为了匹配我的cuda8.0,我毅然下了早一点的TensorFlow版本“tensorflow_gpu-1.6.0-cp35-cp35m-win_amd64.whl”。将TensorFlow1.7删掉,安装1.6版本,发现还是需要cuda9.0.好吧,接下来还是乖乖去下cuda9.0吧。
掉的坑2:不知道英伟达的服务器端怎么了,我下载cuda9.0的过程是一波三折的,下了很多次都没有成功。同样,cudnn for cuda9.0的下载也是蛮艰辛的,尝试了几个版本,最终只能下载才成功。
安装过程:(参照https://blog.csdn.net/sb19931201/article/details/53648615)
(1)安装Anaconda3-2.4.1-Windows-x86_64
(2)安装tensorflow_gpu-1.6.0-cp35-cp35m-win_amd64.whl
(3)安装cuda9.0
(4)安装cudnn for cuda9.0
(5)测试
import tensorflow as tf
#Creates a graph.
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))