Installer causes Docker layer to duplicate cuda libraries even with --skip-cuda

We have a Dockerfile that uses an nvidia container as its base layer, and then at some point later copies the following shell script into a layer and then runs it:

wget -q -O ZED_SDK_Linux_Ubuntu.run  https://download.stereolabs.com/zedsdk/4.0/cu118/ubuntu20 
chmod +x ZED_SDK_Linux_Ubuntu.run 
./ZED_SDK_Linux_Ubuntu.run -- silent skip_python skip_cuda
chmod -R +777 /usr/local/zed
ln -sf /lib/x86_64-linux-gnu/libusb-1.0.so.0 /usr/lib/x86_64-linux-gnu/libusb-1.0.so 
rm ZED_SDK_Linux_Ubuntu.run 

this skip installing cuda, but unfortunately the following line of linux_install_release.sh runs no matter what:

    # Ensure the libs are accessible
    sudo chmod a+rx -R "/usr/local/cuda/lib64/"*

Because any chmod/chown operation in a docker command increases layer sizes in docker, this causes the ZED layer to be an extra ~2.1gb in size, with no way to avoid it. (see filesize - Why does chown increase size of docker image? - Stack Overflow)

I think if --skip-cuda has been set, any manipulation of the cuda directories should be skipped entirely and ensuring cuda is available should be on the user.

2 Likes

By the way this problem exists in the official stereolabs Docker images, using the dive analysis tool calls it out pretty clearly:

Thank you for the documented report, I didn’t suspect this was causing such a huge size difference. We’ll fix the install script and keep this in mind for the next docker image build.