Nvidia jetson debloating guide

does anyone know of like an nvidia jetson debloating guide that exists?

I was just updating my jetson to the latest jetpack release and wanted to take a go at removing some of the massive amounts of bloat that nvidia ships with jetpack. I looked around and couldn’t find really many good guides on getting rid of some of the garbage they leave laying around

if no such guide exists, I was pretty comprehensive in documenting the steps that I took to clean things up. would anyone be interested in me writing it up into a guide and publishing it? (I’m not talking about smth paid, I mean like a free blog post)

2 Likes

These are a few key steps we do:

- hosts: jetson
  tags: [jetson]
  tasks:
  - name: Prefer system OpenCV  
    ansible.builtin.copy:
      src: "{{ files }}/etc/apt/preferences.d/00-l4t-fix-opencv"
      dest: "/etc/apt/preferences.d/00-l4t-fix-opencv"
      mode: 0644
      directory_mode: 0755
      owner: root
      group: root
    become: true

  - name: Install OpenCV
    ansible.builtin.apt:
      name: "libopencv-dev"
      state: present
      allow_downgrade: True
    become: yes

  - name: Prefer system ffmpeg  
    ansible.builtin.copy:
      src: "{{ files }}/etc/apt/preferences.d/00-l4t-fix-ffmpeg"
      dest: "/etc/apt/preferences.d/00-l4t-fix-ffmpeg"
      mode: 0644
      directory_mode: 0755
      owner: root
      group: root
    become: true

  - name: Install FFMpeg
    ansible.builtin.apt:
      name: "ffmpeg"
      state: present
      allow_downgrade: True
    become: yes

With:

Package: ffmpeg
Pin: release o=Ubuntu
Pin-Priority: 1000

and

Package: libopencv-dev
Pin: release o=Ubuntu
Pin-Priority: 1000

being the APT pref files.

This solves the long-standing issue that NVidia chose to ship different version of OpenCV and ffmpeg than which is in the upstream Ubuntu. So when you install any binary ROS packages built on the buildfarm against the Ubuntu version, they’re very prone to fail on Jetson unless you do this.

I think GStreamer could suffer from the same problem.

Yes, of course, you’ll lose the nvidia additions to these packages. ffmpeg might actually have some that you’d want. However, NVidia OpenCV is bullshit, it is NOT built with CUDA support (yes, that’s true and jtop isn’t lying about it - or at least that was the case for JP 5 when I investigated this).

6 Likes

lmfao, incredible

great work nvidia

they seem to do some amazing things with jetpack, like this, marking literally every single package as manually installed, shipping an entire desktop environment for an embedded platform, etc.

also, based on the yaml, I’m assuming you’re using something to manage setting up jetsons automatically? what is it you’re using for that?

do you know what additions they have to it? is it specific patches or just compiling with different features enabled? iirc they had a tarball you could download on their website (though, annoyingly, it’s a single tarball for everything)
wait nvm I just realized that’s ansible lol

1 Like

I’ve ran into this recently as well haha, at build time everything was using nvidia’s version, and at runtime prebuilt cv_bridge got pulled in which required the apt one and boom. My workaround at the time was to implement the little I needed cv_bridge for manually and use nvidia’s opencv at both build and runtime.

I wasn’t really feeling good about removing their version in case something else depended on it, but if this approach works without nuking tensorrt and the rest of jetpack then it’s a great solution :+1:

Btw, I don’t suppose you’ve found a way to get CUDA compiled opencv on Orins that doesn’t involve waiting 8 hours for it to compile from source? I would’ve imagined there has to be an apt source out there with prebuilt binaries but I admit I haven’t really looked after “solving” that for the time being.

Nope, we don’t have CUDA-enabled OpenCV… But usually you can build a deb package and the distribute only that…

@peci1 This is super helpful. Thanks!

Do you think it would be helpful to reach out to OpenCV and NVIDIA to see if we could remedy this situation?

1 Like

I already reached out to NVidia. No effect. Very bad ideas about naming the opencv libraries - #5 by DaneLLL - Jetson AGX Xavier - NVIDIA Developer Forums

@Katherine_Scott your reaching capabilities are probably better than mine in this area, so feel free to give it another try.

if only nvidia actually distributed the ffmpeg source instead of violating the GPL license

$ apt source ffmpeg
Reading package lists... Done
E: Unable to find a source package for ffmpeg

(and no, modifying the /etc/apt/sources.list.d/nvidia-l4t-apt-source.list file to make sure that deb-src was used for the ffmpeg repository did not fix this)

the same applies to opencv, but this isn’t a license violation

nvidia moment