Error building l4t-jetpack docker image with runtime libraries

I am trying to build l4t-jetpack docker image for r36.2.0 based on the provided dockerfile replacing the dev packages with runtime packages and avoiding building the corresponding opencv and tensorrt packages. The final dockerfile I use is:

ARG L4T_TAG=r36.2.0

FROM nvcr.io/nvidia/l4t-base:${L4T_TAG}

#
# Install any utils needed for execution
#
RUN apt-get update && apt-get install -y --no-install-recommends \
    sudo \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get clean

#
# Install nvidia-cuda-dev for CUDA developer packages
# Use nvidia-cuda if need CUDA runtime only
#
RUN apt-get update && apt-get install -y --no-install-recommends \
    nvidia-cuda \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get clean

#
# Install nvidia-cudnn8-dev for CuDNN developer packages
# Use nvidia-cudnn8 if need CuDNN runtime only
#
RUN apt-get update && apt-get install -y --no-install-recommends \
    nvidia-cudnn8 \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get clean

# #
# # Install nvidia-tensorrt-dev for TensorRT developer packages
# # Use nvidia-tensorrt if need TensorRT runtime only
# #
# RUN apt-get update && apt-get install -y --no-install-recommends \
#     nvidia-tensorrt \
#     && rm -rf /var/lib/apt/lists/* \
#     && apt-get clean

#
# Install nvidia-vpi-dev for VPI developer packages
# Use nvidia-vpi if need VPI runtime only
#
RUN mkdir -p /lib/firmware/
RUN apt-get update && apt-get install -y --no-install-recommends \
    nvidia-vpi \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get clean

#
# Install Multimedia API samples & libs
#
RUN apt-get update && apt-get download nvidia-l4t-jetson-multimedia-api \
    && dpkg-deb -R ./nvidia-l4t-jetson-multimedia-api_*_arm64.deb ./mm-api \
    && cp -r ./mm-api/usr/src/jetson_multimedia_api /usr/src/jetson_multimedia_api \
    && ./mm-api/DEBIAN/postinst \
    && rm -rf ./nvidia-l4t-jetson-multimedia-api_*_arm64.deb ./mm-api

#Update libraries
RUN ldconfig 

#
# Setup environment variables
#
ENV CUDA_HOME=/usr/local/cuda
ENV PATH=/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}

but I am getting the following errors when trying to install nvidia-cuda package:

