跨境派

跨境派

跨境派,专注跨境行业新闻资讯、跨境电商知识分享!

当前位置:首页 > 卖家故事 > ubuntu22安装cuda12.3、cudnn8.9.6及NVIDIA TAO TOOLKIT

ubuntu22安装cuda12.3、cudnn8.9.6及NVIDIA TAO TOOLKIT

时间:2024-04-14 09:35:41 来源:网络cs 作者:付梓 栏目:卖家故事 阅读:

标签: 安装 
阅读本书更多章节>>>>

ubuntu22 1050ti显卡 安装cuda12.3、cudnn8.9.6及NVIDIA TAO TOOLKIT

没有代理的同学,先把你的源改为国内源,清华阿里都可以!
没有代理的同学,先把你的源改为国内源,清华阿里都可以!
没有代理的同学,先把你的源改为国内源,清华阿里都可以!

步骤 1:安装NVIDIA显卡驱动
首先,确保你的系统中已经安装了合适版本的 NVIDIA 驱动程序。可以使用以下命令安装:

sudo ubuntu-drivers autoinstall

步骤 2:安装CUDA
访问NVIDIA官方网站:
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_local
选择正确的操作系统、发行版和架构,然后下载对应版本的CUDA Toolkit,个人选择的是.deb(local)版,然后根据下方方官方给的命令一步步来,比较省事。
安装CUDA Toolkit。可以按照官方文档提供的步骤进行安装,通常包括运行安装脚本。

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pinsudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600wget https://developer.download.nvidia.com/compute/cuda/12.3.1/local_installers/cuda-repo-ubuntu2204-12-3-local_12.3.1-545.23.08-1_amd64.debsudo dpkg -i cuda-repo-ubuntu2204-12-3-local_12.3.1-545.23.08-1_amd64.debsudo cp /var/cuda-repo-ubuntu2204-12-3-local/cuda-*-keyring.gpg /usr/share/keyrings/sudo apt-get updatesudo apt-get -y install cuda-toolkit-12-3

步骤 3:设置环境变量
在 ~/.bashrc 文件中添加以下行,然后执行 source ~/.bashrc:

编辑配置文件sudo vim ~/.bashrc添加以下两行(注意我的cuda版本是12.3,根据自己的版本来):export PATH=/usr/local/cuda-12.3/bin${PATH:+:${PATH}}export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}激活配置环境source ~/.bashrc

步骤 4:检测cuda是否安装完成运行:nvidia-smi
(不知道为啥这里的cuda版本显示是12.2的,安装路线也是显示12.3,电脑ubuntu系统是刚刚装的,不存在之前装过的问题。)
在这里插入图片描述
步骤 5:安装cuDNN
访问NVIDIA官方网站:https://developer.nvidia.com/rdp/cudnn-download
登录或注册一个NVIDIA开发者账号。
下载适用于你的CUDA版本的cuDNN。确保选择正确的版本,然后下载对应的.tar文件。(直接选择linux_x86版本省事)。
解压 cuDNN 文件并将文件复制到相应的目录。

tar -xvf cudnn-linux-x86_64-8.9.6.50_cuda12-archive.tar.xzsudo cp cudnn-*-archive/include/cudnn*.h /usr/local/cuda/include sudo cp -P cudnn-*-archive/lib/libcudnn* /usr/local/cuda/lib64 sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

步骤 6:配置NVIDIA TAO TOOLKIT
再次声明,本人电脑是刚刚重装了ubuntu22 所以不存在之前装过环境导致造成安装失败,如出现安装失败,请检查是否有相关东西没有卸载干净。
官方安装步骤教程地址:
https://docs.nvidia.com/tao/tao-toolkit/text/tao_toolkit_quick_start_guide.html#tao-quick-start-guide
从这里开始慢慢来,再次提醒没有代理的同学,如果你没有设置国内源,你将非常非常非常痛苦!
不过笑容不会消失,只是会转移到我的脸上(●’◡’●)。
在这里插入图片描述
1、Install docker-ce by following the official instructions.
After you have installed docker-ce, follow the post-installation steps to ensure that the Docker can be run without sudo.
这一段呢,是安装Docker Engine,选好自己得系统,我是ubuntu所以选了这个,进入以后还要再选择一次,我选了ubuntu。
在这里插入图片描述
在这里插入图片描述
(1)、 首先保证系统环境是干净的,没有其他版本的残留,如果出现报错,先看看是不是提示没有找到相关路径或者文件,如果是那就不用管,直接下一步;如果不是,那就根据报错描述google一下,我是没有遇到什么问题,可以放评论问问。

