Skip to content

Setup on WSL (Ubuntu 22.04)

Chiming NI edited this page Jun 19, 2023 · 9 revisions

Note: As our team shifts towards Jetson Orin Nano, we think it's better to use Ubuntu 22.04 as our testing environment. However, most of the parts are identical between different versions of Ubuntu, so the following steps should possibly also work on Ubuntu 18.04 and 20.04.

Install CMake 3.25.3

wget https://github.com/Kitware/CMake/releases/download/v3.25.3/cmake-3.25.3.tar.gz
tar xvf cmake-3.25.3.tar.gz
cd cmake-3.25.3
./bootstrap --parallel=16
make -j16
sudo make install

Install Boost

sudo apt install libboost-all-dev

Install Protocol Buffer

sudo apt install libprotobuf-dev protobuf-compiler

Install ZBar

sudo apt-get install libzbar-dev libzbar0

Install CUDA

To install CUDA 12.1 on Ubuntu 22.04, follow the instructions on NVIDIA's website.

Important Note: CUDA on WSL Ubuntu 22.04 is different from CUDA on Ubuntu 22.04, please notice the difference.

Note: It is advised to use network repo method for WSL installation as it's much simpler than the local repo method.

Example Shell Commands (⚠️may not work on your machine, think before executing):

wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get install cuda-11-8

After installation, add these lines to the end of .zshrc or .bashrc:

export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH=/usr/lib/wsl/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Install cuDNN 8.6.0

To install cuDNN 8.6.0 on Ubuntu 22.04, follow the instructions on NVIDIA's website.

Note: Network repo method doesn't work for cuDNN on WSL. Use local repo method instead.

Assuming you've downloaded cudnn-local-repo-ubuntu2204-8.6.0.163_1.0-1_amd64.deb to the current directory. Example Shell Commands (⚠️may not work on your machine, think before executing):

sudo dpkg -i cudnn-local-repo-ubuntu2204-8.6.0.163_1.0-1_amd64.deb
sudo cp /var/cudnn-local-repo-*/cudnn-local-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get install libcudnn8

Install TensorRT 8.5.3

To install TensorRT 8.5.3 on Ubuntu 22.04, follow the instructions on NVIDIA's website.

Note: Network repo method doesn't work for TensorRT on WSL. Use local repo method instead.

Assuming you've downloaded nv-tensorrt-local-repo-ubuntu2204-8.5.3-cuda-11.8_1.0-1_amd64.deb to the current directory. Example Shell Commands (⚠️may not work on your machine, think before executing):

sudo dpkg -i nv-tensorrt-local-repo-ubuntu2204-8.5.3-cuda-11.8_1.0-1_amd64.deb
sudo cp /var/nv-tensorrt-local-repo-ubuntu2204-8.5.3-cuda-11.8/*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get install tensorrt

Install OpenCV 4.7.0

OpenCV must be built from source on Ubuntu 22.04. To install OpenCV 4.7.0, follow the instructions on OpenCV's website.

Example Shell Commands (⚠️may not work on your machine, think before executing):

# Download and Extract
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip
unzip opencv.zip
# Create build folder
mkdir -p build && cd build
# CMake build
cmake  ../opencv-4.x
# Build with make or ninja
cmake --build .
# Install compiled library
sudo make install
# or
sudo ninja install

Install {fmt}

Note: This section is no longer required since we've introduced CMake Package Manager.

{fmt} is a C++ library that was added to C++20 standard implementation for std::format, but it also works on earlier versions of C++. To install it on your machine, you must build it from source, follow instructions on this page.

Example Shell Commands (⚠️may not work on your machine, think before executing):

# Clone GitHub repository
git clone [email protected]:fmtlib/fmt.git
cd fmt
# Create build folder
mkdir -p build && cd build
# CMake build
cmake  ..
# Build with make or ninja
cmake --build .
# Install compiled library
sudo make install
# or
sudo ninja install

Install spdlog

Note: This section is no longer required since we've introduced CMake Package Manager.

git clone https://github.com/gabime/spdlog.git
cd spdlog && mkdir build && cd build
cmake .. -DSPDLOG_FMT_EXTERNAL=ON && make -j16 
sudo make install

Further Note on MinGW

If you have installed MinGW on Windows, be sure to add the following line to the end of your .bashrc or .zshrc. You should change the path accordingly if you installed MinGW in a different path.

export PATH=${PATH//:\/mnt\/c\/msys64\/mingw64\/bin:/}