【Ubuntu 20.04LTS系统】安装CUDA11.8、cuDNN,可进行CUDA版本切换

2,064次阅读
没有评论

Ubuntu 20.04LTS系统安装CUDA11.8、cuDNN,可进行CUDA版本切换

  1. 更改为清华源并更新软件列表和依赖项
  2. 安装CUDA
  3. 安装cuDNN
  4. CUDA版本切换
  5. 更改为清华源并更新软件列表和依赖项
    https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse

deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse

更新软件列表和必要的依赖项

sudo apt-get update # 更新软件列表
sudo apt-get install g++ # 下载g++编译器
sudo apt-get install gcc # 下载gcc编译器
sudo apt-get install make # 下载GNU Make编译器
sudo apt-get install initramfs-tools # 下载安装initramfs-tools

  1. 安装CUDA
    步骤一: 下载CUDA安装包

进行CUDA和cuDNN的选择,也可以直接根据官方推荐进行下载安装。
从Nvidia官网下载CUDA https://developer.nvidia.com/cuda-downloads
下方链接,选择更多版本 https://developer.nvidia.com/cuda-toolkit-archive

接下来根据提示进行下载、安装
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安装包过程中的选择

Do you accept the above EULA? (accept / decline / quit):
是否接受最终用户许可协议,输入accept

回车键进行勾选,X就是选中,没有X就是没有选中,把安装驱动进行取消。之后向下键,回车确认

最后点击 install

出现了警告信息,对安装无影响

截图日志:

wit622@622:~/cuda$ sudo sh cuda_11.8.0_520.61.05_linux.run

[sudo] wit622 的密码:

= Summary =

Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-11.8/

Please make sure that

  • PATH includes /usr/local/cuda-11.8/bin
  • LD_LIBRARY_PATH includes /usr/local/cuda-11.8/lib64, or, add /usr/local/cuda-11.8/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.8/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 520.00 is required for CUDA 11.8 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run file:
sudo .run –silent –driver

Logfile is /var/log/cuda-installer.log

也可以进入日志进行查看(位置如下):

/var/log/cuda-installer.log

步骤三: 配置CUDA环境

sudo vim ~/.bashrc

在bashrc文件最下方,添加下入代码
(ps:这边需要注意cuda的版本,版本不同,路径的命名需修改)
export PATH=$PATH:/usr/local/cuda-11.8/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.8/lib64

更新环境
source ~/.bashrc

测试CUDA是否安装成功
nvcc -V
输出下述结果,表示安装成功:

wit622@622:~/cuda$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

  1. 安装cuDNN
    步骤一:下载cuDNN包
https://developer.nvidia.com/rdp/cudnn-archive

例如这边选择了Download cuDNN v8.8.1 (March 8th, 2023), for CUDA 11.x
点击Local Installer for Linux x86_64 (Tar)即可下载压缩包

将压缩包,放入自定义路径后,输入命令进行解压
tar -xvf cudnn-linux-x86_64-8.8.1.3_cuda11-archive.tar.xz

解压后,输入命令,讲cuDNN对应文件拷贝至CUDA指定路径。
wit622@622:~/下载$ cd cudnn-linux-x86_64-8.8.1.3_cuda11-archive/
wit622@622:~/下载/cudnn-linux-x86_64-8.8.1.3_cuda11-archive$ ls
include lib LICENSE

sudo cp include/cudnn.h /usr/local/cuda-11.8/include sudo cp lib/libcudnn /usr/local/cuda-11.8/lib64
sudo chmod a+r /usr/local/cuda-11.8/include/cudnn.h /usr/local/cuda-11.8/lib64/libcudnn

  1. CUDA版本切换
    因为后续部分项目,用的库对应的CUDA不同,无需进行修改,修改环境CUDA路径即可。例如需要11.1的CUDA,可通过修改bashrc进行修改

sudo vim ~/.bashrc
将原先的cuda-11.8注释掉,添加cuda-11.1新的环境设置,即可

cuda-11.8

export PATH=$PATH:/usr/local/cuda-11.8/bin

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.8/lib64