sudo apt install gnome-terminalsudo apt remove docker-desktoprm -r $HOME/.docker/desktopsudo rm /usr/local/bin/com.docker.clisudo apt purge docker-desktop

(2)、开始安装一些依赖跟配置。

# Add Docker's official GPG key:# 设置密钥sudo apt-get updatesudo apt-get install ca-certificates curl gnupgsudo install -m 0755 -d /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgsudo chmod a+r /etc/apt/keyrings/docker.gpg# Add the repository to Apt sources:# 添加apt源并更新echo \  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \  sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt-get update

(3)、开始下载docker,注意这里有个分版本的,我是最新版,自己选择;安装后运行hellow docker测试是否安装成功。如果终端输出hello from docker就证明安装成功,后面的其他安装方式不用再看了,再查看版本号,确认环境变量配置争取,保证正常启动。
在这里插入图片描述

 # 安装docker sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin # 运行hello docker测试 sudo docker run hello-world # 启动docker systemctl --user start docker-desktop # 查看版本号 (最后一句前面加sudo,就不会出现permission denied的提示了。) docker compose version docker --version docker version 

在这里插入图片描述
在这里插入图片描述
(4)、Manage Docker as a non-root user 接下来就是修改权限的步骤了,(After you have installed docker-ce, follow the post-installation steps to ensure that the Docker can be run without sudo.)

sudo groupadd dockersudo usermod -aG docker $USERnewgrp dockerdocker run hello-world

官方提醒:If you initially ran Docker CLI commands using sudo before adding your user to the docker group, you may see the following error 如果运行上面指令出现一下报错:

WARNING: Error loading config file: /home/user/.docker/config.json -stat /home/user/.docker/config.json: permission denied

就执行这几句:

 sudo chown "$USER":"$USER" /home/"$USER"/.docker -R sudo chmod g+rwx "$HOME/.docker" -R

(5)、Configure Docker to start on boot with systemd 配置 Docker 以通过 systemd 启动:

 sudo systemctl enable docker.service sudo systemctl enable containerd.service

To stop this behavior, use disable instead. 关闭docker

 sudo systemctl disable docker.service sudo systemctl disable containerd.service

2、Installing the NVIDIA Container Toolkit,开始装NVIDIA Container Toolkit,官方提供了三种安装方式,我采取的是第一种apt安装。
(1)、Configure the repository 配置:

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \  && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list \  && \    sudo apt-get update

(2)、Install the NVIDIA Container Toolkit packages 下载:

sudo apt-get install -y nvidia-container-toolkit

(3)、Configure the container runtime by using the nvidia-ctk command 配置docker并重启:

sudo nvidia-ctk runtime configure --runtime=dockersudo systemctl restart docker

3、Get an NGC account and API key;重点来了,这个很重要,获取NGC密钥,没有这个密钥,训练不了,首先要用邮箱注册账号,点击右上角然后选择 “Sing in/Sing Up” 然后注册,这个不用教了吧,不会的出门左转面壁思过!
(1)、右上角有现实你的账号名称,点击它,选择setup
在这里插入图片描述
(2)、安装CLI,根据自己的操作系统选择,官方提供多种安装方式,我选择用指令(我用的也是最新版)。

# 下载CLIwget --content-disposition https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions/3.33.0/files/ngccli_linux.zip -O ngccli_linux.zip && unzip ngccli_linux.zipfind ngc-cli/ -type f -exec md5sum {} + | LC_ALL=C sort | md5sum -c ngc-cli.md5# Check the binary's SHA256 hash to ensure the file wasn't corrupted during download. Run the following command# 确保你已经下载了zip包,有的话,直接运行就好。sha256sum ngccli_linux.zip# Compare with the following value, which can also be found in the Release Notes of the Resource# 对比一下生成的这密钥是否一样,注意,不是跟我的对比!!!跟你自己生成的对比!!!:“185f6abffe64c94b4db6f0abbee268a57bd4f481ef9252b0676a9f979a257e1e”#After verifying value, make the NGC CLI binary executable and add your current directory to path:# 修改文件权限chmod u+x ngc-cli/ngc$ echo "export PATH=\"\$PATH:$(pwd)/ngc-cli\"" >> ~/.bash_profile && source ~/.bash_profile#这一句可以不用执行,因为你还不知道密钥。ngc config set

(3)、获取密钥,点进去,其他操作在第二张图里面。好了,到此全部安装完毕!在这里插入图片描述在这里插入图片描述

阅读本书更多章节>>>>

本文链接:https://www.kjpai.cn/gushi/2024-04-14/158392.html,文章来源:网络cs,作者:付梓,版权归作者所有,如需转载请注明来源和作者,否则将追究法律责任!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。

文章评论