1、ubuntu-drivers devices
查看最新驱动
一定要查看以下因为比如比较老的显卡如1050,如果不安装最新驱动是无法正常安装比较新的CUDA
1050默认CUDA9.1,直接安装CUDA10会失败
2、sudo ubuntu-drivers autoinstall
2019.11.11安装的是最新的435.21,可以安装CUDA10
3、https://developer.nvidia.com/cuda-10.0-download-archive
sudo sh cuda_10.0.130_410.48_linux.run
自带410驱动,选择n,其他y
会提示:
***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 with the name of this run file:
sudo .run -silent -driver
没有选择安装驱动,忽略就行。
Vim ~/.bashrc
e进入编辑
按“insert”键
在末尾加入
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}}
:wq
保存退出
source ~/.bashrc
关闭终端,在打开一个新的终端
nvidia-smi
nvcc -V
都正确显示信息,成功
4、安装pytorch:注意网络连接速度
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch