@@ -30,7 +30,8 @@ RUN <<EOF
3030 --exclude torchaudio \
3131 --exclude tensorrt \
3232 --exclude torch2trt \
33- --exclude pycuda
33+ --exclude pycuda \
34+ --exclude nvidia-pyindex
3435 ) > /requirements.l4t-base-image.txt
3536
3637 # ....Builder sanity check.....................................................................
@@ -103,37 +104,6 @@ COPY --from=base-image / /
103104#COPY --from=base-image /opt /opt
104105#COPY --from=base-image ${ROS_ROOT} ${ROS_ROOT}
105106
106- RUN <<EOF
107- echo "(deb) Install basic utilities..."
108-
109- # ....Setup Sources............................................................................
110- {
111- apt-get update \
112- && apt-get install --assume-yes --no-install-recommends \
113- software-properties-common \
114- && add-apt-repository --yes universe \
115- && apt-get update;
116- } || exit 1
117-
118- apt-get install --assume-yes --no-install-recommends \
119- curl \
120- pkg-config \
121- lsb-release \
122- || exit 1
123-
124- echo "Log build time environment variable..."
125- printenv
126-
127- # Update symlink to point to system python3 instead of system python2
128- update-alternatives --install /usr/bin/python python /usr/bin/python3 1 || exit 1
129- update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 || exit 1
130-
131- # ....Teardown.................................................................................
132- apt-get autoremove --assume-yes
133- apt-get clean
134- rm -rf /var/lib/apt/lists/*
135- EOF
136-
137107# ....Transfer environment variable from base-images...............................................
138108# Env var specific to 'nvcr.io/nvidia/l4t-jetpack' base images
139109ARG CUDA_HOME
@@ -192,6 +162,37 @@ ENV NVCC_PATH=${NVCC_PATH}
192162ENV CUDA_NVCC_EXECUTABLE=${CUDA_NVCC_EXECUTABLE}
193163ENV CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES}
194164
165+ RUN <<EOF
166+ echo "Log build time environment variable..."
167+ printenv
168+
169+ echo "(deb) Install basic utilities..."
170+
171+ # ....Setup Sources............................................................................
172+ {
173+ apt-get update \
174+ && apt-get install --assume-yes --no-install-recommends \
175+ software-properties-common \
176+ && add-apt-repository --yes universe \
177+ && apt-get update;
178+ } || exit 1
179+
180+ apt-get install --assume-yes --no-install-recommends \
181+ curl \
182+ pkg-config \
183+ lsb-release \
184+ || exit 1
185+
186+ # Update symlink to point to system python3 instead of system python2
187+ update-alternatives --install /usr/bin/python python /usr/bin/python3 1 || exit 1
188+ update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 || exit 1
189+
190+ # ....Teardown.................................................................................
191+ apt-get autoremove --assume-yes
192+ apt-get clean
193+ rm -rf /var/lib/apt/lists/*
194+ EOF
195+
195196
196197FROM --platform=linux/amd64 ${MIMIC_DEPENDENCIES_BASE_IMAGE:?err}:${MIMIC_DEPENDENCIES_BASE_IMAGE_TAG:?err} AS base-image-amd64
197198ARG TARGETPLATFORM
@@ -209,6 +210,9 @@ SHELL ["/bin/bash", "-c"]
209210ARG UBUNTU_VERSION_MAJOR
210211
211212RUN <<EOF
213+ echo "Log build time environment variable..."
214+ printenv
215+
212216 # ....Check pre-conditions.......................................................................
213217 {
214218 test -n "${UBUNTU_VERSION_MAJOR:?'Env variable need to be set and non-empty.'}" && \
@@ -234,8 +238,6 @@ RUN <<EOF
234238 python3-dev \
235239 python3-pip
236240
237- echo "Log build time environment variable..."
238- printenv
239241
240242 IMG_RELEASE="$( source /etc/lsb-release && echo ${DISTRIB_RELEASE})"
241243 if [[ "${UBUNTU_VERSION_MAJOR:?err}.04" != "${IMG_RELEASE}" ]]; then
@@ -280,6 +282,9 @@ ENV IS_TEAMCITY_RUN=${IS_TEAMCITY_RUN:-false}
280282COPY --from=base-image /requirements.l4t-base-image.txt /requirements.l4t-base-image.txt
281283
282284RUN <<EOF
285+ echo "Log build time environment variable..."
286+ printenv
287+
283288 # ....Check pre-conditions.....................................................................
284289 {
285290 test -n "${UBUNTU_VERSION_MAJOR:?'Env variable need to be set and non-empty.'}" && \
@@ -290,9 +295,8 @@ RUN <<EOF
290295 } || { echo -e "\033[1;31m[DN error]\033[0m Failed pre-condition check" 1>&2 ; exit 1 ; }
291296
292297 # ....Reinstall l4t image package in amd64 image...............................................
293- apt-get update
294-
295298 if [[ ${TARGETPLATFORM} =~ "linux/amd64".* ]]; then
299+ apt-get update
296300
297301 echo "Install general utilities..."
298302 apt-get install --assume-yes --no-install-recommends \
@@ -327,23 +331,28 @@ RUN <<EOF
327331 fi
328332
329333 # ....Install l4t image ubuntu apt requirement.................................................
330- echo "Install l4t image ubuntu apt requirement..."
331- # Install pycuda related
332- # Build instruction: https://github.com/berlinguyinca/pycuda/blob/master/doc/source/install.rst
333- #
334- # Requirement for 'pycairo' which is required by 'pycuda'
335- apt-get install --assume-yes --no-install-recommends \
336- libcairo2-dev
334+ if [[ ${TARGETPLATFORM} =~ "linux/amd64".* ]]; then
335+ echo "Install l4t image ubuntu apt requirement..."
337336
338- # ....Install l4t image python requirement from file...........................................
339- echo "Install l4t image python requirement from file..."
340- # Requirement for 'graphsurgeon' and 'uff', it give access to nvidia pip index
341- pip3 install --no-cache-dir nvidia-pyindex
337+ echo "Log requirements.l4t-base-image.txt for debuging..."
338+ cat /requirements.l4t-base-image.txt
339+
340+ # Install pycuda related
341+ # Build instruction: https://github.com/berlinguyinca/pycuda/blob/master/doc/source/install.rst
342+ #
343+ # Requirement for 'pycairo' which is required by 'pycuda'
344+ apt-get install --assume-yes --no-install-recommends \
345+ libcairo2-dev
346+
347+ # ....Install l4t image python requirement from file...........................................
348+ echo "Install l4t image python requirement from file..."
349+ # Requirement for 'graphsurgeon' and 'uff', it give access to nvidia pip index
350+ python3 -m pip install onnx_graphsurgeon uff --extra-index-url https://pypi.ngc.nvidia.com
351+ #|| pip3 install --no-cache-dir nvidia-pyindex
342352
343- if [[ ${TARGETPLATFORM} =~ "linux/amd64".* ]]; then
344353 echo "Strip versions from requirement"
345354 sed -i.bak 's/==.*//g' /requirements.l4t-base-image.txt
346- pip3 install -r /requirements.l4t-base-image.txt || exit 1
355+ pip3 install -r /requirements.l4t-base-image.txt --extra-index-url https://pypi.ngc.nvidia.com
347356
348357 # Clean up sed tmp file
349358 rm /requirements.l4t-base-image.txt.bak
@@ -356,9 +365,8 @@ RUN <<EOF
356365 # - https://github.com/NVIDIA-AI-IOT/torch2trt
357366 # - https://github.com/dusty-nv/jetson-containers/blob/master/packages/pytorch/torch2trt/Dockerfile
358367 #
359-
360- # pip3 install git+https://github.com/NVIDIA-AI-IOT/torch2trt
361368 if [[ ${TARGETPLATFORM} =~ "linux/amd64".* ]]; then
369+ # pip3 install git+https://github.com/NVIDIA-AI-IOT/torch2trt
362370 cd /opt
363371 git clone https://github.com/NVIDIA-AI-IOT/torch2trt
364372 cd torch2trt
@@ -392,6 +400,8 @@ ARG TARGETARCH
392400ARG BUILDPLATFORM
393401
394402RUN <<EOF
403+ echo "Test final"
404+
395405 # ....Check pre-conditions.......................................................................
396406 {
397407 test -n "${TARGETPLATFORM:?'Env variable need to be set and non-empty.'}" && \
@@ -422,11 +432,11 @@ RUN <<EOF
422432
423433 if [[ ${TARGETPLATFORM} =~ "linux/arm64".* ]]; then
424434 {
425- test -n ${CUDA_HOME:?'Environment variable was not passed from base-image build stage to test stage'} && \
426- test -n ${NVIDIA_VISIBLE_DEVICES:?'Environment variable was not passed from base-image build stage to test stage'} && \
427- test -n ${NVIDIA_DRIVER_CAPABILITIES:?'Environment variable was not passed from base-image build stage to test stage'} && \
428- test -n ${PATH:?'Environment variable was not passed from base-image build stage to test stage'} && \
429- test -n ${LD_LIBRARY_PATH:?'Environment variable was not passed from base-image build stage to test stage'} ;
435+ test -n ${CUDA_HOME:?'(Final) Environment variable was not passed from base-image build stage to test stage'} && \
436+ test -n ${NVIDIA_VISIBLE_DEVICES:?'(Final) Environment variable was not passed from base-image build stage to test stage'} && \
437+ test -n ${NVIDIA_DRIVER_CAPABILITIES:?'(Final) Environment variable was not passed from base-image build stage to test stage'} && \
438+ test -n ${PATH:?'(Final) Environment variable was not passed from base-image build stage to test stage'} && \
439+ test -n ${LD_LIBRARY_PATH:?'(Final) Environment variable was not passed from base-image build stage to test stage'} ;
430440 } || { echo "Missing required environment variables!" 1>&2 ; exit 1 ; }
431441 fi
432442
0 commit comments