介紹
CentOS下安裝nvidia+cuda+cudnn
NVIDIA驅(qū)動
去NVIDIA官網(wǎng)下載合適版本驅(qū)動,
-
安裝lspci娩井,使用下面命令逗嫡,找尋lspci,發(fā)現(xiàn)在pciutils中崖瞭,故安裝pciutils
yum whatprovides */lspci yum install pciutils
檢查是否安裝了NVIDIA的GPU(硬件層面):
lspci | grep -i nvidia
-
安裝kernel-devel和kernel-headers
sudo yum install kernel-devel sudo yum install kernel-headers
賦予運行權(quán)限
chmod a+x NVIDIA-Linux-x86_64-410.78.run
-
禁用nouveau
# 打開配置文件: vi /usr/lib/modprobe.d/dist-blacklist.conf # 加上或修改 兩行 blacklist nouveau options nouveau modeset=0 查看nouveau是否禁用, 如果沒有輸出代表成功 lsmod | grep nouveau
-
可選
備份原來的 initramfs nouveau image鏡像 mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img 創(chuàng)建新的 initramfs image鏡像 dracut /boot/initramfs-$(uname -r).img $(uname -r)
-
安裝
運行命令 sudo ./NVIDIA-Linux-x86_64-410.78.run 如果報錯,則使用 sudo ./Nvidia*.sh --kernel-source-path=/usr/src/kernels/按TAB補全
CUDA
去這里選擇合適版本下載
賦予運行權(quán)限
chmod a+x cuda_10.0.130_410.48_linux.run
-
安裝
sudo ./cuda_10.0.130_410.48_linux.run
1. 會先有個閱讀聲明撑毛,一直按D书聚,然后accept。 2. 很多選項 Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 410.48? (y)es/(n)o/(q)uit: n Install the CUDA 10.0 Toolkit? (y)es/(n)o/(q)uit: y Enter Toolkit Location [ default is /usr/local/cuda-10.0 ]: Do you want to install a symbolic link at /usr/local/cuda? (y)es/(n)o/(q)uit: y Install the CUDA 10.0 Samples? (y)es/(n)o/(q)uit: n 選項install the OpenGL libraries,如果雙顯卡(集顯+獨顯)選擇n藻雌,如果只有獨顯可以選擇y雌续,如果雙顯卡選擇y的話,會出現(xiàn)黑屏或者循環(huán)登錄的問題胯杭,如果加了上面的參數(shù)就不會出現(xiàn)這個選項了驯杜。 3. 安裝過程結(jié)束后會有以下信息: =========== = Summary = =========== Driver: Not Selected Toolkit: Installed in /usr/local/cuda-10.0 Samples: Not Selected Please make sure that - PATH includes /usr/local/cuda-10.0/bin - LD_LIBRARY_PATH includes /usr/local/cuda-10.0/lib64, or, add /usr/local/cuda-10.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-10.0/bin Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-10.0/doc/pdf for detailed information on setting up CUDA. ***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 10.0 functionality to work. To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file: sudo <CudaInstaller>.run -silent -driver Logfile is /tmp/cuda_install_11482.log
-
將cuda的bin文件和lib導出到系統(tǒng)環(huán)境中,版本不一樣則更換其中cuda-x.x
export PATH="/usr/local/cuda-10.0/bin:$PATH" export LD_LIBRARY_PATH="/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH" 或者 vi ~/.bashrc export PATH="/usr/local/cuda-10.0/bin:$PATH" export LD_LIBRARY_PATH="/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH" source ~/.bashrc
-
測試:如果下面測試的最后結(jié)果都是Result = PASS做个,說明CUDA安裝成功啦鸽心。
如果成功會輸出版本信息
nvcc –V
-
編譯并測試設(shè)備 deviceQuery:
cd /usr/local/cuda-9.2/samples/1_Utilities/deviceQuery sudo make ./deviceQuery
-
編譯并測試帶寬 bandwidthTest:
cd ../bandwidthTest sudo make ./bandwidthTest
-
其他
所需的libcudart.so.8.0如果正確安裝的話,以下兩種方法同理:sudo ldconfig /usr/local/cuda-8.0/lib64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
- 如果仍然不行居暖,再嘗試執(zhí)行:
export PATH=\$PATH:/usr/local/cuda-8.0/bin export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-8.0/lib64 source /etc/profile
- 此時會顯示
/sbin/ldconfig.real: /usr/local/cuda-8.0/lib64/libcudnn.so.6 不是符號連接
顽频。不用擔心,這時已經(jīng)解決問題了太闺。
安裝cudnn
參考:https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html
去這里下載相應版本
解壓
tar -xzvf cudnn-10.0-linux-x64-v7.tgz
-
復制
cp include/cudnn.h /usr/local/cuda-10.0/include/ cp lib64/libcudnn* /usr/local/cuda-10.0/lib64/
授權(quán)
sudo chmod a+r /usr/local/cuda-10.0/include/cudnn.h /usr/local/cuda-10.0/lib64/libcudnn*