Build for Jetson

In this chapter, we introduce how to install MMDeploy on NVIDIA Jetson platforms, which we have verified on the following modules:

  • Jetson Nano

  • Jetson TX2

  • Jetson AGX Xavier

Hardware recommendation:


  • To equip a Jetson device, JetPack SDK is a must.

  • The Model Converter of MMDeploy requires an environment with PyTorch for converting PyTorch models to ONNX models.

  • Regarding the toolchain, CMake and GCC has to be upgraded to no less than 3.14 and 7.0 respectively.

JetPack SDK

JetPack SDK provides a full development environment for hardware-accelerated AI-at-the-edge development. All Jetson modules and developer kits are supported by JetPack SDK.

There are two major installation methods including,

  1. SD Card Image Method

  2. NVIDIA SDK Manager Method

You can find a very detailed installation guide from NVIDIA official website.


Please select the option to install “Jetson SDK Components” when using NVIDIA SDK Manager as this includes CUDA and TensorRT which are needed for this guide.

Here we have chosen JetPack 4.6.1 as our best practice on setting up Jetson platforms. MMDeploy has been tested on JetPack 4.6 (rev.3) and above and TensorRT and above. Earlier JetPack versions has incompatibilities with TensorRT 7.x


Install Archiconda instead of Anaconda because the latter does not provide the wheel built for Jetson.

bash -b

echo -e '\n# set environment variable for conda' >> ~/.bashrc
echo ". ~/archiconda3/etc/profile.d/" >> ~/.bashrc
echo 'export PATH=$PATH:~/archiconda3/bin' >> ~/.bashrc

echo -e '\n# set environment variable for pip' >> ~/.bashrc
echo 'export OPENBLAS_CORETYPE=ARMV8' >> ~/.bashrc

source ~/.bashrc
conda --version

After the installation, create a conda environment and activate it.

# get the version of python3 installed by default
export PYTHON_VERSION=`python3 --version | cut -d' ' -f 2 | cut -d'.' -f1,2`
conda create -y -n mmdeploy python=${PYTHON_VERSION}
conda activate mmdeploy


JetPack SDK 4+ provides Python 3.6. We strongly recommend using the default Python. Trying to upgrade it will probably ruin the JetPack environment.

If a higher-version of Python is necessary, you can install JetPack 5+, in which the Python version is 3.8.


Download the PyTorch wheel for Jetson from here and save it to the /home/username directory. Build torchvision from source as there is no prebuilt torchvision for Jetson platforms.

Take torch 1.10.0 and torchvision 0.11.1 for example. You can install them as below:

# pytorch
wget -O torch-1.10.0-cp36-cp36m-linux_aarch64.whl
pip3 install torch-1.10.0-cp36-cp36m-linux_aarch64.whl

# torchvision
sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev libopenblas-base libopenmpi-dev  libopenblas-dev -y
git clone --branch v0.11.1 torchvision
cd torchvision
export BUILD_VERSION=0.11.1
pip install -e .


It takes about 30 minutes to install torchvision on a Jetson Nano. So, please be patient until the installation is complete.

If you install other versions of PyTorch and torchvision, make sure the versions are compatible. Refer to the compatibility chart listed here.


We use the latest cmake v3.23.1 released in April 2022.

# purge existing
sudo apt-get purge cmake -y

# install prebuilt binary
export CMAKE_VER=3.23.1
export ARCH=aarch64
chmod +x cmake-${CMAKE_VER}-linux-${ARCH}.sh
sudo ./cmake-${CMAKE_VER}-linux-${ARCH}.sh --prefix=/usr --skip-license
cmake --version

Install Dependencies

The Model Converter of MMDeploy on Jetson platforms depends on MMCV and the inference engine TensorRT. While MMDeploy C/C++ Inference SDK relies on spdlog, OpenCV and and so on, as well as TensorRT. Thus, in the following sections, we will describe how to prepare TensorRT. And then, we will present the way to install dependencies of Model Converter and C/C++ Inference SDK respectively.

Prepare TensorRT

TensorRT is already packed into JetPack SDK. But In order to import it successfully in conda environment, we need to copy the tensorrt package to the conda environment created before.

cp -r /usr/lib/python${PYTHON_VERSION}/dist-packages/tensorrt* ~/archiconda3/envs/mmdeploy/lib/python${PYTHON_VERSION}/site-packages/
conda deactivate
conda activate mmdeploy
python -c "import tensorrt; print(tensorrt.__version__)" # Will print the version of TensorRT

# set environment variable for building mmdeploy later on
export TENSORRT_DIR=/usr/include/aarch64-linux-gnu

# append cuda path and libraries to PATH and LD_LIBRARY_PATH, which is also used for building mmdeploy later on.
# this is not needed if you use NVIDIA SDK Manager with "Jetson SDK Components" for installing JetPack.
# this is only needed if you install JetPack using SD Card Image Method.
export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64

You can also make the above environment variables permanent by adding them to ~/.bashrc.

echo -e '\n# set environment variable for TensorRT' >> ~/.bashrc
echo 'export TENSORRT_DIR=/usr/include/aarch64-linux-gnu' >> ~/.bashrc

