Ubuntu 16.04安裝GPU(GTX1080 Ti)

一、安裝ubuntu 16.04

1.ISOUltra 製作啓動盤

2.安裝ubuntu 16.04系統

3.用VPN上網

https://jingyan.baidu.com/article/ca41422fecac111eae99eddf.html

Linux Ubuntu系統中設置VPN完整教程

4.安裝JDK(配置環境變量)

 

 

二、安裝NVIDIA顯卡

1.輸入命令 init 3進入文本模式

2.切換到tty1控制檯:Ctrl+Alt+F1

3.關閉X-Windowsudoservice lightdm stop

4.開始安裝:sudo ./NVIDIA.run

5.重新啓動X-Windowsudoservice lightdm start(不行的話,按Ctrl+Alt+F7進入圖形界面)

6.安裝後驅動程序工作不正常,使用下面的命令進行卸載:sudo sh~/NVIDIA-Linux-x86_64-367.44.run --uninstall

7.驗證安裝成功nvidia-smi 或者nvidia-settings




三、安裝CUDA 8.0

1.gcc 從5.X 降到 4.9 (ubuntu12.04 默認的gcc版本都是5.x 以上的,但CUDA8.0不支持)

sudo add-apt-repositoryppa:ubuntu-toolchain-r/test
sudo apt-get update

apt-get install gcc-4.9 g++-4.9

 

we can fixit with simple symbolic

cd /usr/bin
rm gcc g++ cpp
ln -s gcc-4.9 gcc
ln -s g++-4.9 g++
ln -s cpp-4.9 cpp

https://askubuntu.com/questions/428198/getting-installing-gcc-g-4-9-on-ubuntu

 

 

2.開始安裝CUDA

sudo sh cuda_8.0.27_linux.run

 

報錯:缺少包

Installingthe CUDA Toolkit in /usr/local/cuda-8.0 … 

Missingrecommended library: libGLU.so 

Missingrecommended library: libX11.so 

Missingrecommended library: libXi.so 

Missingrecommended library: libXmu.so

 

原因是缺少相關的依賴庫,安裝相應庫就解決了:

sudoapt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-devlibgl1-mesa-glx libglu1-mesa libglu1-mesa-dev

再次安裝,就不再提示了

sudo sh cuda_8.0.27_linux.run

 

 

 

注意:提示安裝驅動時候,一定要點 NO!NO!NO!

 

===========

Do you accept the previously read EULA? 

accept/decline/quit: accept

Install NVIDIAAccelerated Graphics Driver for Linux-x86_64 375.26? 

(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Toolkit? 

(y)es/(n)o/(q)uit: y

Enter Toolkit Location 

[ default is /usr/local/cuda-8.0 ]:

Do you want to install a symbolic link at /usr/local/cuda? 

(y)es/(n)o/(q)uit: y

Install the CUDA 8.0 Samples? 

(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location 

[ default is /home/guyadong ]:

Installing the CUDA Toolkit in /usr/local/cuda-8.0 … 

Installing the CUDA Samples in /home/guyadong … 

Copying samples to /home/guyadong/NVIDIA_CUDA-8.0_Samplesnow… 

Finished copying samples.

===========

 

 

3.安裝成功,環境變量配置

=Summary =

Driver: Not Selected 

Toolkit: Installed in /usr/local/cuda-8.0 

Samples: Installed in /home/guyadong 

Please make sure that 

- PATH includes /usr/local/cuda-8.0/bin 

- LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add/usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in/usr/local/cuda-8.0/bin

Please see CUDA_Installation_Guide_Linux.pdf in/usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.

***WARNING: Incomplete installation! This installation did notinstall the CUDA Driver. A driver of version at least 361.00 is required forCUDA 8.0 functionality to work. 

To install the driver using this installer, run the followingcommand, replacing with the name of this run file: 

sudo .run -silent -driver

Logfile is /tmp/cuda_install_13101.log 

Signal caught, cleaning up

 

 

 

我們在terminal中鍵入下列命令:

sudo gedit~/.bash_profile # 打開.bash_profile 這是用戶的環境變量,不是全局的

然後在打開的文本末尾加入:

export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=
/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

保存並關閉後,輸入下列命令使環境變量生效:

source~/.bash_profile # 使被更改的環境變量生效

 

 

 

然後設置環境變量和動態鏈接庫,在命令行輸入:

 $ sudo gedit /etc/profile

 在打開的文件末尾加入:

 export PATH = /usr/local/cuda/bin:$PATH

 保存之後,創建鏈接文件:

 sudo gedit /etc/ld.so.conf.d/cuda.conf

在打開的文件中添加如下語句:

 /usr/local/cuda/lib64 1 1

然後執行

 sudo ldconfig  (使鏈接立即生效)

 

 

 

 

4.測試安裝成功

cd/usr/local/cuda-8.0/samples/1_Utilities/deviceQuery

進入NVIDIA_CUDA-8.0_Samples目錄,執行:make

sudo./deviceQuery

 

 

 

執行:$ nvcc-V,結果如下:

 

 

 

四、安裝cudnn 5.1

1、下載後解壓

tar -zxvf ~/Download/cudnn.gz

2.進入解壓後的cudnn的cuda目錄

sudo cp cudnn.h /usr/local/cuda/include/   #複製頭文件

sudo chmod a+r/usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*  #賦權限

 

 再將cd進入lib64目錄下的動態文件進行復制和鏈接:

 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.0.5libcudnn.so.5 #生成軟銜接

 sudo ln -s libcudnn.so.5libcudnn.so #生成軟銜接

 

後面IDE出現錯誤:libcudnn.so.6.5:cannot open shared object file:Nosuche file or directory

解決: sudoldconfig -v  (使鏈接立即生效)

 

 

 

 

五、安裝Pycharm和anaconda(python)

1.Pycharm

解壓後進入bin目錄,運行./pycharm.sh 即可

2.anaconda 安裝

bashanaconda.sh

中間有一步問是否添加環境變量,回答 YES!YES!YES!

source ~/.bashrc  #更新環境變量

 

 

六、安裝tensorflow_gpu和keras

1.從清華大學鏡像軟件站下載

 https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/

2.pip 安裝 keras

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章