win10安装tensorflow-gpu版本

几个月前用conda创建了一个python3.6的虚拟环境用于安装tensorflow-gpu,而win10下Anaconda自带的python是3.7.4版本的,后来发现默认的python3.7环境中 "No module named 'tensorflow'"!坑爹啊。干脆就把之前的python3.6版本下的虚拟环境给删除了,使用命令conda remove -n tf-py36 --all ,然后重新安装!

以前参照 https://www.cnblogs.com/guoyaohua/p/9265268.html 就没问题。

在官网https://www.tensorflow.org/install/source_windows可以看到tensorflow在1.13版本以后开始支持python3.5-3.7 了:

python版本回退的方法:conda install python=3.6
等半个小时左右。
conda search tensorflow-gpu 看到最新的2.1.0版本已经出来了,我选择1.9.0安装:
conda install tensorflow-gpu==1.9.0 很快装好了,试一下吧:

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))

可以看到:
[Info...]Found device 0 with properties:
name: GeForce GTX 1650 major: 7 minor: 5 memoryClockRate(GHz): 1.56
pciBusID: 0000:01:00.0
totalMemory: 4.00GiB freeMemory: 3.25GiB

最后sess.run几毫秒算出矩阵相乘的结果:
[[22. 28.]
 [49. 64.]]
又可以愉快地玩耍啦。

猜你喜欢

转载自blog.csdn.net/rover2002/article/details/106299823