先下载合适版本的gpu驱动及cuda,cudnn
下载地址
- CUDA:https://developer.nvidia.com/cuda-downloads
- cuDNN(需要注册Nvidia账号):https://developer.nvidia.com/cudn
- gpu驱动:https://www.nvidia.cn/Download/index.aspx?lang=cn
注意版本间对应关系,本次使用的是cuda9,cudnn7,显卡k80
安装gpu驱动
关掉图形界面
init 3
驱动安装(也可和cuda一并安装)
kernel-source-path为系统对应内核版本
./NVIDIA-Linux-x86_64-384.183.run --kernel-source-path=/usr/src/kernels/3.10.0-693.5.2.el7.x86_64
之后直接看着选就好
安装cuda
./cuda_9.0.176_384.81_linux.run
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
(y)es/(n)o/(q)uit: yes #是否需要安装gpu驱动,之前没装就选是
Do you want to install the OpenGL libraries?
(y)es/(n)o/(q)uit [ default is yes ]: no #选no
Do you want to run nvidia-xconfig?
This will update the system X configuration file so that the NVIDIA X driver
is used. The pre-existing X configuration file will be backed up.
This option should not be used on systems that require a custom
X configuration, such as systems with multiple GPU vendors.
(y)es/(n)o/(q)uit [ default is no ]: no
Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: yes
Enter Toolkit Location
[ default is /usr/local/cuda-9.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: yes
Install the CUDA 9.0 Samples?
(y)es/(n)o/(q)uit: yes
Enter CUDA Samples Location
[ default is /root ]:
Installing the NVIDIA display driver...
Installing the CUDA Toolkit in /usr/local/cuda-9.0 ...
Missing recommended library: libGLU.so
Missing recommended library: libX11.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so
Missing recommended library: libGL.so
Installing the CUDA Samples in /root ...
Copying samples to /root/NVIDIA_CUDA-9.0_Samples now...
Finished copying samples.
===========
= Summary =
===========
Driver: Installed
Toolkit: Installed in /usr/local/cuda-9.0
Samples: Installed in /root, but missing recommended libraries
Please make sure that
- PATH includes /usr/local/cuda-9.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-9.0/lib64, or, add /usr/local/cuda-9.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-9.0/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.0/doc/pdf for detailed information on setting up CUDA.
Logfile is /tmp/cuda_install_34964.log
Signal caught, cleaning up
vim /etc/profile
末尾添加(对应cuda路径)
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
source /etc/profile
安装cudnn
tar xvf cudnn-9.0-linux-x64-v7.3.1.20.solitairetheme8 -C /home/manager
manager用户下
cd ~
vim .bashrc
最后一行加入
export LD_LIBRARY_PATH=/home/manager/cuda/lib64:$LD_LIBRARY_PATH
source .bashrc
cd cuda/include/
cp *.h /usr/local/cuda/include/
chmod 777 cudnn.h