安装完CUDA Driver后,就可以安装CUDA了。
因为项目需要,这里安装的CUDA 11.4版本
下载CUDA
访问CUDA Toolkit官网,找到要下载的版本。
![在这里插入图片描述](https://img-blog.csdnimg.cn/3d8ce81e90bc4af4919c62d6c8253a37.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5q2m6a2C5q6_MDAx,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
![在这里插入图片描述](https://img-blog.csdnimg.cn/16068be645d84229896fd3a972a7fcce.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5q2m6a2C5q6_MDAx,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
如果驱动已经安装,不要选驱动
配置CUDA环境
打开用户配置文件:
sudo vi ~/.bashrc
在文件中添加如下语句:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
保存关闭后source文件使配置生效:
source ~/.bashrc
输入命令nvcc -V,如果出现如下信息则说明安装成功:
(base) xxx@xxx:~/NVIDIA_CUDA-11.4_Samples$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Wed_Jun__2_19:15:15_PDT_2021
Cuda compilation tools, release 11.4, V11.4.48
Build cuda_11.4.r11.4/compiler.30033411_0
CUDA Sample测试
切换到CUDA Sample目录,默认在/home/xxx/NVIDIA_CUDA-xxx/下
(base) xxx@xxx:~/NVIDIA_CUDA-11.4_Samples$ ls
0_Simple 1_Utilities 2_Graphics 3_Imaging 4_Finance 5_Simulations 6_Advanced 7_CUDALibraries bin common EULA.txt Makefile
编译差不多5分钟
make
进入bin/x86_64/linux/release文件夹
运行
./deviceQuery
如果出现下图,则说明安装成功:
(base) xxx@xxx:~/NVIDIA_CUDA-11.4_Samples/bin/x86_64/linux/release$ ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "NVIDIA GeForce MX450"
CUDA Driver Version / Runtime Version 11.4 / 11.4
CUDA Capability Major/Minor version number: 7.5
Total amount of global memory: 1878 MBytes (1969684480 bytes)
(014) Multiprocessors, (064) CUDA Cores/MP: 896 CUDA Cores
GPU Max Clock rate: 930 MHz (0.93 GHz)
Memory Clock rate: 5001 Mhz
Memory Bus Width: 64-bit
L2 Cache Size: 524288 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total shared memory per multiprocessor: 65536 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 1024
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 3 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device supports Managed Memory: Yes
Device supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.4, CUDA Runtime Version = 11.4, NumDevs = 1
Result = PASS