轉(zhuǎn)載至http://www.cnblogs.com/willnote/p/6746499.html
Anaconda安裝
在清華大學(xué) TUNA 鏡像源選擇對(duì)應(yīng)的操作系統(tǒng)與所需的Python版本下載Anaconda安裝包。Windows環(huán)境下的安裝包直接執(zhí)行.exe文件進(jìn)行安裝即可,Ubuntu環(huán)境下在終端執(zhí)行
$bashAnaconda2-4.3.1-Linux-x86_64.sh#Python2.7版本
或者
$bashAnaconda3-4.3.1-Linux-x86_64.sh#Python3.5版本
在安裝的過程中,會(huì)詢問安裝路徑,按回車即可。之后會(huì)詢問是否將Anaconda安裝路徑加入到環(huán)境變量(.bashrc)中,輸入yes,這樣以后在終端中輸入python即可直接進(jìn)入Anaconda的Python版本(如果你的系統(tǒng)中之前安裝過Python,自行選擇yes or no)。安裝成功后,會(huì)有當(dāng)前用戶根目錄下生成一個(gè)anaconda2的文件夾,里面就是安裝好的內(nèi)容
查詢安裝信息
$conda info
查詢當(dāng)前已經(jīng)安裝的庫(kù)
$ condalist
安裝庫(kù)(***代表庫(kù)名稱)
$ conda install***
更新庫(kù)
$ conda update***
Anaconda倉(cāng)庫(kù)鏡像
官方下載更新工具包的速度很慢,所以繼續(xù)添加清華大學(xué) TUNA提供的Anaconda倉(cāng)庫(kù)鏡像,在終端或cmd中輸入如下命令進(jìn)行添加
$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/$ conda config --setshow_channel_urls yes$ conda install numpy#測(cè)試是否添加成功
之后會(huì)自動(dòng)在用戶根目錄生成“.condarc”文件,Ubuntu環(huán)境下路徑為~/.condarc,Windows環(huán)境下路徑為C:\用戶\your_user_name\.condarc
channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/-defaultsshow_channel_urls:yes
如果要?jiǎng)h除鏡像,直接刪除“.condarc”文件即可
Tensorflow安裝
在終端或cmd中輸入以下命令搜索當(dāng)前可用的tensorflow版本
$ anaconda search -t conda tensorflowUsing AnacondaAPI:https://api.anaconda.orgRun'anaconda show 'to get moredetails:Packages:Name? ? ? ? ? ? ? ? ? ? ? |? Version | Package Types? | Platforms? ? ? ? ? ------------------------- |? ------ | --------------- | ---------------? ? HCC/tensorflow? ? ? ? ? ? |1.0.0| conda? ? ? ? ? | linux-64HCC/tensorflow-cpucompat? |1.0.0| conda? ? ? ? ? | linux-64HCC/tensorflow-fma? ? ? ? |1.0.0| conda? ? ? ? ? | linux-64SentientPrime/tensorflow? |0.6.0| conda? ? ? ? ? | osx-64: TensorFlow helps the tensors flow? ? acellera/tensorflow-cuda? |0.12.1| conda? ? ? ? ? | linux-64anaconda/tensorflow? ? ? |1.0.1| conda? ? ? ? ? | linux-64anaconda/tensorflow-gpu? |1.0.1| conda? ? ? ? ? | linux-64conda-forge/tensorflow? ? |1.0.0| conda? ? ? ? ? | linux-64, win-64, osx-64: TensorFlow helps the tensors flow? ? creditx/tensorflow? ? ? ? |0.9.0| conda? ? ? ? ? | linux-64: TensorFlow helps the tensors flow? ? derickl/tensorflow? ? ? ? |0.12.1| conda? ? ? ? ? | osx-64dhirschfeld/tensorflow? ? |0.12.0rc0 | conda? ? ? ? ? | win-64dseuss/tensorflow? ? ? ? |? ? ? ? ? | conda? ? ? ? ? | osx-64guyanhua/tensorflow? ? ? |1.0.0| conda? ? ? ? ? | linux-64ijstokes/tensorflow? ? ? |2017.03.03.1349| conda, ipynb? ? | linux-64jjh_cio_testing/tensorflow |1.0.1| conda? ? ? ? ? | linux-64jjh_cio_testing/tensorflow-gpu |1.0.1| conda? ? ? ? ? | linux-64jjh_ppc64le/tensorflow? ? |1.0.1| conda? ? ? ? ? | linux-ppc64le? ? ? jjh_ppc64le/tensorflow-gpu |1.0.1| conda? ? ? ? ? | linux-ppc64le? ? ? jjhelmus/tensorflow? ? ? |0.12.0rc0 | conda, pypi? ? | linux-64, osx-64: TensorFlow helps the tensors flow? ? jjhelmus/tensorflow-gpu? |1.0.1| conda? ? ? ? ? | linux-64kevin-keraudren/tensorflow |0.9.0| conda? ? ? ? ? | linux-64lcls-rhel7/tensorflow? ? |0.12.1| conda? ? ? ? ? | linux-64marta-sd/tensorflow? ? ? |1.0.1| conda? ? ? ? ? | linux-64: TensorFlow helps the tensors flow? ? memex/tensorflow? ? ? ? ? |0.5.0| conda? ? ? ? ? | linux-64, osx-64: TensorFlow helps the tensors flow? ? mhworth/tensorflow? ? ? ? |0.7.1| conda? ? ? ? ? | osx-64: TensorFlow helps the tensors flow? ? miovision/tensorflow? ? ? |0.10.0.gpu | conda? ? ? ? ? | linux-64, osx-64msarahan/tensorflow? ? ? |1.0.0rc2 | conda? ? ? ? ? | linux-64mutirri/tensorflow? ? ? ? |0.10.0rc0 | conda? ? ? ? ? | linux-64mwojcikowski/tensorflow? |1.0.1| conda? ? ? ? ? | linux-64rdonnelly/tensorflow? ? ? |0.9.0| conda? ? ? ? ? | linux-64rdonnellyr/r-tensorflow? |0.4.0| conda? ? ? ? ? | osx-64test_org_002/tensorflow? |0.10.0rc0 | conda? ? ? ? ? |? ? ? ? ? ? ? ? Found32packages
選擇一個(gè)較新的CPU或GPU版本,如jjh_cio_testing/tensorflow-gpu的1.0.1版本,輸入如下命令查詢安裝命令
$ anaconda show jjh_cio_testing/tensorflow-gpuUsing AnacondaAPI:https://api.anaconda.orgName:tensorflow-gpuSummary:Access:publicPackageTypes:condaVersions:+1.0.1To installthispackagewith condarun:conda install --channelhttps://conda.anaconda.org/jjh_cio_testing tensorflow-gpu
使用最后一行的提示命令進(jìn)行安裝
$ conda install --channelhttps://conda.anaconda.org/jjh_cio_testing tensorflow-gpuFetchingpackagemetadata .............Solvingpackagespecifications:.Package planforinstallationinenvironment/home/will/anaconda2:The following packages will be SUPERSEDED by a higher-prioritychannel:tensorflow-gpu:1.0.1-py27_4https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free --> 1.0.1-py27_4 jjh_cio_testingProceed ([y]/n)?
conda會(huì)自動(dòng)檢測(cè)安裝此版本的Tensorflow所依賴的庫(kù),如果你的Anaconda缺少這些依賴庫(kù),會(huì)提示你安裝。因?yàn)槲抑耙呀?jīng)安裝過了,所以這里只提示我安裝Tensorflow。輸入y并回車之后等待安裝結(jié)束即可
可以選擇次高版本的Tensorflow安裝,因?yàn)樽钚掳姹究赡芮迦A TUNA的倉(cāng)庫(kù)鏡像庫(kù)沒有及時(shí)更新,而官方更新連接總是失敗,我最開始選擇了jjhelmus/tensorflow-gpu的1.0.1版本,其他依賴庫(kù)清華 TUNA的倉(cāng)庫(kù)鏡像有資源,而到最后jjhelmus/tensorflow-gpu版本的Tensorflow安裝包總是下載不下來(lái),嘗試20多次之后換了一個(gè)1.0.0的版本,終于順利安裝成功
進(jìn)入python,輸入
import tensorflowastf
如果沒有報(bào)錯(cuò)說明安裝成功。