CentOS8下安装CUDA 10.2

空扰寡人 提交于 2020-01-10 13:28:44

第一步:先安装好nvidia驱动

 

第二步:打开终端,输入命令:nvcc --version,查看是否安装了cuda

运行命令:nvidia-smi

可以看到CUDA Version:10.2

 

第三步:入官网下载cuda10.2版本,按下面选好后,会给出安装命令

 

 

wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-rhel8-10-2-local-10.2.89-440.33.01-1.0-1.x86_64.rpm
sudo rpm -i cuda-repo-rhel8-10-2-local-10.2.89-440.33.01-1.0-1.x86_64.rpm
sudo dnf clean all
sudo dnf -y module install nvidia-driver:latest-dkms
sudo dnf -y install cuda

 

第四步:打开~/.bashrc,加入配置信息
[root@localhost ~]# vi ~/.bashrc

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

更新~/.bashrc

[root@localhost ~]# source ~/.bashrc

重启后

 

第五步:确认CUDA正确安装,运行命令

$ nvcc --version
$ nvidia-smi


[root@localhost ~]# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89

[root@localhost ~]# nvidia-smi
Fri Jan 10 12:45:36 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01 Driver Version: 440.33.01 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 650 Off | 00000000:02:00.0 N/A | N/A |
| 21% 24C P8 N/A / N/A | 79MiB / 979MiB | N/A Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 Not Supported |
+-----------------------------------------------------------------------------+

第六步:测试CUDA程序

# mkdir cuda-samples

# cuda-install-samples-10.2.sh cuda-samples/

# cd ./cuda-samples/NVIDIA_CUDA-10.2_Samples/0_Simple/clock/

# make

 

[root@localhost ~]# mkdir cuda-samples
[root@localhost ~]# cuda-install-samples-10.2.sh cuda-samples/
Copying samples to cuda-samples/NVIDIA_CUDA-10.2_Samples now...
Finished copying samples.

[root@localhost ~]# cd ./cuda-samples/NVIDIA_CUDA-10.2_Samples/0_Simple/clock/
[root@localhost clock]# make

/usr/local/cuda-10.2/bin/nvcc -ccbin g++ -I../../common/inc -m64 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o clock.o -c clock.cu
/usr/local/cuda-10.2/bin/nvcc -ccbin g++ -m64 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o clock clock.o
mkdir -p ../../bin/x86_64/linux/release
cp clock ../../bin/x86_64/linux/release

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!