#6 [3/8] RUN apt-get update && apt-get install -y --no-install-recommends     nvidia-cuda     && rm -rf /var/lib/apt/lists/*     && apt-get clean
#6 0.704 Get:1 http://ports.ubuntu.com/ubuntu-ports jammy InRelease [270 kB]
#6 0.955 Get:2 https://repo.download.nvidia.com/jetson/common r36.2 InRelease [2555 B]
#6 1.016 Get:3 http://ports.ubuntu.com/ubuntu-ports jammy-updates InRelease [128 kB]
#6 1.101 Get:4 http://ports.ubuntu.com/ubuntu-ports jammy-backports InRelease [127 kB]
#6 1.185 Get:5 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease [129 kB]
#6 2.467 Get:6 http://ports.ubuntu.com/ubuntu-ports jammy/restricted arm64 Packages [24.2 kB]
#6 2.583 Get:7 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 Packages [17.2 MB]
#6 5.479 Get:8 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 Packages [24.3 kB]
#6 27.90 Get:9 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 Packages [1758 kB]
#6 29.77 Get:10 http://ports.ubuntu.com/ubuntu-ports jammy/multiverse arm64 Packages [224 kB]
#6 29.96 Get:11 http://ports.ubuntu.com/ubuntu-ports jammy-updates/multiverse arm64 Packages [29.5 kB]
#6 30.00 Get:12 http://ports.ubuntu.com/ubuntu-ports jammy-updates/restricted arm64 Packages [2008 kB]
#6 31.71 Get:13 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 Packages [1340 kB]
#6 32.98 Get:14 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 Packages [1944 kB]
#6 34.14 Get:15 http://ports.ubuntu.com/ubuntu-ports jammy-backports/universe arm64 Packages [30.3 kB]
#6 34.15 Get:16 http://ports.ubuntu.com/ubuntu-ports jammy-backports/main arm64 Packages [80.6 kB]
#6 34.15 Get:17 http://ports.ubuntu.com/ubuntu-ports jammy-security/universe arm64 Packages [1062 kB]
#6 34.39 Get:18 http://ports.ubuntu.com/ubuntu-ports jammy-security/main arm64 Packages [1689 kB]
#6 37.48 Get:19 http://ports.ubuntu.com/ubuntu-ports jammy-security/multiverse arm64 Packages [24.1 kB]
#6 37.51 Get:20 http://ports.ubuntu.com/ubuntu-ports jammy-security/restricted arm64 Packages [1946 kB]
#6 39.00 Fetched 30.1 MB in 39s (781 kB/s)
#6 39.00 Reading package lists...
#6 43.07 W: https://repo.download.nvidia.com/jetson/common/dists/r36.2/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
#6 43.33 Reading package lists...
#6 47.37 Building dependency tree...
#6 47.97 Reading state information...
#6 48.09 Some packages could not be installed. This may mean that you have
#6 48.09 requested an impossible situation or if you are using the unstable
#6 48.09 distribution that some required packages have not yet been created
#6 48.09 or been moved out of Incoming.
#6 48.09 The following information may help to resolve the situation:
#6 48.09 
#6 48.09 The following packages have unmet dependencies:
#6 48.31  cuda-compat-12-2 : PreDepends: nvidia-l4t-core but it is not installable
#6 48.31  nvidia-l4t-cudadebuggingsupport : Depends: nvidia-l4t-cuda (> 36.0.0-0) but it is not installable
#6 48.31                                    Depends: nvidia-l4t-cuda (< 37.0.0-0) but it is not installable
#6 48.32 E: Unable to correct problems, you have held broken packages.
#6 ERROR: process "/bin/sh -c apt-get update && apt-get install -y --no-install-recommends     nvidia-cuda     && rm -rf /var/lib/apt/lists/*     && apt-get clean" did not complete successfully: exit code: 100

I added the following before installing the packages

RUN apt-key adv --fetch-key http://repo.download.nvidia.com/jetson/jetson-ota-public.asc
RUN echo 'deb https://repo.download.nvidia.com/jetson/t234 r36.2 main' > /etc/apt/sources.list.d/nvidia-l4t-apt-source.list

Now it founds all the packages in which nvidia-cuda depends on but now I am getting the following error:

