响应式企业网站后台管理系统,开发一款软件,西安seo经理,福建中兴建设有限公司网站Ubuntu 20.04LTS系统安装CUDA11.8、cuDNN#xff0c;可进行CUDA版本切换 1. 更改为清华源并更新软件列表和依赖项2. 安装CUDA3. 安装cuDNN4. CUDA版本切换 1. 更改为清华源并更新软件列表和依赖项 https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ # 默认注释了源码镜像以提… Ubuntu 20.04LTS系统安装CUDA11.8、cuDNN可进行CUDA版本切换 1. 更改为清华源并更新软件列表和依赖项2. 安装CUDA3. 安装cuDNN4. CUDA版本切换 1. 更改为清华源并更新软件列表和依赖项 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 multiversedeb 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-tools2. 安装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 出现了警告信息对安装无影响
截图日志
wit622622:~/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 rootTo 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 CudaInstaller with the name of this run file:sudo CudaInstaller.run --silent --driverLogfile 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输出下述结果表示安装成功:
wit622622:~/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_03. 安装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指定路径。
wit622622:~/下载$ cd cudnn-linux-x86_64-8.8.1.3_cuda11-archive/
wit622622:~/下载/cudnn-linux-x86_64-8.8.1.3_cuda11-archive$ ls
include lib LICENSEsudo cp include/cudnn*.h /usr/local/cuda-11.8/include
sudo cp lib/libcudnn* /usr/local/cuda-11.8/lib64
sudo chmod ar /usr/local/cuda-11.8/include/cudnn*.h /usr/local/cuda-11.8/lib64/libcudnn*4. 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