nvidia 官方文档
nvidia 对不同系统的支持
![v2-73b5f2989cc00c73c5a54b0d82c4370e_b.jpg](http://img-03.proxy.5ce.com/view/image?&type=2&guid=221882ce-a92e-eb11-8da9-e4434bdf6706&url=https://pic3.zhimg.com/v2-73b5f2989cc00c73c5a54b0d82c4370e_b.jpg)
查看是否有支持cuda的GPU:
lspci | grep -i nvidia
如果没有,安装驱动
sudo apt install nvidia-driver-440
查看linux版本是否支持
uname -m && cat /etc/*release
比如我的显示结果如下:
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
...
查看是否安装gcc编译器
在用CUDA Toolkit 进行开发时需要用到gcc编译器,运行CUDA应用并不需要它
gcc --version
验证Kernel Headers 和 Development Packages 是否安装
Ubuntu:
sudo apt-get install linux-headers-$(uname -r)
下载安装 CUDA Toolkit
nvidia官网:cuda toolkit 下载
建议选择Deb 或 RPM文件
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
run DEMO
export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64
${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
cuda-install-samples-10.2.sh ~
cd ~/NVIDIA_CUDA-10.2_Samples/5_Simulations/nbody
make
./nbody