cuda-11.1

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

正文完
可以使用微信扫码关注公众号(ID:xzluomor)
post-qrcode
 0
评论(没有评论)

文心AIGC

2024 年 4 月
1234567
891011121314
15161718192021
22232425262728
2930  
文心AIGC
文心AIGC
人工智能ChatGPT,AIGC指利用人工智能技术来生成内容,其中包括文字、语音、代码、图像、视频、机器人动作等等。被认为是继PGC、UGC之后的新型内容创作方式。AIGC作为元宇宙的新方向,近几年迭代速度呈现指数级爆发,谷歌、Meta、百度等平台型巨头持续布局
文章搜索
热门文章
潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026

潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026

潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026 Jay 2025-12-22 09...
面向「空天具身智能」,北航团队提出星座规划新基准丨NeurIPS’25

面向「空天具身智能」,北航团队提出星座规划新基准丨NeurIPS’25

面向「空天具身智能」,北航团队提出星座规划新基准丨NeurIPS’25 鹭羽 2025-12-13 22:37...
5天连更5次,可灵AI年末“狂飙式”升级

5天连更5次,可灵AI年末“狂飙式”升级

5天连更5次,可灵AI年末“狂飙式”升级 思邈 2025-12-10 14:28:37 来源:量子位 让更大规...
钉钉又发新版本!把 AI 搬进每一次对话和会议

钉钉又发新版本!把 AI 搬进每一次对话和会议

钉钉又发新版本!把 AI 搬进每一次对话和会议 梦晨 2025-12-11 15:33:51 来源:量子位 A...
商汤Seko2.0重磅发布,合作短剧登顶抖音AI短剧榜No.1

商汤Seko2.0重磅发布,合作短剧登顶抖音AI短剧榜No.1

商汤Seko2.0重磅发布,合作短剧登顶抖音AI短剧榜No.1 十三 2025-12-15 14:13:14 ...
最新评论
ufabet ufabet มีเกมให้เลือกเล่นมากมาย: เกมเดิมพันหลากหลาย ครบทุกค่ายดัง
tornado crypto mixer tornado crypto mixer Discover the power of privacy with TornadoCash! Learn how this decentralized mixer ensures your transactions remain confidential.
ดูบอลสด ดูบอลสด Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
Obrazy Sztuka Nowoczesna Obrazy Sztuka Nowoczesna Thank you for this wonderful contribution to the topic. Your ability to explain complex ideas simply is admirable.
ufabet ufabet Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
ufabet ufabet You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
ufabet ufabet Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
热评文章
读懂2025中国AI走向!公司×产品×人物×方案,最值得关注的都在这里了

读懂2025中国AI走向!公司×产品×人物×方案,最值得关注的都在这里了

读懂2025中国AI走向!公司×产品×人物×方案,最值得关注的都在这里了 衡宇 2025-12-10 12:3...
5天连更5次,可灵AI年末“狂飙式”升级

5天连更5次,可灵AI年末“狂飙式”升级

5天连更5次,可灵AI年末“狂飙式”升级 思邈 2025-12-10 14:28:37 来源:量子位 让更大规...
戴尔 x OpenCSG,推出⾯向智能初创企业的⼀体化 IT 基础架构解决方案

戴尔 x OpenCSG,推出⾯向智能初创企业的⼀体化 IT 基础架构解决方案

戴尔 x OpenCSG,推出⾯向智能初创企业的⼀体化 IT 基础架构解决方案 十三 2025-12-10 1...
九章云极独揽量子位三项大奖:以“一度算力”重构AI基础设施云格局

九章云极独揽量子位三项大奖:以“一度算力”重构AI基础设施云格局

九章云极独揽量子位三项大奖:以“一度算力”重构AI基础设施云格局 量子位的朋友们 2025-12-10 18:...
乐奇Rokid这一年,一路狂飙不回头

乐奇Rokid这一年,一路狂飙不回头

乐奇Rokid这一年,一路狂飙不回头 梦瑶 2025-12-10 20:41:15 来源:量子位 梦瑶 发自 ...