一. 安装系统环境
1.1 安装显卡驱动
1. 驱动安装
2. 驱动掉了重新安装
显卡驱动可能因为内核更新而掉,首先重新装好显卡驱动:
sudo sh NVIDIA-……………….run --no-opengl-files --no-x-check --no-nouveau-check
按照上诉教程选择安装
安装好之后锁定内核版本
3. ubuntu内核锁定
1. 查看可用内核
dpkg --list | grep linux-image
dpkg --list | grep linux-headers
dpkg --list | grep linux-modules
2. 锁定内核更新
# apt-mark hold linux-image-5.15.0-92-generic
linux-image-5.15.0-92-generic set on hold.
# apt-mark hold linux-headers-5.15.0-92-generic
linux-headers-5.15.0-92-generic set on hold.
# apt-mark hold linux-modules-extra-5.15.0-92-generic
linux-modules-extra-5.15.0-92-generic set on hold.
3. 重启内核更新
sudo apt-mark unhold linux-image-4.4.0-21-generic
sudo apt-mark unhold linux-image-extra-4.4.0-21-generic
1.2 安装cuda
1. 查看cuda版本
nvcc -V
nvidia-smi可以查看显卡对应可安装的最高cuda版本
可以看出驱动版本是470.199.02 可安装的cuda的最高版本是11.4,显卡的内存是8111MB
2. 安装cuda
Ubuntu 20.04安装CUDA 11.4, cuDNN 8.24 - 知乎
查看cuda与显卡版本对应:CUDA 12.4 Update 1 Release Notes
cuda官网下载:CUDA Toolkit Archive | NVIDIA Developer
显卡驱动和cuda可独立于conda,不需要一定在conda下安装
1.3 安装anaconda
下载anaconda:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
安装:
bash Anaconda.sh
安装过程中注意后的路径,一般为/home/hh/anaconda3
在.bashrc中写入export
export PATH="/home/hh/anaconda3/bin:$PATH"
1.4 布置conda
1. 激活conda
conda activate
2. 创建新的conda环境
conda create -n bevformer python=3.8 -y
3. 查看当前使用的conda源:
conda config --show channels
4. 创建新的环境可能http容易连接超时,换成国内镜像源
(删除 ”- default“(可选))
conda config --remove channels defaults
(添加镜像源,注意是http,而非https,因为https有时候会出现连接错误的问题,改成http后不会再出现此类问题。)
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
(在设置中显示以上镜像源)
conda config --set show_channel_urls yes
(关掉验证,对于http来说,走的是明文传输,不加密的,就不需要验证,其中信息的加密方式为SSL)
conda config --set ssl_verify false
再重复2步骤可以安装成功
二. 安装bevformer环境
要注意pip安装的版本之间要统一
1. nvidia-smi查看显卡驱动和对应的cuda版本
nvcc -V,显示CUDA Version: 11.4
可以安装torch+cu111版本的pytorch这些库
pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
2. 安装好电脑上cuda版本对应的torch之后,再安装mmdetection3d,否则后面跑不起来
3. 安装yapf==0.40.1的版本,0.40.2的版本跑不起来
pip install yapf==0.40.1
4. 安装的numpy的版本不能过低
pip install numpy==1.23.5
5. 安装的mmcv mmdet3d版本要和之前的cuda torch之间一一对应
mmcv 2.1.0
mmcv-full 1.4.0
mmdet 2.14.0
mmdet3d 0.17.2 /home/hh/WorkSpace/MapTR/mmdetection3d
mmdet3d按照maptr中的教程安装即可
6. setuptools包版本过高,需要降低版本
AttributeError: module 'distutils' has no attribute 'version' ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 104780) of binary: /home/hh/anaconda3/envs/maptr/bin/python3
pip install setuptools==59.5.0
7. ubuntu 指定内核启动
sudo vim /etc/default/grub
把GRUB_DEFAULT="0"修改为:
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.15.0-105-generic"
指定内核启动版本,0表示默认用最新的内核启动,内核升级之后,会导致显卡驱动和内核版本之间不匹配
再启动修改的grub:
sudo update-grub
重启电脑之后,就会用选定的内核版本启动电脑
未完待续...