??最近老板突然要說做項目姻檀,雙手一揮就申請了張顯卡人断,因此記錄下這篇文檔爬迟;
系統(tǒng)?/?Ubunto16.04
顯卡?/?Nvidia GTX 1070ti
-
NVIDIA顯卡驅(qū)動
-
安裝準備
- 屏蔽nouveau開源驅(qū)動
touch /etc/modprobe.d/blacklist-nouveau.conf echo "blacklist nouveau" >>blacklist-nouveau.conf echo "options nouveau modeset = 0" >>blacklist-nouveau.conf
- 更新前可以去
blacklist-nouveau.conf
查看命令是否添加成功辰狡,之后執(zhí)行更新:
sudo update-initramfs -u
- 去Nvidia官網(wǎng)下載和顯卡對應的驅(qū)動锋叨,我的是GTX1070ti,對應的最新的驅(qū)動是
NVIDIA-Linux-x86_64-390.48.run
-
安裝NVIDIA顯卡驅(qū)動:
- 進入字符界面
Ctrl+alt+F1
之后宛篇,輸入同戶名和密碼娃磺,登陸成功后執(zhí)行:
sudo service lightdm stop
- 安裝:其中
–no-opengl-files
很重要,不然安裝后重啟會出現(xiàn)循環(huán)登錄的問題叫倍。
sudo chmod 777 NVIDIA-Linux-x86_64-390.48.run //執(zhí)行權限 sudo sh NVIDIA-Linux-x86_64-390.48.run –no-opengl-files //執(zhí)行 sudo service lightdm start sudo reboot
- 重啟如果能夠順利登錄偷卧,恭喜,之后測試是否安裝成功:
打印出gpu相關信息表示安裝成功吆倦。nvidia-smi
- 進入字符界面
-
安裝CUDA-8.0
- 安裝依賴:
- 設置源:
將aliyun的源添加到# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
/etc/apt/source.list
中; - 安裝相關依賴庫:
sudo apt-get install freeglut3-dev build-essential libx11-dev sudo apt-get install libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa sudo apt-get install libglu1-mesa-dev ```
- 安裝依賴:
-
安裝:ubunto16系統(tǒng)默認的
gcc-5.4.0
就支持cuda-8.0
听诸,我的cuda-runfile文件是cuda_8.0.61_375.26_linux-run
sudo sh cuda_8.0.44_linux.run --no-opengl-libs
這里沒有安裝opengl,不會出現(xiàn)循環(huán)登錄的bug蚕泽;
- 添加環(huán)境變量
vim ~/.bashrc export PATH=/usr/local/cuda-8.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH sudo vim /etc/profile export CUDA_HOME=/usr/local/cuda-8.0
- 設置動態(tài)鏈接庫
sudo vim /etc/profile
寫入
export PATH = /usr/local/cuda/bin:$PATH
創(chuàng)建
cuda.conf
文件sudo gedit /etc/ld.so.conf.d/cuda.conf
添加以下路徑
/usr/local/cuda/lib64
執(zhí)行鏈接生效
sudo ldconfig sudo reboot
- 測試cuda是否安裝成功
得到以下結果表示安裝成功晌梨。cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery sudo make ./deviceQuery
-
安裝cuDNN-5.1
- Cuda8.0對應的cnDNN版本是5.1,去官網(wǎng)注冊下載须妻;
- 下載之后解壓仔蝌,將cuDNN里的文件copy到CUDA目錄;
sudo cp cudnn.h /usr/local/cuda/include/ sudo cp lib* /usr/local/cuda/lib64/ cd /usr/local/cuda/lib64/ sudo rm -rf libcudnn.so libcudnn.so.5 sudo ln -s libcudnn.so.5.1.5 libcudnn.so.5 sudo ln -s libcudnn.so.5 libcudnn.so
-
安裝python
- 安裝setuptools依賴的zlib庫荒吏;
download:http://www.zlib.net/ ./configure --prefix=/usr/local/zlib/ make make install
添加鏈接敛惊;
//將--prefix目錄添加到zlib.conf中 sudo vim /etc/ld.so.conf.d/zlib.conf ldconfig
- 安裝setuptools;
download:https://pypi.org/project/setuptools/ sudo python setup.py install
- 安裝pip绰更;
sudo python setup.py install
-
安裝tensorflow
pip安裝:
//gpu-python2 sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0-cp27-none-linux_x86_64.whl //cpu-python2 sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp27-none-linux_x86_64.whl //gpu-python3 sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp34-cp34m-linux_x86_64.whl //cpu-python3 sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0-cp34-cp34m-linux_x86_64.whl
-
總結
這樣環(huán)境就搭好了瞧挤,可以愉快的燒GPU啦~
-