赞
踩
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
步骤一: 下载CUDA安装包
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 <CudaInstaller> with the name of this run file: sudo <CudaInstaller>.run --silent --driver Logfile is /var/log/cuda-installer.log
也可以进入日志进行查看(位置如下):
/var/log/cuda-installer.log
步骤三: 配置CUDA环境
sudo vim ~/.bashrc
export PATH=$PATH:/usr/local/cuda-11.8/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.8/lib64
source ~/.bashrc
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
步骤一:下载cuDNN包
https://developer.nvidia.com/rdp/cudnn-archive
tar -xvf cudnn-linux-x86_64-8.8.1.3_cuda11-archive.tar.xz
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*
因为后续部分项目,用的库对应的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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。