1. 程式人生 > >程式設計師的Linux環境搭建——Ubuntu16.04+anaconda+TensorFlow

程式設計師的Linux環境搭建——Ubuntu16.04+anaconda+TensorFlow

安裝anaconda

首先安裝Python,建議直接安裝anaconda,anaconda中包含了包括Python在內的很多環境,非常方便,同時也可以很方便的建立多個Python版本的環境,在清華的開源映象站中下載anaconda,網址是https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

anaconda下載並安裝完成之後,不要先急著安裝tensorflow,先執行一下三條命令,否則用pip或者conda安裝其他包的時候會很慢

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

 清華映象下載的anaconda檔案為.sh檔案 安裝過程很簡單,執行如下指令即可:

bash Anaconda3-4.2.0-Linux-x86_64.sh

anaconda安裝完成之後,使用anaconda Python環境安裝第三方包的時候可能會提示許可權不足,所以先賦許可權給anaconda所在資料夾,指令如下:其中jiabin是我的使用者名稱,/home/jiabin/anaconda3 是我安裝的anaconda所在資料夾.

sudo chwn -R jiabin  /home/jiabin/anaconda3

新增新的python環境

安裝anaconda會帶有一個Python,具體的Python版本由anaconda的版本決定,若發現anaconda攜帶的Python版本不是自己想要的,可以通過如下命令建立新的Python環境。

conda create --name python27 python=2.7

 設定預設mython環境

anaconda安裝完成之後,需要設定anaconda的python環境為預設環境

在終端輸入$sudo gedit /etc/profile,開啟profile檔案。

在檔案末尾新增一行:export PATH=/path/to/your/anaconda3/bin:$PATH

執行 source /etc/procile使修改的配置檔案生效

安裝TensorFlow

執行下列程式碼安裝tensorflow,此處安裝的是GPU版本的TensorFlow1.5.0

conda install tensorflow-gpu==1.5.0