2018年开始学习tensorflow框架。买了块显卡1060 6G。装上了原生的ubuntu16.04。从安装显卡驱动到cuda和cudnn。无奈配置tensorflow环境一直报错。之后转回windows系统。试着继续用网上说的命令行配置,还查了tensorflow的官方文档。还是报错。
最后用最简单的anaconda navigator配置成功。前后不到2个小时。
下面说下步骤。
首先确定显卡
首先从官网https://www.anaconda.com/download/安装anaconda。版本最新的就可以。
安装完成后打开anaconda navigator
点击创建环境
输入环境名称。(我这里使用tensorflow1,因为之前创建好tensorflow。之前没有创建过的可以用tensorflow)
python版本用3.6就可以
在package选项中选择Not install会列出所有未安装package
在菜单中找到tensorflow-gpu点击apply进行安装。安装的是1.1.0版本.
环境配置好后安装pycharm
选择file>>settings>>project>>project interpreter
选择add local python interpreter
添加刚刚创建环境的python地址。
然后运行示例
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
得到
C:\Users\Administrator\AppData\Local\conda\conda\envs\tensorflow\python.exe E:/tensorflow/test.py
2018-01-05 10:12:41.831346: W c:\l\work\tensorflow-1.1.0\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2018-01-05 10:12:41.831624: W c:\l\work\tensorflow-1.1.0\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-05 10:12:41.831897: W c:\l\work\tensorflow-1.1.0\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-05 10:12:41.832299: W c:\l\work\tensorflow-1.1.0\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-05 10:12:41.832653: W c:\l\work\tensorflow-1.1.0\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-05 10:12:41.832942: W c:\l\work\tensorflow-1.1.0\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2018-01-05 10:12:41.833232: W c:\l\work\tensorflow-1.1.0\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-05 10:12:41.833522: W c:\l\work\tensorflow-1.1.0\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2018-01-05 10:12:42.160935: I c:\l\work\tensorflow-1.1.0\tensorflow\core\common_runtime\gpu\gpu_device.cc:887] Found device 0 with properties:
name: GeForce GTX 1060 6GB
major: 6 minor: 1 memoryClockRate (GHz) 1.7715
pciBusID 0000:01:00.0
Total memory: 6.00GiB
Free memory: 5.00GiB
2018-01-05 10:12:42.161316: I c:\l\work\tensorflow-1.1.0\tensorflow\core\common_runtime\gpu\gpu_device.cc:908] DMA: 0
2018-01-05 10:12:42.161567: I c:\l\work\tensorflow-1.1.0\tensorflow\core\common_runtime\gpu\gpu_device.cc:918] 0: Y
2018-01-05 10:12:42.161762: I c:\l\work\tensorflow-1.1.0\tensorflow\core\common_runtime\gpu\gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0)
b'Hello, TensorFlow!'
Process finished with exit code 0
安装成功
---------------------
作者:tangtangllll
来源:CSDN
原文:https://blog.csdn.net/tangtangllll/article/details/78978513
版权声明:本文为博主原创文章,转载请附上博文链接!