qengineering Jetson Nano Ubuntu 20.04 Image

repository·main·Indexed 19 days ago

https://github.com/qengineering/jetson-nano-ubuntu-20-image

A custom Ubuntu 20.04 OS image optimized for NVIDIA Jetson Nano. It comes pre-configured with deep learning libraries including OpenCV 4.8.0, TensorFlow 2.4.1, PyTorch 1.13.0, TorchVision 0.14.0, and TensorRT 8.0.1.6. The documentation covers installation via SD card flashing, partition expansion with GParted, GCC/G++ version configuration, VNC setup, and instructions for converting the image to a headless OS.

Tokens
1.5K
Snippets
8
Records
10
Agent score
26%

What's inside jetson-nano-ubuntu-20-image

  1. Install the Jetson Nano Ubuntu 20.04 Image

    main

    To install the Ubuntu 20.04 OS image on a Jetson Nano, follow these steps:

    1. Prepare Hardware: Use a minimum 32 GB SD card. It is highly recommended to use a 64 GB or larger card because the software occupies over 21 GB, leaving little room for user data on a 32 GB card.
    2. Download Image: Download JetsonNanoUb20_3b.img.xz from the official server.
    3. Flash SD Card: Use Raspberry Pi Imager or balenaEtcher.
      • Note: Flash the .xz file directly; do not unzip it first.
      • Note: If using Imager, it is reported to work more reliably than balenaEtcher for this image.
    4. Boot: Insert the SD card into the Jetson Nano.

    Credentials:

    • Password: jetson
    • MD5 Checksum: D738F1FE20088A1BDBD10E2358B512F7
    # No single command, but the process involves flashing the .xz file directly.
  2. Reconstruct split image files using 7z

    main

    If you download the image in chunks (e.g., JetsonNanoUb20_3b.img.xz.001 through ...013), you can reconstruct the original .img.xz file using 7-Zip.

    Place all chunks in one folder and run the extraction command on the first file. 7-Zip will automatically process the subsequent parts in order.

    If 7z is not in your system PATH, you must provide the full path to the executable.

    # Standard usage
    7z x JetsonNanoUb20_3b.img.xz.001
    
    # Windows example with full path
    "C:\Program Files\7-Zip\7z.exe" x JetsonNanoUb20_3b.img.xz.001
  3. Configure GCC and G++ versions

    main

    The image includes both GCC/G++ version 8 and version 9. Since many CUDA-related software packages require version 8, you can switch between them using update-alternatives.

    Use the following commands to select your preferred version:

    $ sudo update-alternatives --config gcc
    $ sudo update-alternatives --config g++
  4. Enable VNC for remote desktop access

    main

    To enable VNC on Ubuntu 20.04, you must first configure the GNOME Vino server to allow connections without encryption.

    1. Run the following command to disable required encryption: $ gsettings set org.gnome.Vino require-encryption false
    2. On your VNC client, ensure you uncheck the 'Authenticate' boxes during connection.
    $ gsettings set org.gnome.Vino require-encryption false
  5. Expand SD card partition using GParted

    main

    Because the image contains a large amount of software, you should expand the partition to utilize the full capacity of your SD card (especially if using 64GB+).

    1. Install GParted: $ sudo apt-get install gparted.
    2. Use GParted to resize the partition to fill the remaining unallocated space on the SD card.
    $ sudo apt-get install gparted
  6. Convert to a Headless OS

    main

    To reduce the OS footprint to approximately 420 MB, you can remove the desktop environment and associated GUI packages. This is useful for resource-constrained headless deployments.

    Warning: This will remove the graphical user interface.

    sudo chown root:root / /lib
    sudo apt purge ubuntu-desktop -y && sudo apt autoremove -y && sudo apt autoclean
    sudo apt-get remove nautilus nautilus-* gnome-power-manager gnome-screensaver gnome-termina* gnome-pane* 
    sudo apt-get remove gnome-applet* gnome-bluetooth gnome-desktop* gnome-sessio* gnome-user* gnome-shell-common
    sudo apt-get remove zeitgeist-core libzeitgeist* gnome-control-center gnome-screenshot && sudo apt-get autoremove
    sudo apt-get remove --purge libreoffice* 
    sudo apt-get remove libreoffice-core
    sudo apt-get remove snapd lightdm cups chromium*
  7. Fix 'cannot allocate memory in static TLS block' error when using OpenCV and TensorFlow/TensorRT

    main

    When using an aarch64 system (like the Jetson Nano), importing both OpenCV and TensorFlow (or TensorRT) in Python can trigger the error: cannot allocate memory in static TLS block. This is caused by OpenMP memory requirements.

    To resolve this, use one of the following methods:

    1. Recommended: Import Order Import cv2 (OpenCV) at the very beginning of your Python script, before importing TensorFlow or TensorRT.

    2. Alternative: Disable OpenMP Rebuild OpenCV with the -DBUILD_OPENMP=OFF and -DWITH_OPENMP=OFF flags. This forces OpenCV to use pthread or TBB for parallelization instead. Note that this is not recommended as not all OpenCV algorithms will automatically switch to pthread.

    import cv2
    import tensorflow as tf
    # or
    import cv2
    import tensorrt