Jetson/FAQ/BSP/RootFS Reduction

< Jetson‎ | FAQ/BSP
Revision as of 01:52, 3 February 2020 by Peter Pan (talk | contribs) (How to fix library missing issue after reduction)
Jump to: navigation, search

How to reduce disk usage on Jetson platform

Jetson platform files system is based on ubuntu sample file system. Some Nvidia platform related binaries (BSP related) are added to support platform basic function. Jetson SDK Components including CUDA, cuDNN, TensorRT, OpenCV, VisionWorks, DeepStream and multimedia API provide AI related support.

This page breaks down Nvidia platform related binaries and Jetson SDK Component, so user can remove unused files to save space. A command to list all installed ubuntu packages by size is also provided for user to remove unused package based on needs.

Nvidia platform related binaries breakdown

Below is a breakdown of Nvidia platform related binaries.

 ├── boot (43M)           Image(kernel binary), dtb and extlinux.conf. All are not used by Xavier, Image and extlinux.conf are used by Nano, TX1 and TX2
 ├── etc (536K)           Nvidia specified config file. DO NOT touch
 ├── lib
 │   ├── firmware (4.3M)  Firmwares used by platform. DO NOT touch
 │   ├── modules (47M)    Modules(.ko) used by platform. Can delete some based on needs
 │   └── systemd (32K)    Nvidia specified config file. DO NOT touch
 ├── opt
 │   └── nvidia  (17M)    Jetson gpio python lib and usb device mode service. Can delete based on needs
 ├── usr
 │   ├── bin (356K)       Nvidia speficied tools. DO NOT touch
 │   ├── lib (130M)       Nvidia speficied libs. DO NOT touch
 │   ├── sbin (2M)        Nvidia speficied tools. DO NOT touch
 │   ├── share (2.5M)     Nvidia specified boot logo, license, icon, etc. DO NOT touch
 │   └── src (234M)       Linux header files and grahics demos. Can delete based on needs
 └── var
     └── nvidia (188K)    Placeholder for nvcam. Can delete based on needs

Jetson SDK Components

Based on Jetson OS, Jetson SDK Components, including CUDA, cuDNN, TensorRT, OpenCV, VisionWorks, MultiMedia API and DeepStream, are installed by sdkmanager(or jetpack tool for older version). MultiMedia API is installed by tbz2 package while others are installed by deb package.

Both Jetson SDK libs(both static and dynamic libs) and sample code are installed and sample code can be deleted to save space. And if user's application is dynamicly linked to these libs, all static libs can be deleted.

After Jetson SDK Components are installed, run below commands can remove all deb files.

 sudo apt clean    # clean debs in /var/cache/apt/archives
 sudo rm /etc/apt/sources.list.d/*        # remove /var/cudaxxxx, /var/visonworksxxxx from apt source list
 sudo rm /var/cuda-repo-10-0-local-10.0.326/ /var/visionworks-repo/ /var/visionworks-sfm-repo/ /var/visionworks-tracking-repo/ -rf     # remove nvidia's debs

Below table list all Jetson SDK Components brief breakdown.


Elememt Path Size
sample /usr/local/cuda/samples 198M
dynamic lib /usr/local/cuda/targets/aarch64-linux/lib/*.so* 723M
static lib /usr/local/cuda/targets/aarch64-linux/lib/*.a 898M
doc /usr/local/cuda/doc 231M


Elememt Path Size
sample /usr/src/cudnn_samples_v7 11M
dynamic lib /usr/lib/aarch64-linux-gnu/libcudnn*.so* 367M
static lib /usr/lib/aarch64-linux-gnu/libcudnn*.a 358M


Elememt Path Size
sample /usr/src/tensorrt 783M
dynamic lib /usr/lib/aarch64-linux-gnu/libnvcaffe_parser*.so*
static lib /usr/lib/aarch64-linux-gnu/libnvcaffe_parser*.a
doc /usr/share/doc/libnvinfer* 24K


Elememt Path Size
sample /usr/share/OpenCV 11M
dynamic lib /usr/lib/libopencv*.so* 19M


Elememt Path Size
sample /usr/share/visionworks*
dynamic lib /usr/lib/libvisionworks*.so* 28M
doc /usr/share/doc/libvisionworks* 352K


Elememt Path Size
sample /opt/nvidia/deepstream/deepstream*/samples 205M
dynamic lib /opt/nvidia/deepstream/deepstream*/lib 52M
doc /opt/nvidia/deepstream/deepstream*/doc 16K

MultiMedia API

Path Size
/usr/src/tegra_multimedia_api 107M

Remove installed deb packages

Run below command can remove all cached .deb file.

 sudo apt clean

Run below command can remove all non-required installed packages.

 sudo apt autoremove

Below command can list all install deb packages by size. User can remove the undesired packages by hand to save space.

 dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -rn


