方法一: Run file 安装
wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
sudo sh cuda_10.2.89_440.33.01_linux.run
=========================
方法二:Deb 安装
Download Installer for Linux Ubuntu 18.04 x86_64
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub sudo apt-get update sudo apt-get -y install cuda
环境变量
export CUDA_HOME=/usr/local/cuda-10.2
export CUDA_ROOT=/usr/local/cuda-10.2
export PATH=$PATH:$CUDA_HOME/bin:$CUDA_HOME/include:$CUDA_HOME
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH:$CUDA_HOME/include
export CUDA_INC_DIR=$CUDA_INC_DIR:$CUDA_HOME:$CUDA_HOME/include
pip3 install pycuda==2019.1.2 -i https://pypi.tuna.tsinghua.edu.cn/simple #### 不要使用sudo,否则可能会报错
安装cudnn
https://developer.nvidia.com/cudnn
安装TensorRT 7
wget https://developer.download.nvidia.com/compute/cuda/repos/${os}/x86_64/cuda-repo-${os}_${cuda}-1_amd64.deb
sudo dpkg -i nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.0.0.11-ga-20191216_1-1_amd64.deb
sudo apt-key add /var/nv-tensorrt-repo-cuda10.2-trt7.0.0.11-ga-20191216/7fa2af80.pub
sudo apt-get update
sudo apt-get install tensorrt
sudo apt-get install python3-libnvinfer
sudo apt-get install python3-libnvinfer-dev
sudo apt-get install uff-converter-tf
dpkg -l | grep TensorRT
=========================================
CUDA 10.1
# 卸载之前已经安装的cuda $ sudo apt-get remove nvidia-cuda-toolkit $ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin $ sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 $ wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb $ sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb $ sudo apt-key add /var/cuda-repo-10-1-local-10.1.243-418.87.00/7fa2af80.pub $ sudo apt-get update $ sudo apt-get -y install cuda # 部分驱动可能会更新,需要执行更新,否则可能依旧不正常 $ sudo apt-get dist-upgrade $ sudo apt-get autoremove # 可能需要删除一下XWindow的配置文件,否则驱动可能不能正常加载 $ sudo rm -rf ~/.Xauthority # 如果出现如下错误 # ubuntu 18.04 "nvidia-340 导致 /usr/lib/x86_64-linux-gnu/libGL.so.1 # 转移到 /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib" # 参考 http://www.mobibrw.com/?p=21739 # 删除安装源,可以节约几个GB的磁盘,安装完成后这部分已经用不上了 $ sudo apt-get remove --purge cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00
安装对应版本的cuDNN
:
$ wget https://www.mobibrw.com/wp-content/uploads/2019/11/libcudnn7_7.6.5.32-1cuda10.1_amd64.deb_.zip $ wget https://www.mobibrw.com/wp-content/uploads/2019/11/libcudnn7-dev_7.6.5.32-1cuda10.1_amd64.deb_.zip $ wget https://www.mobibrw.com/wp-content/uploads/2019/11/libcudnn7-doc_7.6.5.32-1cuda10.1_amd64.deb_.zip # 解压缩 $ unzip libcudnn7_7.6.5.32-1cuda10.1_amd64.deb_.zip $ unzip libcudnn7-dev_7.6.5.32-1cuda10.1_amd64.deb_.zip $ unzip libcudnn7-doc_7.6.5.32-1cuda10.1_amd64.deb_.zip # 按照顺序安装 $ sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.1_amd64.deb $ sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.1_amd64.deb $ sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.1_amd64.deb
$ cp -r /usr/src/cudnn_samples_v7/ ~/ $ cd ~/cudnn_samples_v7/mnistCUDNN $ make clean && make $ ./mnistCUDNN