Setting Up 3D Open Source OpenPCDet with Anaconda: A Step-by-Step Guide
This article is just like notes for my study and thoughts. Hope this article is useful to you! :)
OpenPCDet is an open-source library for LiDAR-based 3D Object Detection. It was created by the OpenPCDet Development Team, built on top of PyTorch, and intended to be adaptable and effective. It supports a variety of state-of-the-art 3D object detection models and offers an extensible design that allows researchers and developers to develop their custom models.
3D Object Detection is essential in translating point cloud information, a form of spatial information representation fundamental in various domains, including autonomous driving, robotics, and augmented reality (AR). By identifying objects in 3D space, innovations can better understand their environment, empowering more precise navigation, interaction, and decision-making. Within the domain of autonomous driving, a precise 3D bounding box is vital for recognizing obstacles, pedestrians, and other vehicles to ensure the safety and reliability of autonomous navigation systems.
So, in this article, I will explain how to install OpenPCDet using Anaconda. This will make it easy for beginners to use this open-source library and discover its features.
Prerequisites:
- Make sure you have installed the proper version of the NVIDIA driver to be compatible with your GPU and CUDA. I am using Ubuntu 22.04.3 LTS and a GPU of NVIDIA GeForce GTX 1650. (please make sure you install OpenPCDet on Linux because it only works on Linux OS.)
- I am using Python 3.7.16, PyTorch 1.13.1, and CUDA 11.5.
- Make sure you already installed Anaconda in your terminal.
Step 1: Create a new conda environment for OpenPCDet
conda create -n openpcdet python=3.7
conda activate openpcdet
Step 2: check the CUDA version and GPU driver
nvidia-smi
nvcc --version
If you get an error while running this command, install the GPU driver first, CUDA, and also CuDNN, As you can see in the nvcc — version output, I have CUDA version 11.5
Step 3: Install PyTorch
Go to this official website and choose PyTorch the same as our system.
pip3 install torch torchvision torchaudio
Step 4: Install SpConv: Spatially Sparse Convolution Library
install The OpenPCDet asked us to install SpConv, so you can visit the repository and find the version that suits with your CUDA version
I will choose the CUDA 11.6 and install it in my terminal
pip install spconv-cu116
Step 5: Clone the OpenPCDet repository
git clone https://github.com/open-mmlab/OpenPCDet.git
cd OpenPCDet
Step 6: Install the Required Packages
In the openpcdet environment, we will install the required packages listed in the requirements.txt file:
pip install -r requirements.txt
Step 6: Build the OpenPCDet
python setup.py develop
If you successfully build OpenPCDet, the output will look like this:
Using /home/alifya/anaconda3/envs/openpcdet/lib/python3.7/site-packages
Searching for typing-extensions==4.7.1
Best match: typing-extensions 4.7.1
Adding typing-extensions 4.7.1 to easy-install.pth file
Using /home/alifya/anaconda3/envs/openpcdet/lib/python3.7/site-packages
Searching for zipp==3.15.0
Best match: zipp 3.15.0
Adding zipp 3.15.0 to easy-install.pth file
Using /home/alifya/anaconda3/envs/openpcdet/lib/python3.7/site-packages
Finished processing dependencies for pcdet==0.6.0+255db8f
Step 7: Demo (Verify the Installation)
If you want to test whether the installation works or not, you can read the quickstart demo documentation
first, install Open3D or Mayavi for visualization tools:]
pip install open3d
# or
pip install mayavi
prepare the point cloud data but in this article, I use the original KITTI Velodyne data, For a demo, you can download the pre-trained model provided by OpenPCDet here:
cd tools
python demo.py --cfg_file /home/alifya/Alifya/medium/OpenPCDet/tools/cfgs/kitti_models/pointpillar.yaml --ckpt /home/alifya/Alifya/medium/OpenPCDet/pointpillar_7728.pth --data_path /home/alifya/Alifya/medium/OpenPCDet/data/kitti/000006.bin
The result:
Error and Solution (Troubleshooting):
- Some people, I am sure, will get an error like this: “RuntimeError: Error compiling objects for extension.”
So the solution that worked for me is that you can consider downgrading the GCC version. Before that, I used the GCC C++1 11 standard version. For instance, CUDA 10 officially supports up to GCC 8, and CUDA 11 supports up to GCC 9, You can check the official compatibility in NVIDIA’s documentation based on your CUDA version. Run this in your terminal to check the list of available GCC alternatives:
sudo apt list gcc-9
Here is the output from my terminal:
It means that I have gcc-9 available in my repositories, so now I can install it. First, update the package list;
sudo apt update
then install ‘gcc-9’ and ‘g++-9’;
sudo apt install gcc-9 g++-9
then set gcc-9 and g++-9 as the default compilers for this session;
export CC=/usr/bin/gcc-9
export CXX=/usr/bin/g++-9
then, you can reinstall OpenPCDet;
python setup.py develop
2. maybe you got this error like “ModuleNotFoundError: No module named ‘av2’
There are two options for this solution: First, you can just install the package; av2 is the official API of the Argoverse 2 dataset
pip install av2
# or
conda install -c conda-forge av2
But if this solution is not working for you, you can jump into option 2, If you don't use the Argoverse 2 dataset in your project, just comment out OpenPCDet/pcdet/datasets/init. py in line 15 and line 27 as I attached below:
# comment out line 15
from .argo2.argo2_dataset import Argo2Dataset
# comment out line 27
'Argo2Dataset': Argo2Dataset
Thank you for reading my article!
Reference:
- OpenPCDet GitHub Repository: OpenPCDet GitHub