Skip to content

Tutorial - NanoSAM

Let's run NVIDIA's NanoSAM to check out the performance gain by distillation.

What you need

  1. One of the following Jetson:

    Jetson AGX Orin (64GB) Jetson AGX Orin (32GB) Jetson Orin NX (16GB) Jetson Orin Nano (8GB)

  2. Running one of the following versions of JetPack:

    JetPack 5 (L4T r35.x) JetPack 6 (L4T r36.x)

  3. Sufficient storage space (preferably with NVMe SSD).

    • 6.3GB for container image
    • Spaces for models

Set up a container for nanosam

Clone jetson-containers

See jetson-containers' nanosam package README for more infomation**

git clone
cd jetson-containers
sudo apt update; sudo apt install -y python3-pip
pip3 install -r requirements.txt

How to start

Use and autotag script to automatically pull or build a compatible container image.

cd jetson-containers
./ $(./autotag nanosam)

Run examples

Inside the container, you can move to /opt/nanosam directory, to go through all the examples demonstrated on the repo.

cd /opt/nanosam

To run the "Example 1 - Segment with bounding box":

python3 examples/ \
    --image_encoder="data/resnet18_image_encoder.engine" \

The result is saved under /opt/nanosam/data/basic_usage_out.jpg.

To check on your host machine, you can copy that into /data directory of the container where that is mounted from the host.

cp data/basic_usage_out.jpg /data/

Then you can go to your host system, and find the file under the jetson_containers' data directory, like jetson_containers/data/basic_usage_out.jpg.