type
status
date
slug
summary
tags
category
icon
password
在深度学习领域,高效地利用GPU资源是至关重要的。为此,NVIDIA开发了几个关键的库,如CUDA、cuDNN和TensorRT,以优化和加速深度学习模型的训练和推理过程。本文旨在记录自己在Ubuntu 20.04操作系统上配置这些工具,以后需要在其他设备上配置 便于翻阅。

NVIDIA Driver

  • 使用CUDA前,要求GPU驱动与cuda 的版本要匹配,匹配关系如下:
notion image
  • 检查自己机器建议的驱动`ubuntu-drivers devices`
notion image
上面信息提示了,当前我使用的GPU是[GeForce GTX 3090 24GB],他推荐的(recommended)驱动是nvidia-driver-550-open
  • 安装指定版本`sudo apt install nvidia-driver-550-open`
  • 重启 `sudo reboot`
  • 检查安装 nvidia-smi
    • 我手动安装驱动(版本 550),但是在安装 CUDA 12.0 时可能 驱动自动降级了。
    • notion image

CUDA

CUDA是一个由NVIDIA开发的平行计算平台和编程模型。
  • GeForce GTX 3090 只能安装cuda11以上版本
notion image
根据nvidia-smi提示,我可以最高安装12.0,我选择的12.0 版本的
notion image
我选择的deb(local)
  • 测试nvcc nvcc —version

cuDNN

cuDNN是NVIDIA提供的深度神经网络加速库。
notion image
我现在的是Download cuDNN v8.8.1 (March 8th, 2023), for CUDA 12.x 对应我的cuba版本
  • 下载后安装
  • 验证cuDNN
notion image
./mnistCUDNN 执行后有Test passed!说明cuDNN安装完成
 

TensorRT

TensorRT是一个用于高性能深度学习推理的SDK。
notion image
比如我选择的是 8.6.1版本,下载完文件名为:nv-tensorrt-local-repo-ubuntu2004-8.6.1-cuda-12.0_1.0-1_amd64.deb
  • 安装
  • 验证
dpkg -l | grep TensorRT
 
notion image
自此 Ubuntu20.04配置CUDA、CUDnn、TensorRT 完毕!

结论

在Ubuntu 20.04上安装和配置CUDA、cuDNN和TensorRT可能看起来有些复杂,但遵循上述步骤可以相对顺利地完成。
 
安装Nerd字体深度学习Conda包管理环境与pdb调试