Welcome to this guide on LiDAR-based 3D Object Detection using the OpenPCDet codebase. In this tutorial, we will explore the OpenPCDet framework in detail and demonstrate how to implement an object detection algorithm across three different levels.
We will start from scratch.
System Pre-requistes
Ubuntu 22.04
Nvidia GPU
Python >=3.7 ~ <=3.11
(We have Python 3.10.12 in our system while Python 3.10.15 in virtual environment)
Table of Contents
STEP 1.
we will follow these steps to remove NVIDIA drivers, CUDA, and cuDNN from Ubuntu 22.04 system
a): Update the System
sudo apt update
b): Remove NVIDIA Driver
To remove the NVIDIA driver, use the following commands:
sudo apt-get remove --purge '^nvidia.*'
sudo apt-get autoremove --purge
sudo apt-get autoclean
To remove the CUDA toolkit, first verify its installation path (typically in /usr/local/cuda) and remove the associated files:
sudo apt-get remove --purge '^cuda.*'
sudo apt-get autoremove --purge
sudo rm -rf /usr/local/cuda*
If cuDNN was installed manually, remove it from /usr/local:
sudo rm -rf /usr/local/cuda/include/cudnn*
sudo rm -rf /usr/local/cuda/lib64/libcudnn*
e) Restart the system
sudo reboot
STEP 2.
Install
Nvidia driver 535.216.01 for GeForce RTX 4060
a) UPdate the system
sudo apt update
b) 1. Check for NVIDIA GPU using lspci
lspci | grep -i nvidia
It will show
STEP 1.
we will follow these steps to remove NVIDIA drivers, CUDA, and cuDNN from Ubuntu 22.04 system
a): Update the System
sudo apt update
b): Remove NVIDIA Driver
To remove the NVIDIA driver, use the following commands:
sudo apt-get remove --purge '^nvidia.*'
sudo apt-get autoremove --purge
sudo apt-get autoclean
To remove the CUDA toolkit, first verify its installation path (typically in /usr/local/cuda) and remove the associated files:
sudo apt-get remove --purge '^cuda.*'
sudo apt-get autoremove --purge
sudo rm -rf /usr/local/cuda*
If cuDNN was installed manually, remove it from /usr/local:
sudo rm -rf /usr/local/cuda/include/cudnn*
sudo rm -rf /usr/local/cuda/lib64/libcudnn*
e) Restart the system
sudo reboot
STEP 2:
Install
Nvidia driver 535.216.01 for GeForce RTX 4060
a) UPdate the system
sudo apt update
b) 1. Check for NVIDIA GPU using lspci
lspci | grep -i nvidia
It will show (Change this figurexxxxxx for 4060)
c). Download NVIDIA Driver
Visit https://www.nvidia.com/download/driverResults.aspx/233000/en-us/ to download Nvidia driver 535.216.01
c) Make the .run File Executable
Navigate to the directory where you have downloaded the NVIDIA-Linux-x86_64-535.216.01.run file. If it's in your Downloads folder, for example, use:
cd ~/Downloads
Make the .run file executable:
chmod +x NVIDIA-Linux-x86_64-535.216.01.run
Now, execute the .run file to start the installation process:
sudo ./NVIDIA-Linux-x86_64-535.216.01.run
sudo reboot
f) Check the driver
Nvidia driver 535.216.01 for GeForce RTX 3050
a) UPdate the system
sudo apt update
b) 1. Check for NVIDIA GPU using lspci
lspci | grep -i nvidia
It will show
2. Install Dependencies
Before installing the driver, install necessary dependencies:
sudo apt install build-essential dkms
You can install the NVIDIA driver and CUDA from the official PPA repository. First, add the repository for the latest NVIDIA drivers:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
If you want to install the driver via the package manager, you can try:
sudo apt install nvidia-driver-535
sudo reboot
f) Check the driver
Step 3:
a) Visit
https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=runfile_loca
b) Download runfile( local) nstaller
cd Downloads
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
c) Install CUDA 11.8
sudo sh cuda_11.8.0_520.61.05_linux.run
d) Follow the required instructions in the installer as (Continue, Accept, Deselect the driver because we have already isntalled the driver and Install)
e) Add CUDA binaries to your PATH:
Open new terminal and type
gedit ~/.bashrc
Comment any exiting cuda version in the file and type
export PATH=/usr/local/cuda-11.8/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH
Save and close the file.
Close terminal
f) Verify cuda installation
Open new terminal and type
nvcc --version
Step 4 : CUDNN 9.5.1
a) Visit
https://developer.nvidia.com/cudnn-downloads?target_os=Linux&target_arch=x86_64&Distribution=RHEL&target_version=9&target_type=rpm_local
b) Download deb( local) installer
cd Downloads
wget https://developer.download.nvidia.com/compute/cudnn/9.5.1/local_installers/cudnn-local-repo-ubuntu2204-9.5.1_1.0-1_amd64.deb
sudo dpkg -i cudnn-local-repo-ubuntu2204-9.5.1_1.0-1_amd64.deb
sudo cp /var/cudnn-local-repo-ubuntu2204-9.5.1/cudnn-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cudnn
c) To install for CUDA 11, perform the above configuration but install the CUDA 11 specific package:
sudo apt-get -y install cudnn-cuda-11
d) Verfity that cudnn 9.5.1 has been installed
cat /usr/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
It will show
#define CUDNN_MAJOR 9
#define CUDNN_MINOR 5
#define CUDNN_PATCHLEVEL 1
e) Check if the cuDNN shared library files are present:
ls /usr/lib/x86_64-linux-gnu/libcudnn*
e) Check if the cuDNN shared library files are present:
ls /usr/lib/x86_64-linux-gnu/libcudnn*
STEP 5: CONDA
For this we will use CONDA instead of pip Because
Choosing Conda over pip for installing PyTorch and CUDA-compatible packages has several advantages.
Conda provides a more robust and automated dependency management system, especially when dealing with complex environments and non-Python dependencies.
pip installs Python packages and their dependencies, but it does not automatically handle non-Python dependencies, like CUDA or cuDNN, which are crucial for running PyTorch on GPUs.
pip itself does not provide virtual environment management directly, but it can be used in conjunction with tools like venv or virtualenv to create and manage virtual environments.
Conda, on the other hand, is both a package manager and an environment manager.
pip does not have built-in virtual environment management, but it can be used with external tools (like venv or virtualenv).
Conda provides integrated environment management, making it easier to handle both dependencies and virtual environments.
a) Check if conda is already isntalled
conda --version
In our case, we assume that conda is not already installed, So follow these steps to install conda
a) Install CONDA if not install
aa) Install Miniconda (Recommended)
Miniconda is a lightweight version of Anaconda and is often sufficient for most users.
# Download Miniconda installer
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# Run the installer
bash Miniconda3-latest-Linux-x86_64.sh
# Follow the on-screen prompts
Press 'Enter' key to continue
Press 'q' key to exit the agreement view and takes you directly to the prompt where you can accept it by typing yes or no.
Press 'Enter' key to confirm the location
Type 'no'
After installation, Add Miniconda to Your PATH Permanently
Edit your ~/.bashrc file to include the export PATH command:
gedit ~/.bashrc
############ CONDA (miniconda)
export PATH="$HOME/miniconda3/bin:$PATH"
Save file and close it
Reload the ~/.bashrc File Apply the changes immediately without reopening the terminal:
source ~/.bashrc
Check for conda directory
ls ~/miniconda3
Check conda version to verify its installation
conda --version
In our case it shows conda 24.9.2
Yongin-si, South Korea
sumairamanzoorpk@gmail.com