跳至主要內容

GPU 相关

程序员李某某大约 2 分钟

GPU 相关

Nvidia

安装驱动与CUDA

Nvidia Driver 下载open in new window

安装以ubantu 为例

cat > /etc/modprobe.d/blacklist-nouveau.conf <<EOF 
blacklist nouveau 
options nouveau modeset=0 
EOF 
update-initramfs -u 
reboot 
sh ./NVIDIA-Linux-x86_64-550.78.run --silent --uninstall 
sh ./NVIDIA-Linux-x86_64-550.78.run --silent -no-x-check -no-nouveau-check -no
opengl-files --no-cc-version-check --allow-installation-with-running-driver

然后执行nvidia-smi查看最高支持的 CUDA 版本

## CUDA Toolkit 12.3
wget https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda_12.3.0_545.23.06_linux.run
sudo sh cuda_12.3.0_545.23.06_linux.run

## CUDA Toolkit 12.2
wget https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
sudo sh cuda_12.2.2_535.104.05_linux.run

## CUDA Toolkit 12.1.1
wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda_12.1.1_530.30.02_linux.run
sudo sh cuda_12.1.1_530.30.02_linux.run

## CUDA Toolkit 12.0.1
wget https://developer.download.nvidia.com/compute/cuda/12.0.1/local_installers/cuda_12.0.1_525.85.12_linux.run
sudo sh cuda_12.0.1_525.85.12_linux.run

## CUDA Toolkit 11.8
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
sudo sh cuda_11.8.0_520.61.05_linux.run

## CUDA Toolkit 11.7.1
wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run
sudo sh cuda_11.7.1_515.65.01_linux.run

进入界面:

  • 输入accept然后enter

  • 选项按空格只保留cuda toolkit 12.3然后install安装

  • 正常安装完成后linux系统内是没有nvcc命令的,建议通过编辑当前用户的~/.bashrc在最后一行添加下面字段,保存后source ~/.bashrc生效

    export LD\_LIBRARY\_PATH=$LD\_LIBRARY\_PATH:/usr/local/cuda-11.8/lib64  
    export PATH=$PATH:/usr/local/cuda-11.8/bin  
    export CUDA\_HOME=$CUDA\_HOME:/usr/local/cuda-11.8
    

nvidia-smi

图片
图片

GPU测速

## 安装gpu burn
git clone https://github.com/wilicc/gpu-burn
cd gpu-burn/
make
## 测试
./gpu_burn 60

#################################################
100.0%  proc'd: 14280 (7373 Gflop/s) - 13390 (6997 Gflop/s) - 15912 (7110 Gflop/s) - 13184 (7055 Gflop/s) - 13464 (7369 Gflop/s) - 13974 (7351 Gflop/s) - 16626 (7470 Gflop/s
100.0%  proc'd: 14280 (7373 Gflop/s) - 13390 (6997 Gflop/s) - 15912 (7110 Gflop/s) - 13184 (7055 Gflop/s) - 13566 (7102 Gflop/s) - 13974 (7351 Gflop/s) - 16626 (7470 Gflop/s
100.0%  proc'd: 14382 (7224 Gflop/s) - 13390 (6997 Gflop/s) - 15912 (7110 Gflop/s) - 13184 (7055 Gflop/s) - 13566 (7102 Gflop/s) - 13974 (7351 Gflop/s) - 16626 (7470 Gflop/s
100.0%  proc'd: 14382 (7224 Gflop/s) - 13390 (6997 Gflop/s) - 15912 (7110 Gflop/s) - 13184 (7055 Gflop/s) - 13566 (7102 Gflop/s) - 13974 (7351 Gflop/s) - 16728 (7458 Gflop/s
100.0%  proc'd: 14382 (7224 Gflop/s) - 13390 (6997 Gflop/s) - 16014 (6994 Gflop/s) - 13184 (7055 Gflop/s) - 13566 (7102 Gflop/s) - 13974 (7351 Gflop/s) - 16728 (7458 Gflop/s) - 14688 (7569 Gflop/s)   
errors: 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0   temps: 59 C - 69 C - 66 C - 65 C - 67 C - 65 C - 60 C - 63 C 
Killing processes.. Freed memory for dev 7
Uninitted cublas
Freed memory for dev 5
Uninitted cublas
Freed memory for dev 1
Freed memory for dev 4
Uninitted cublas
Uninitted cublas
Freed memory for dev 3
Freed memory for dev 0
Uninitted cublas
Uninitted cublas
Freed memory for dev 6
Uninitted cublas
Freed memory for dev 2
Uninitted cublas
done

Tested 8 GPUs:
        GPU 0: OK
        GPU 1: OK
        GPU 2: OK
        GPU 3: OK
        GPU 4: OK
        GPU 5: OK
        GPU 6: OK
        GPU 7: OK

这样我们就能看到每张gpu的性能了

## 测试单精度
./gpu_burn 60

## 双精度
./gpu_burn -d 60

## tensor core
./gpu_burn -tc 60

## 可用环境变量指定测哪个显卡
export CUDA_VISIBLE_DEVICES=0,1
上次编辑于:
贡献者: 李元昊