1 环境
操作系统:ubuntu19.10
显卡:GeForce MX150
2 准备文件
CUDA 版本与显卡无关,但 CUDNN 需要和 CUDA 匹配,
CUDA 下载地址:https://developer.nvidia.com/cuda-toolkit-archive
CUDNN 下载地址:https://developer.nvidia.com/cudnn
本机的 CUDA、CUDNN 型号:
cuda_10.0.130_410.48_linux.run
cudnn-10.0-linux-x64-v7.6.4.38.tgz
3 显卡驱动
ubuntu19.10里已经安装了nvidia显卡驱动,如果没有,自行安装,可以参考这里,这款 GeForce MX150 显卡对应的显卡驱动为NVIDIA-Linux-x86_64-430.50.run
;
查看显卡型号:
nvidia-smi -L
4 安装cuda
进入文件所在目录,执行:
./cuda_10.0.130_410.48_linux.run
这是安装过程中的几个选项(是否安装显卡驱动取决于你是否已经安装了显卡,我们上一步已经安装了,所以这里就不安装):
Do you accept the previously read EULA?
accept/decline/quit: accept
You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: y
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: y
Enter CUDA Samples Location
[ default is /home/tanrui ]:
如果安装过程中出现:
unsupported compiler x.x.x Use --override to override this check 错误类型
需要在安装命令中添加参数--override
:
./cuda_10.0.130_410.48_linux.run --override
如果安装成功,就显示如下:
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-10.0
Samples: Installed in /home/tanrui, but missing recommended libraries
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
5 安装cudnn
解压文件:
tar -xvf cudnn-10.0-linux-x64-v7.6.4.38.tgz
chmod 777 cuda -R
复制到cuda文件夹中:
cp cuda/include/cudnn.h /usr/local/cuda/include/
cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
把下面内容添加至.bashrc:
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
更新 .bashrc:
source .bashrc