Remove all deb installation packages

 sudo apt clean
 sudo rm /etc/apt/sources.list.d/*
 sudo rm -rf /var/cuda-repo-10-0-local-10.0.326/ /var/visionworks-repo/ /var/visionworks-sfm-repo/ /var/visionworks-tracking-repo

Remove ubuntu-desktop and the accessories

 sudo apt-get purge gnome-shell
 sudo apt-get purge docker*
 sudo apt-get purge chromium-browser thunderbird fonts-noto-cjk  libreoffice-common  containerd  snapd
 sudo apt-get remove --purge python* libpython*
 sudo apt-get purge libwebkit2gtk-4.0-37  libqt5webkit5  ubuntu-wallpapers-bionic freepats  libreoffice-writer libicu60  libreoffice-calc vim-runtime libflite1  libperl5.26 libmozjs-52-0 humanity-icon-theme samba-libs  iso-codes kwin-data perl-modules-5.26 light-themes libjavascriptcoregtk-4.0-18 chromium-browser-l10n
 sudo apt-get purge libvisionworks libvisionworks-sfm-dev libvisionworks-sfm-repo
 sudo apt-get autoremove

Remove some source code and sample code

 cd /usr/src && sudo rm -rf cudnn_samples_v7 linux-headers-4.9.140-tegra-ubuntu18.04_aarch64 linux-headers-4.9.140-tegra-linux_x86_64  tensorrt nvidia
 rm -rf /home/nvidia/VisionWorks-SFM-0.90-Samples

How to fix library missing issue after reduction

Sometimes after removing ubuntu packages, application execution may fail due to depended libraries missing.

For example, after removing packages by above example, Jetson Multimedia API sample cannot run like below.

 nvidia@nvidia-desktop:~/jetson_multimedia_api/samples/00_video_decode$ ./video_decode
 ./video_decode: error while loading shared libraries: cannot open shared object file: No such file or directory

ldd command shows both and are missing like below. So we need to copy these libraries from clean platform.

 nvidia@nvidia-desktop:~/jetson_multimedia_api/samples/00_video_decode$ ldd video_decode (0x0000007f869e8000) => /lib/aarch64-linux-gnu/ (0x0000007f86916000) => not found => /usr/lib/aarch64-linux-gnu/ (0x0000007f868f5000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f868bf000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f86796000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8677c000) => not found => /usr/lib/aarch64-linux-gnu/ (0x0000007f8674a000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f865b7000) => /lib/aarch64-linux-gnu/ (0x0000007f86593000) => /lib/aarch64-linux-gnu/ (0x0000007f8643a000)
       /lib/ (0x0000007f869bd000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8630e000) => /lib/aarch64-linux-gnu/ (0x0000007f862f9000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f862c9000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f86287000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f86268000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8624a000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f86237000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8621b000) => /lib/aarch64-linux-gnu/ (0x0000007f86161000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8614e000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f86139000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8611b000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f860fc000) => /lib/aarch64-linux-gnu/ (0x0000007f860da000) => /lib/aarch64-linux-gnu/ (0x0000007f860c3000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f860ae000)

On clean platform, we can use "find" and "ls" command to get all the necessary libraries like below.

 nvidia@nvidia-xavier:~$ find /usr/lib/ -name "*"
 nvidia@nvidia-xavier:/usr/lib/aarch64-linux-gnu$ ls -l /usr/lib/aarch64-linux-gnu/*
 lrwxrwxrwx 1 root root    12 Dec 26 16:15 /usr/lib/aarch64-linux-gnu/ ->
 lrwxrwxrwx 1 root root    21 Dec 19 14:43 /usr/lib/aarch64-linux-gnu/ ->
 -rw-r--r-- 1 root root 55424 Feb 10  2018 /usr/lib/aarch64-linux-gnu/
 lrwxrwxrwx 1 root root    18 Dec 10 15:08 /usr/lib/aarch64-linux-gnu/ -> tegra/

After restore libv4l2 and libnvjpeg, remember to run "sudo ldconfig" to update /etc/

Now, re-run video_decode, it still fails. That's because the new added libv4l2 and libnvjpeg depends on other missing libraries like below:

 nvidia@nvidia-desktop:~/jetson_multimedia_api/samples/00_video_decode$ ldd video_decode (0x0000007f9abff000) => /lib/aarch64-linux-gnu/ (0x0000007f9ab2d000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9aa18000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9a9f7000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9a9c1000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9a898000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a87e000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a826000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9a7f4000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9a661000) => /lib/aarch64-linux-gnu/ (0x0000007f9a63d000) => /lib/aarch64-linux-gnu/ (0x0000007f9a4e4000)
       /lib/ (0x0000007f9abd4000) => not found => /lib/aarch64-linux-gnu/ (0x0000007f9a4cf000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9a3a3000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9a373000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a331000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a312000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a2f4000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a2e1000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a2bc000) => not found => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a2a0000) => /lib/aarch64-linux-gnu/ (0x0000007f9a1e6000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9a1d3000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f9a1be000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a1a0000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a181000) => /lib/aarch64-linux-gnu/ (0x0000007f9a15f000) => /lib/aarch64-linux-gnu/ (0x0000007f9a148000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f9a133000)

After restore libv4lconvert and libnvbufsurface just like libv4l2, all dependencies are available now.

 nvidia@nvidia-desktop:~/jetson_multimedia_api/samples/00_video_decode$ ldd video_decode (0x0000007f8bb5c000) => /lib/aarch64-linux-gnu/ (0x0000007f8ba8a000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b975000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b954000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b91e000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b7f5000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8b7db000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8b783000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b751000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b5be000) => /lib/aarch64-linux-gnu/ (0x0000007f8b59a000) => /lib/aarch64-linux-gnu/ (0x0000007f8b441000)
       /lib/ (0x0000007f8bb31000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b3bc000) => /lib/aarch64-linux-gnu/ (0x0000007f8b3a7000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b27b000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b24b000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8b209000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8b1ea000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8b1cc000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8b1b9000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8b194000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8b116000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8b0fa000) => /lib/aarch64-linux-gnu/ (0x0000007f8b040000) => /lib/aarch64-linux-gnu/ (0x0000007f8b029000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b016000) => /usr/lib/aarch64-linux-gnu/ (0x0000007f8b001000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8afe3000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8afc4000) => /lib/aarch64-linux-gnu/ (0x0000007f8afa2000) => /usr/lib/aarch64-linux-gnu/tegra/ (0x0000007f8af8d000)