1- 官網(wǎng)下載安裝對應版本cuda文件.deb格式,包括本體和補丁文件
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-cublas-performance-update_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda
- 此時將自動安裝對應n卡驅(qū)動,不用手動安裝
2- cudnn安裝
? ? - 下載對應操作系統(tǒng)版本3個文件扰付,如果你安裝的cuda版本是8.0最好選擇6.0
? ? - 包括runtime library; developer library ; sampels
3- 安裝命令如下:
Install the runtime library, for example:
sudo dpkg -i libcudnn7_7.0.3.11-1+cuda9.0_amd64.deb
Install the developer library, for example:
sudo dpkg -i libcudnn7-dev_7.0.3.11-1+cuda9.0_amd64.deb
Install the code samples and the cuDNN Library User Guide, for example:
sudo dpkg -i libcudnn7-doc_7.0.3.11-1+cuda9.0_amd64.deb
-如果版本安裝錯了脐瑰,請使用dpkg -p libcudnn7 刪除
3- tensorflow安裝
- 準備工作:
- anoconda安裝
? ? - 官網(wǎng)下載anoconda.sh文件,選64bit anoconda2就可以了
? ? - 下載好以后運行
bash ~/Downloads/Anoconda.sh
注意:~/Downloads 是你存放下載文件的目錄运提,根據(jù)你的存放路徑更改
? ? - 注意:Anoconda.sh 是你下載的文件名闻葵,同樣根據(jù)實際文件名做更改
? ? - 運行上述命令后,將詢問你是否要安裝anoconda2路徑到你的計算機槽畔,還有是否安裝microsoft VS都選yes
? ? - 安裝完成后栈妆,可通過
? ? - anaconda-navigator
#測試是否安裝成功
- anoconda pip 替換為國內(nèi)源
- pip 源;推薦豆瓣
- 修改~/.pip/pip.conf,如果沒有就創(chuàng)建
? ? - 內(nèi)容如下:
[global]
index-url = https://pypi.douban.com/simple
?
- 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
- tensorflow安裝
- 創(chuàng)建一個conda虛擬環(huán)境,命名為tensorflow
conda create -n tensorflow pip python=2.7 # or python=3.3, etc.Insert your code here.
- 激活conda環(huán)境
source activate tensorflow
- 安裝tensorflow1.4,筆者安裝的cuda版本為8.0,不支持tensorflow版本太高的環(huán)境
pip install --upgrade tensorflow-gpu==1.4
- 使用以下語句測試tensorflow安裝是否成功
Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))