MMDetection3D Library Installation Guide
Overview
Cuda, Conda, MMDetection3D installation and test.
1. Prepare
The installation is tested in environment: Ubuntu 20.04, CUDA-11.6, PyTorch v1.13.1.
1.1 Miniconda
The installation is inside a conda virtual envrionment, so be sure Miniconda is installed.
Installation on Linux:
1mkdir -p ~/miniconda3
2wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
3bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
4rm -rf ~/miniconda3/miniconda.sh
And initialization:
1~/miniconda3/bin/conda init bash
2~/miniconda3/bin/conda init zsh
1.2 Remove and Install
CUDA 11.6 and Nvidia driver 510.39.01 are recommended in the guide. The Nvidia driver can be installed along with CUDA.
Remove Cuda
- Check cuda version:
nvcc --version
- Remove cuda:
1sudo apt-get --purge remove "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*"
- or
sudo /usr/local/cuda-11.x/bin/cuda-uninstaller
(replacex
with the version of cuda)
Remove Nvidia Driver
- Check nvidia driver version:
nvidia-smi
- Remove nvidia driver:
sudo /usr/bin/nvidia-uninstall
orsudo apt-get --purge remove "*nvidia*" "libxnvctrl*"
sudo apt-get autoremove
(caution)
Installation
Option 1
Install CUDA 11.6 and driver 510.39.01:
1wget https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda_11.6.0_510.39.01_linux.run
2sudo sh cuda_11.6.0_510.39.01_linux.run
Select the Nvidia driver during CUDA installation in Terminal.
For other versions, check method from Nvidia toolkit website.
Option 2
Open Software & Updates
, click Additional Drivers
, selecet Nvidia driver and click Apply Changes
.
2. Install dependencies
2.1 Create envrionment from file
Download the envrionment.yml file. Create the envrionment by:
1conda env create --file environment.yml
Once created successfully, jump to Section 3.3 to test it.
If otherwise failed, follow Section 2.2 to install it manually.
2.2 Manual installation
Create a virtual environment:
1conda create --name openmmlab python=3.8 -y
2conda activate openmmlab
Install Pytorch v1.13.1:
1conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.6 -c pytorch -c nvidia
- Pytorch and CUDA compatible page: https://pytorch.org/get-started/previous-versions/
Install SpConv:
1pip install spconv-cu116
3. Install MMDetection3D
See more from: https://mmdetection3d.readthedocs.io/en/latest/get_started.html
3.1 Install MM* dependencies
1# Install mim
2pip install -U openmim
3mim install mmengine 'mmcv>=2.0.0rc4,<=2.2.0' 'mmdet>=3.0.0'
3.2 Install MMDetection3D library
Case one: use mmdet3d as a dependency or third-party package:
1# Install mmdet3d (e.g. 1.4.0)
2mim install "mmdet3d>=1.1.0"
Case two: develop and run mmdet3d directly, install it from source:
1git clone https://github.com/open-mmlab/mmdetection3d.git -b dev-1.x
2cd mmdetection3d
3pip install -v -e .
After installation, verify the package location by pip show mmdet3d
.
3.3 Test
To test the result, try to import libraries from it in a Python IDE, for example:
1from mmdet3d.apis import init_model, inference_detector
or
1import mmdet3d
2print(mmdet3d.__version__)