一、Anaconda鏡像下載
下載地址(清華映像站):https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ (我下載的版本是Anaconda3-5.2.0-Windows-x86_64)
二、在Anaconda中安裝TensorFlow
2.1Anaconda修改國內鏡像源
國外網絡有時太慢,可以通過配置把下載源改為國內的。
具體步驟為:
(1)首先,打開Anaconda Prompt窗口,
(2)執行命令:conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
然后,繼續執行命令:conda config --set show_channel_urls yes
(3)在用戶目錄底下找到.condarc文件,用記事本打開,刪除第3行-defaults,保存文件
(4)至此,鏡像源已修改完畢!
2.2安裝TensorFlow
安裝普通版TensorFlow命令為:conda install tensorflow
安裝GPU版TensorFlow命令為:conda install tensorflow-gpu
2.3測試TesnorFlow是否安裝成功
打開Jupyter,
瀏覽器會自動彈出一個網頁,點新建Python3文件,輸入:
import tensorflow as tf #輸出版本號就說明安裝成功
tf.__version__ #注意是前后各有2個下划線“_”
按“Ctrl+Enter”執行
如上圖,出現版本號,則說明TensorFlow安裝完畢,至此,開發環境已經搭建完畢!
可以趁熱打鐵,敲一下在TensorFlow的第一個小程序“hello world”吧~
import tensorflow as tf hello= tf.constant("Hello.World!") #創建一個常量運算 sess = tf.Session() #創建一個TF對活 print(sess.run(hel1o)) #運行並獲得結果
關於TensorFlow的基礎知識,請看下一篇博文哦!