a-ubuntu - nvidia
MENU
CAFFE(一):Ubuntu 下安裝CUDA(安裝:NVIDIA-384+CUDA9.0+cuDNN7.1)
2018-04-07 / VIEWS: 198
(安裝:NVIDIA-384+CUDA9.0+cuDNN7.1)
顯卡(GPU)驅動:NVIDIA-384
CUDA:CUDA9.0
cuDNN:cuDNN7.1
Ubuntu 下安裝CUDA需要裝NVIDIA驅動,首先進入NVIDIA官網,然後查詢對應NVIDIA驅動是否支持你電腦的型號。
這裏我的電腦是:華碩F450J ,自帶的NVIDIA GEFORCE 745。
第一步、安裝NVIDIA GPU驅動
可以看出:GeForce 700M Series (Notebooks):
GeForce GTX 780M, GeForce GTX 770M, GeForce GTX 765M, GeForce GTX 760M, GeForce GT 755M, GeForce GT 750M, GeForce GT 745M, GeForce GT 740M, GeForce GT 735M, GeForce GT 730M, GeForce GT 720M, GeForce GT 710M, GeForce 720M, GeForce 710M, GeForce 705M
GeForce GT 745M為我電腦的型號,所以version:390.48是支持我的NVIDIAGPU驅動的。
所以第二部我們安裝NVIDIA DISPLAY DRIVER version:390.48 執行如下代碼:
第一部分:安裝後續步驟或環境必需的依賴包
1 sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler 2 3 sudo apt-get install --no-install-recommends libboost-all-dev 4 5 sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev 6 7 sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev 8 9 sudo apt-get install git cmake build-essential
輸入以下代碼輸出如下信息則表示依賴環境安裝成功
code:
1 sudo apt-get install git cmake build-essential
顯示:
1 Reading package lists... Done 2 Building dependency tree 3 Reading state information... Done 4 build-essential is already the newest version (12.1ubuntu2). 5 cmake is already the newest version (3.5.1-1ubuntu3). 6 git is already the newest version (1:2.7.4-0ubuntu1.3). 7 0 upgraded, 0 newly installed, 0 to remove and 126 not upgraded.
sudo apt-get update sudo add-apt-repository ppa:graphics-drivers/ppa sudo apt-get update sudo apt-get install nvidia-384 sudo apt-get install mesa-common-dev sudo apt-get install freeglut3-dev
執行結束後,重新啟動系統
sudo reboot #或者sudo shutdown -r now
開機後檢測是否安裝顯示驅動成功
nvidia-settings #或者直接點擊dash開始界面輸入NVIDIA查看
顯示如下信息表示安裝成功
配置環境變量
sudo gedit ~/.bashrc
在.bashrc中加入如下兩行
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
注意:這個地方的提示,要安裝這個CUDA Toolkit 9.1,需要先安裝至少NVIDIA DISPLAY DRIVER R390 版本3.90以上。
下載好CUDA Toolkit9.1後,執行如下代碼進行安裝(此處不需要安裝OPGL),代碼如下:
1 sudo sh cuda_9.0.176_384.81_linux.run --no-opengl-libs #run文檔的文檔名根據自己下的文檔名修改,默認是我提供的文檔
輸出顯示:
1 Do you accept the previously read EULA? 2 accept/decline/quit: accept 3 Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? 4 (y)es/(n)o/(q)uit: n 5 Install the CUDA 9.0 Toolkit? 6 (y)es/(n)o/(q)uit: y 7 Enter Toolkit Location 8 [ default is /usr/local/cuda-9.0 ]: 9 Do you want to install a symbolic link at /usr/local/cuda? 10 (y)es/(n)o/(q)uit: y 11 Install the CUDA 9.0 Samples? 12 (y)es/(n)o/(q)uit: y 13 Enter CUDA Samples Location 14 [ default is /home/pertor ]: 15 Installing the CUDA Toolkit in /usr/local/cuda-9.0 ... 16 Missing recommended library: libXmu.so
添加環境變量:
sudo gedit ~/.bashrc export PATH=/usr/local/cuda-8.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH source ~/.bashrc
驗證CUDA9.0是否安裝成功
cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery sudo make ./deviceQuery
輸出如下信息表示成功安裝
./deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking) Detected 1 CUDA Capable device(s) Device 0: "GeForce GT 740M" CUDA Driver Version / Runtime Version 8.0 / 8.0 CUDA Capability Major/Minor version number: 3.5 Total amount of global memory: 2004 MBytes (2100953088 bytes) ( 2) Multiprocessors, (192) CUDA Cores/MP: 384 CUDA Cores GPU Max Clock rate: 1032 MHz (1.03 GHz) Memory Clock rate: 800 Mhz Memory Bus Width: 64-bit L2 Cache Size: 524288 bytes Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096) Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
cuDNN 的全稱是 The NVIDIA CUDA® Deep Neural Network library,是專門用來對深度學習加速的庫,它支持 Caffe2, MATLAB, Microsoft Cognitive Toolkit, TensorFlow, Theano 及 PyTorch 等深度學習的加速優化,目前最新版本是 cuDNN 7.1,接下來我們來看下它的安裝方式。
下載鏈接:https://developer.nvidia.com/rdp/cudnn-download,需要註冊之後才能打開,這裏我們選擇 cuDNN v7.1.1 (Feb 28, 2018), for CUDA 9.0,然後選擇 cuDNN v7.1.1 Library for Linux,如圖所示:
下載下來之後解壓安裝,執行如下步驟:
1 tar -zxvf cudnn-9.0-linux-x64-v7.1.tgz 2 sudo cp cuda/include/cudnn.h /usr/local/cuda/include/ 3 sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/ -d 4 sudo chmod a+r /usr/local/cuda/include/cudnn.h 5 sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
執行完如上命令之後,cuDNN 就安裝好了,這時我們可以發現在 /usr/local/cuda/include 目錄下就多了 cudnn.h 頭文檔。
終端中執行nvcc -V 顯示如下信息則表示成功
nvcc -V pertor@pertor-computer:~$ nvcc -V nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2017 NVIDIA Corporation Built on Fri_Sep__1_21:08:03_CDT_2017 Cuda compilation tools, release 9.0, V9.0.176
提示:
不建議安裝CUDA 9.1 ,建議安裝CUDA 9.0版本。CUDA 9.1裏面自帶387驅動,但是一般CUDA 9.1自帶的驅動一般很難安裝成功的,所以建議自己去單獨安裝384顯示驅動。並且官網提示CUDA9.1 需要的顯卡驅動必須至少是390以上版本,所以安裝了384顯卡驅動則需要安裝CUDA9.0。
為了保險起見我們應該裝CUDA 9.0和 nvidia-384這個版本。
關鍵詞:cuda 安裝 nvidia sudo geforce cudnn dev install 驅動 usr
相關推薦:
Win10 Anaconda下TensorFlow-GPU環境搭建詳細教程(包含CUDA+cuDNN安裝過程)
CAFFE(四):Ubuntu 下安裝jupyter notebook
CentOS 7 卸載CUDA 9.1 安裝CUDA8.0 並安裝Tensorflow GPU版
ubuntu nvidia卡 下安裝cuda8+cudnn6.0+tensorflow1.4
Ubuntu16.04+cuda9.1+opencv3.4+caffe環境搭建
Read more posts by this author.
China /source/cbb/pertor
Share this post
掃文資訊 © 2017 / runtime 0.067975s / size: 15028published with CoreCMS Alpha v0.1 CN | TW | HK | 技術 / 編程