100% successful deployment of BEVFormer on Ubuntu 18.04/20.04 Server

Deploy BEVFormer on Ubuntu 18.04/22.04


Author: Yihang Tao

This is a 100% successful instruction for deploying BEVFormer/ActFormer on Ubuntu 18.04/22.04.

Introduction

For those who wanna do experiments with BEVFormer and are still struggling to configure the environment on Ubuntu 18.04/20.04, congratulate you finally find the right place! There may be some strange reasons leading to the failure in running BEVFormer, however, you will make it after following the instructions below.

The key points are highlighted here:

  • Please ensure the running cuda version is 11.3
  • Please ensure the gcc version is higher than 4.0 but lower than 8.0
  • Please use mmcv-full higher than 1.3 but lower than 1.4

Steps

1. Create virtual environment

1
2
conda create -n open-mmlab python=3.8 -y  
conda activate open-mmlab

2. Install GPU-version Pytorch

Method 1:

1
pip install torch==1.10.0+cu113 torchvision==0.11.0+cu113 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html

Method 2:

1
conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cudatoolkit=11.3 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/

3. Install mmcv-full, mmdet, and mmsegmentation

1
2
pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html
pip install mmdet==2.14.0 mmsegmentation==0.14.1

4. Install Dependency

1
2
3
pip install ninja tensorboard==2.13.0 nuscenes-devkit==1.1.10 scikit-image==0.19.0 lyft-dataset-sdk==0.0.8
pip install numpy==1.19.5 pandas==1.4.4 llvmlite==0.31.0 setuptools==59.5.0 yapf==0.40.0
conda install -c omgarcia gcc-6 # gcc-6.2

5. Set CUDA Path (Important)

Exit current environment

1
conda deactivate

Download and intall CUDA 11.3 (assume you are not root user)

1
2
wget https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda_11.3.0_465.19.01_linux.run
sh cuda_11.3.0_465.19.01_linux.run

Wait until interface appears (ignore the wrong version below, yours should be 11.3)

Accept and continue

Cancel the first option (press enter), and select options, modify the cuda installation path to yours, otherwise you don’t have enough permission

Set CUDA path

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Switch CUDA version when activate open-mmlab
mkdir -p /home/[username]/anaconda3/envs/open-mmlab/etc/conda/activate.d
vim /home/[username]/anaconda3/envs/open-mmlab/etc/conda/activate.d/activate.sh

# Insert following content
ORIGINAL_CUDA_HOME=$CUDA_HOME
ORIGINAL_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
export CUDA_HOME=[your installed cuda path]/cuda-11.3
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
export PATH=$CUDA_HOME/bin:$PATH

# Recover CUDA version when deactivate open-mmlab
mkdir -p /home/[username]/anaconda3/envs/open-mmlab/etc/conda/deactivate.d
vim /home/[username]/anaconda3/envs/open-mmlab/etc/conda/deactivate.d/deactivate.sh

# Insert following content
export CUDA_HOME=$ORIGINAL_CUDA_HOME
export LD_LIBRARY_PATH=$ORIGINAL_LD_LIBRARY_PATH
unset ORIGINAL_CUDA_HOME
unset ORIGINAL_LD_LIBRARY_PATH
export PATH=$CUDA_HOME/bin:$PATH

Enter virtual enironment and check CUDA version

1
2
3
conda activate open-mmlab
nvcc -V
# Now you should see CUDA version is 11.3

6. Install mmdet3d

1
2
3
4
5
cd BEVFormer
git clone https://github.com/open-mmlab/mmdetection3d.git
cd mmdetection3d
git checkout v0.17.1
pip install -v -e .

7. Install Detectron2, Timm

1
2
pip install einops fvcore seaborn iopath==0.1.9 timm==0.6.13  typing-extensions==4.5.0 pylint ipython==8.12 numba==0.48.0 scikit-image==0.19.3 yapf==0.40.1
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'

Now everything should be fine! :-)

Reference

[1] https://blog.csdn.net/newbie_dqt/article/details/134766294
[2] https://blog.csdn.net/weixin_45944960/article/details/130000445
[3] https://blog.csdn.net/Mr__George/article/details/106984574
[4] https://blog.csdn.net/qq_40677266/article/details/121322583


100% successful deployment of BEVFormer on Ubuntu 18.04/20.04 Server
http://yihangtao.github.io/blog/2024/08/09/bevformer/
Author
Yihang Tao
Posted on
August 9, 2024
Licensed under