运行环境:
ubuntu18.04 melodic
宏基暗影骑士笔记本
适用:
ubuntu18.04 / ubuntu20.04
思路:
3060显卡+CUDA11.1+cudnn8.1.0+pytorch1.8.0+pycharm2021+Anaconda+vscode
1.1 3060显卡驱动自动安装
1)换清华源
2)安装nvidia-driver-470-server
3)重启电脑
4)nvidia-smi (检查已显卡驱动版本)
CUDA Version: 11.4 (显卡驱动API 11.4)
2.1 CUDA11.1.1
CUDA下载地址:https://developer.nvidia.com/cuda-toolkit-archive
1)下载CUDA Toolkit 11.1 Update 1 Downloads
(运行API,小于等于上面显卡驱动API 11.4就可以)
复制到浏览器下载, 不需要墙(30分钟)
https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
cd 到下载路径
sudo sh cuda_11.1.1_455.32.00_linux.run
2)contunue , 然后accept
3)回车取消Driver安装,然后install
4)添加环境变量
gedit ~/.bashrc
在文件结尾添加如下语句:(修改成自己的路径)
export PATH="/usr/local/cuda-11.1/bin:$PATH"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.1/lib64
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-11.1/lib
source ~/.bashrc
nvcc -V
只要驱动API高于运行时API就没关系
nvidia-smi显示的是驱动API,nvcc -V显示的是运行时API
5)确认是否安装成功
进入deviceQuery/目录
cd usr/local/cuda-11.1/samples/1_Utilities/deviceQuery/
sudo make
执行检查版本
./deviceQuery
3.1 cudnn 8.1.0
https://developer.nvidia.com/rdp/cudnn-archive
密码:首位设置是大写
1)下载版本
Download cuDNN v8.1.0 (January 26th, 2021), for CUDA 11.0,11.1 and 11.2
2)解压
tar -xvzf cudnn-11.4-linux-x64-v8.2.2.26.tgz
sudo nautilus
打开超级复制,复制include和lib64文件夹内容复制到cuda11.1对应文件夹中
3)添加环境变量
参考网址
gedit ~/.bashrc
export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
source ~/.bashrc
4)查看cudnn版本
ls /usr/local/cuda/include/cudnn.h
如果输出 No such file or directory,则cuDNN头文件未安装或者安装位置不正确,
如果输出 /usr/local/cuda/include/cudnn.h,则cuDNN头文件已经安装成功。
ls /usr/local/cuda/lib64/libcudnn*
4.1 pycharm2021.3
1)社区版(免费)
https://www.jetbrains.com/pycharm/download/other.html
2)安装并创建pycharm图标
cd /home/duduzai/pycharm2021/bin
bash pycharm.sh
cd /usr/share/applications
sudo gedit pycharm.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=Pycharm
Icon=/home/duduzai/pycharm2021/bin/pycharm.png
Exec=sh /home/duduzai/pycharm2021/bin/pycharm.sh
MimeType=application/x-py;
Name[en_US]=pycharm
5.1 Anaconda 5.3.0(python3.7.0)
1)下载
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
下载Anaconda3-5.3.0-Linux-x86_64.sh
2)安装
bash Anaconda3-2023.03-Linux-x86_64.sh
一直按回车 或 输入yes再回车(自动添加环境变量)
ROS自带的3.6.9被替换成anaconda自带的3.7.0
gedit ~/.bashrc
如果导致ROS包编译错误,建议注释掉,再重新编译ROS包(如相机雷达标定包)
source ~/.bashrc
# 注释后激活conda方式:
source ~/anaconda3/bin/activate
conda activate openmmlab
# added by Anaconda3 5.3.0 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/home/duduzai/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/home/duduzai/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/duduzai/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/home/duduzai/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
5.2 Anaconda 环境创建
1)创建名为 lidar_camera 的环境
conda create --name lidar_camera python=3.8
2)激活环境
conda activate lidar_camera
3)显示环境的安装包
conda list
4)查看所有环境
conda env list
6.1 pytorch1.8
https://pytorch.org/get-started/previous-versions/
conda activate lidar_camera
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
7.1 Anaconda和vscode联合使用
1)安装vscode环境
2)设置conda路径
查看conda环境路径
文章来源:https://www.toymoban.com/news/detail-435535.html
文章来源地址https://www.toymoban.com/news/detail-435535.html
/home/duduzai/anaconda3/envs/lidar_camera/bin/python
到了这里,关于ubuntu 3060显卡驱动+cuda+cudnn+pytorch+pycharm+vscode的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!