#8 21.68 The following additional packages will be installed:
#8 21.68   cuda-compat-12-2 cuda-cudart-12-2 cuda-libraries-12-2 cuda-nvrtc-12-2
#8 21.68   cuda-runtime-12-2 cuda-toolkit-12-2-config-common
#8 21.68   cuda-toolkit-12-config-common cuda-toolkit-config-common libcublas-12-2
#8 21.68   libcudla-12-2 libcufft-12-2 libcufile-12-2 libcurand-12-2 libcusolver-12-2
#8 21.68   libcusparse-12-2 libnpp-12-2 libnvjitlink-12-2 nvidia-l4t-core
#8 21.68   nvidia-l4t-cuda nvidia-l4t-cudadebuggingsupport
#8 21.82 The following NEW packages will be installed:
#8 21.82   cuda-compat-12-2 cuda-cudart-12-2 cuda-libraries-12-2 cuda-nvrtc-12-2
#8 21.82   cuda-runtime-12-2 cuda-toolkit-12-2-config-common
#8 21.82   cuda-toolkit-12-config-common cuda-toolkit-config-common libcublas-12-2
#8 21.82   libcudla-12-2 libcufft-12-2 libcufile-12-2 libcurand-12-2 libcusolver-12-2
#8 21.82   libcusparse-12-2 libnpp-12-2 libnvjitlink-12-2 nvidia-cuda nvidia-l4t-core
#8 21.82   nvidia-l4t-cuda nvidia-l4t-cudadebuggingsupport
#8 22.71 0 upgraded, 21 newly installed, 0 to remove and 91 not upgraded.
#8 22.71 Need to get 695 MB of archives.
#8 22.71 After this operation, 1907 MB of additional disk space will be used.
#8 22.71 Get:1 https://repo.download.nvidia.com/jetson/t234 r36.2/main arm64 nvidia-l4t-core arm64 36.2.0-20231218214829 [3743 kB]
#8 23.69 Get:2 https://repo.download.nvidia.com/jetson/t234 r36.2/main arm64 nvidia-l4t-cuda arm64 36.2.0-20231218214829 [5442 kB]
#8 24.28 Get:3 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 cuda-compat-12-2 arm64 12.2.34086590-1 [18.8 MB]
#8 25.82 Get:4 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 nvidia-l4t-cudadebuggingsupport arm64 12.2-33282765.0 [2530 kB]
#8 26.03 Get:5 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 cuda-toolkit-config-common all 12.2.140-1 [16.4 kB]
#8 26.04 Get:6 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 cuda-toolkit-12-config-common all 12.2.140-1 [16.4 kB]
#8 26.04 Get:7 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 cuda-toolkit-12-2-config-common all 12.2.140-1 [16.3 kB]
#8 26.04 Get:8 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 cuda-cudart-12-2 arm64 12.2.140-1 [176 kB]
#8 26.05 Get:9 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 cuda-nvrtc-12-2 arm64 12.2.140-1 [16.4 MB]
#8 27.41 Get:10 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 libcublas-12-2 arm64 12.2.5.6-1 [227 MB]
#8 60.55 Get:11 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 libcufft-12-2 arm64 11.0.8.103-1 [58.0 MB]
#8 65.58 Get:12 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 libcufile-12-2 arm64 1.7.2.10-1 [721 kB]
#8 65.80 Get:13 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 libcudla-12-2 arm64 12.2.140-1 [29.1 kB]
#8 66.01 Get:14 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 libcurand-12-2 arm64 10.3.3.141-1 [42.5 MB]
#8 70.15 Get:15 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 libcusolver-12-2 arm64 11.5.2.141-1 [83.9 MB]
#8 85.13 Get:16 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 libcusparse-12-2 arm64 12.1.2.141-1 [118 MB]
#8 112.8 Get:17 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 libnpp-12-2 arm64 12.2.1.4-1 [103 MB]
#8 124.9 Get:18 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 libnvjitlink-12-2 arm64 12.2.140-1 [14.3 MB]
#8 128.1 Get:19 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 cuda-libraries-12-2 arm64 12.2.12-1 [2590 B]
#8 128.1 Get:20 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 cuda-runtime-12-2 arm64 12.2.12-1 [2502 B]
#8 128.1 Get:21 https://repo.download.nvidia.com/jetson/common r36.2/main arm64 nvidia-cuda arm64 6.0-b52 [28.1 kB]
#8 128.8 debconf: delaying package configuration, since apt-utils is not installed
#8 128.9 Fetched 695 MB in 1min 46s (6537 kB/s)
#8 129.0 Selecting previously unselected package nvidia-l4t-core.
#8 129.0 (Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 34278 files and directories currently installed.)
#8 129.0 Preparing to unpack .../nvidia-l4t-core_36.2.0-20231218214829_arm64.deb ...
#8 129.1 /var/lib/dpkg/tmp.ci/preinst: line 43: /proc/device-tree/compatible: No such file or directory
#8 129.1 dpkg: error processing archive /var/cache/apt/archives/nvidia-l4t-core_36.2.0-20231218214829_arm64.deb (--unpack):
#8 129.1  new nvidia-l4t-core package pre-installation script subprocess returned error exit status 1
#8 129.2 Errors were encountered while processing:
#8 129.2  /var/cache/apt/archives/nvidia-l4t-core_36.2.0-20231218214829_arm64.deb
#8 129.3 E: Sub-process /usr/bin/dpkg returned an error code (1)
#8 ERROR: process "/bin/sh -c apt-get update && apt-get install -y --no-install-recommends     nvidia-cuda     && rm -rf /var/lib/apt/lists/*     && apt-get clean" did not complete successfully: exit code: 100

Hi,

We have provided a l4t-jetpack container for r36.2.
So you don’t need to build it from the source:

Thanks.