How to enable GPU in custom docker image?

Hello guys, let just say, that i will use ubuntu:bionic as base image, install all l4t debs inside container.

How can i access GPU from within my custom image?

I tried docker run --runtime=nvidia …
it does not work …

Here is example of my Dockerfile used to build custom container

FROM ubuntu:bionic  as base
# Set the working directory to /app
WORKDIR /app

FROM base as nvidia
ARG SOC="t210"
ADD --chown=root:root https://repo.download.nvidia.com/jetson/jetson-ota-public.asc /etc/apt/trusted.gpg.d/jetson-ota-public.asc
RUN chmod 644 /etc/apt/trusted.gpg.d/jetson-ota-public.asc \
    && apt-get update && apt-get install -y --no-install-recommends ca-certificates \
    && echo "deb https://repo.download.nvidia.com/jetson/common r32.6 main" > /etc/apt/sources.list.d/nvidia-l4t-apt-source.list \
    && echo "deb https://repo.download.nvidia.com/jetson/${SOC} r32.6 main" >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list \
    && rm -rf /var/lib/apt/lists/* \
    && mkdir -p /opt/nvidia/l4t-packages/ && touch /opt/nvidia/l4t-packages/.nv-l4t-disable-boot-fw-update-in-preinstall

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
    && apt-get -y install -o Dpkg::Options::="--force-confnew" nvidia-l4t-gstreamer

FROM nvidia
# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
    && apt-get -y install libssl-dev
RUN yes yes | gst-install --prefix=/app/gst --version=1.16.2
RUN ldconfig

ENV LD_LIBRARY_PATH=/app/gst/lib/aarch64-linux-gnu
ENV PATH=/app/gst/bin:${PATH}

container has all required nvidia debs inside

root@aa306154a59d:/app# dpkg -l |grep l4t
ii  nvidia-l4t-3d-core                   32.6.1-20210916211029               arm64        NVIDIA GL EGL Package
ii  nvidia-l4t-camera                    32.6.1-20210916211029               arm64        NVIDIA Camera Package
ii  nvidia-l4t-core                      32.6.1-20210726122000               arm64        NVIDIA Core Package
ii  nvidia-l4t-cuda                      32.6.1-20210916211029               arm64        NVIDIA CUDA Package
ii  nvidia-l4t-firmware                  32.6.1-20210916211029               arm64        NVIDIA Firmware Package
ii  nvidia-l4t-gstreamer                 32.6.1-20210916211029               arm64        NVIDIA GST Application files
ii  nvidia-l4t-init                      32.6.1-20210916211029               arm64        NVIDIA Init debian package
ii  nvidia-l4t-libvulkan                 32.6.1-20210916211029               arm64        NVIDIA Vulkan Loader Package
ii  nvidia-l4t-multimedia                32.6.1-20210916211029               arm64        NVIDIA Multimedia Package
ii  nvidia-l4t-multimedia-utils          32.6.1-20210916211029               arm64        NVIDIA Multimedia Package
ii  nvidia-l4t-wayland                   32.6.1-20210916211029               arm64        NVIDIA Wayland Package
ii  nvidia-l4t-x11                       32.6.1-20210916211029               arm64        NVIDIA X11 Package

Hi,

Please use l4t image as base instead.

https://ngc.nvidia.com/catalog/containers/nvidia:l4t-base

Thanks.

hi @AastaLLL , of course i am using those
But I am really curious, what is that secret ingredience that only these l4t-xxx containers work on jetson with gpu?
is it a way nvidia runtime on jetson is implemented - that it specifically detects for l4t container and only in this case will mount gpu?
on pc there is gpus all on docker …

i am totaly aware that those l4t containers are mounting libraries as specified in nvidia-container-runtime.d and those .csv files to save container image space.
but if i decide to “install” those libraries inside my container (see that dockerfile) than i am all set and i have all necessary jetson gpu drivers/cuda libraries etc needed, so why they do not work with --runtime=nvidia or --gpus all ??

thanks in advance for helping me to understand that.

Hi,

Please note that Jetson equips iGPU rather than the dGPU.
The OS is also a customized l4t rather than standard Linux.

You can use --runtime=nvidia and by default, it will enable GPU for usage.
As a result, you don’t need the --gpus all command.

Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.