# this is not needed if you use NVIDIA SDK Manager with "Jetson SDK Components" for installing JetPack.
# this is only needed if you install JetPack using SD Card Image Method.
echo -e '\n# set environment variable for CUDA' >> ~/.bashrc
echo 'export PATH=$PATH:/usr/local/cuda/bin' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64' >> ~/.bashrc

source ~/.bashrc
conda activate mmdeploy

Install Dependencies for Model Converter

Install MMCV

MMCV has not provided prebuilt package for Jetson platforms, so we have to build it from source.

sudo apt-get install -y libssl-dev
git clone --branch 2.x
cd mmcv
MMCV_WITH_OPS=1 pip install -e .


It takes about 1 hour 40 minutes to install MMCV on a Jetson Nano. So, please be patient until the installation is complete.

Install ONNX

Don’t install the latest ONNX. The recommended ONNX version is 1.10.0.

# Execute one of the following commands
pip install onnx==1.10.0
conda install -c conda-forge onnx

If the installation failed and showed the following error:

CMake Error at CMakeLists.txt:299 (message):
      Protobuf compiler not found

Please install dependencies:

sudo apt-get install protobuf-compiler libprotoc-dev

Install ONNX Runtime [Optional]

Go to Jetson_Zoo#ONNX_Runtime to find right version of onnx runtime. Then download and install package.

For example:

# Download pip wheel from location mentioned above
$ wget -O onnxruntime_gpu-1.10.0-cp36-cp36m-linux_aarch64.whl

# Install pip wheel
$ pip3 install onnxruntime_gpu-1.10.0-cp36-cp36m-linux_aarch64.whl

Install h5py and pycuda

Model Converter employs HDF5 to save the calibration data for TensorRT INT8 quantization and needs pycuda to copy device memory.

sudo apt-get install -y pkg-config libhdf5-100 libhdf5-dev
pip install versioned-hdf5 pycuda


It takes about 6 minutes to install versioned-hdf5 on a Jetson Nano. So, please be patient until the installation is complete.

Install Dependencies for C/C++ Inference SDK

Install spdlog

spdlog is a very fast, header-only/compiled, C++ logging library

sudo apt-get install -y libspdlog-dev

Install is a high-performance image processing library of openPPL

git clone
export PPLCV_DIR=$(pwd)
echo -e '\n# set environment variable for' >> ~/.bashrc
echo "export PPLCV_DIR=$(pwd)" >> ~/.bashrc
./ cuda


It takes about 15 minutes to install on a Jetson Nano. So, please be patient until the installation is complete.

Install MMDeploy

git clone -b main --recursive
cd mmdeploy
export MMDEPLOY_DIR=$(pwd)

Install Model Converter

Since some operators adopted by OpenMMLab codebases are not supported by TensorRT, we build the custom TensorRT plugins to make it up, such as roi_align, scatternd, etc. You can find a full list of custom plugins from here.

# build TensorRT custom operators
mkdir -p build && cd build
make -j$(nproc) && make install

# install model converter
pip install -v -e .
# "-v" means verbose, or more output
# "-e" means installing a project in editable mode,
# thus any local modifications made to the code will take effect without re-installation.


It takes about 5 minutes to install model converter on a Jetson Nano. So, please be patient until the installation is complete.

Install C/C++ Inference SDK

Build SDK Libraries and its demo as below:

mkdir -p build && cd build
cmake .. \
make -j$(nproc) && make install


It takes about 9 minutes to build SDK libraries on a Jetson Nano. So, please be patient until the installation is complete.

Run a Demo

Object Detection demo

Before running this demo, you need to convert model files to be able to use with this SDK.

  1. Install MMDetection which is needed for model conversion

MMDetection is an open source object detection toolbox based on PyTorch

git clone -b 3.x
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e .  # or "python develop"
  1. Follow this document on how to convert model files.

For this example, we have used as the model config, and this file as the corresponding checkpoint file. Also for deploy config, we have used

python ./tools/ \
    configs/mmdet/detection/ \
    $PATH_TO_MMDET/configs/retinanet/ \
    retinanet_r18_fpn_1x_coco_20220407_171055-614fd399.pth \
    $PATH_TO_MMDET/demo/demo.jpg \
    --work-dir work_dir \
    --show \
    --device cuda:0 \
  1. Finally run inference on an image

./object_detection cuda ${directory/to/the/converted/models} ${path/to/an/image}

The above inference is done on a Seeed reComputer built with Jetson Nano module



  • pip install throws an error like Illegal instruction (core dumped)

    Check if you are using any mirror, if you did, try this:

    rm .condarc
    conda clean -i
    conda create -n xxx python=${PYTHON_VERSION}


  • #assertion/root/workspace/mmdeploy/csrc/backend_ops/tensorrt/batched_nms/trt_batched_nms.cpp,98 or pre_top_k need to be reduced for devices with arch 7.2

    1. Set MAX N mode and perform sudo nvpmodel -m 0 && sudo jetson_clocks.

    2. Reduce the number of pre_top_k in deploy config file like mmdet pre_top_k does, e.g., 1000.

    3. Convert the model again and try SDK demo again.


  • Error error: cannot import name 'ProcessGroup' from 'torch.distributed'.

Read the Docs v: latest
On Read the Docs
Project Home

Free document hosting provided by Read the Docs.