1. 程式人生 > >anaconda+pycharm配置tensorflow-GPU環境最簡單方法

anaconda+pycharm配置tensorflow-GPU環境最簡單方法

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 
版權宣告:本文為博主原創文章,轉載請附上博文連結!