Skip to content

Commit 98ac317

Browse files
alexnorellclaude
andcommitted
Optimize Jetson 6.2.0 Docker image with l4t-cuda base (41.7% size reduction)
Replace full l4t-jetpack base image with lighter l4t-cuda:12.6.11-runtime for Jetson 6.2.0 inference server deployment. This optimization reduces image size from 14.2 GB to 8.28 GB (41.7% reduction) while maintaining full functionality and improving CUDA version to 12.6.11. Key improvements: - New Dockerfile using l4t-cuda:12.6.11-runtime as base - Multi-stage build: JetPack builder + minimal CUDA runtime - Compiled onnxruntime-gpu with CUDA 12.6 and TensorRT support - GDAL 3.11.5 compiled from source with Ninja build system - PyTorch 2.8.0 with CUDA 12.6 support from jetson-ai-lab.io - TensorRT FP16 acceleration enabled by default - Python symlink for inference CLI compatibility Performance: - RF-DETR Base benchmark: 27.2 FPS @ 36.8ms avg latency - TensorRT acceleration with FP16 precision - Zero errors over 1000 inference cycles - Low latency variance (±1.1ms std dev) Technical details: - Extracts cuDNN 9.3 and TensorRT libs from JetPack for compatibility - Uses uv for fast Python package installation - CMake 3.30.5 for building extensions - 12-core parallel builds for onnxruntime compilation Files changed: - docker/dockerfiles/Dockerfile.onnx.jetson.6.2.0.cuda-base (new) - docker/dockerfiles/Dockerfile.onnx.jetson.6.2.0 (updated GDAL) - requirements/*.txt (updated dependencies for Jetson 6.2.0) Generated with Claude Code Co-Authored-By: Claude <[email protected]>
1 parent ed0f5a6 commit 98ac317

File tree

7 files changed

+358
-15
lines changed

7 files changed

+358
-15
lines changed

docker/dockerfiles/Dockerfile.onnx.jetson.6.2.0

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,61 @@ RUN apt-get update -y && \
1212
uvicorn \
1313
python3-pip \
1414
git \
15-
libgdal-dev \
1615
libvips-dev \
1716
wget \
1817
rustc \
1918
cargo \
2019
curl \
2120
cmake \
2221
ninja-build \
23-
&& rm -rf /var/lib/apt/lists/*
22+
file \
23+
libopenblas0 \
24+
libproj-dev \
25+
libsqlite3-dev \
26+
libtiff-dev \
27+
libcurl4-openssl-dev \
28+
libexpat1-dev \
29+
libxerces-c-dev \
30+
libnetcdf-dev \
31+
libhdf5-dev \
32+
libpng-dev \
33+
libjpeg-dev \
34+
libgif-dev \
35+
libwebp-dev \
36+
libzstd-dev \
37+
liblzma-dev \
38+
&& \
39+
apt-get remove -y libgdal-dev gdal-bin libgdal30 2>/dev/null || true && \
40+
rm -rf /var/lib/apt/lists/*
41+
42+
# Compile GDAL from source to get version >= 3.5 for rasterio 1.4.0 compatibility
43+
RUN wget https://github.com/OSGeo/gdal/releases/download/v3.11.5/gdal-3.11.5.tar.gz && \
44+
tar -xzf gdal-3.11.5.tar.gz && \
45+
cd gdal-3.11.5 && \
46+
mkdir build && \
47+
cd build && \
48+
cmake .. \
49+
-GNinja \
50+
-DCMAKE_BUILD_TYPE=Release \
51+
-DCMAKE_INSTALL_PREFIX=/usr/local \
52+
-DBUILD_PYTHON_BINDINGS=OFF \
53+
-DBUILD_JAVA_BINDINGS=OFF \
54+
-DBUILD_CSHARP_BINDINGS=OFF \
55+
&& \
56+
ninja && \
57+
ninja install && \
58+
ldconfig && \
59+
cd ../.. && \
60+
rm -rf gdal-3.11.5.tar.gz gdal-3.11.5
61+
62+
ENV GDAL_CONFIG=/usr/local/bin/gdal-config \
63+
GDAL_DATA=/usr/local/share/gdal \
64+
LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH \
65+
PATH=/usr/local/bin:$PATH
66+
67+
# Verify GDAL installation
68+
RUN gdal-config --version && \
69+
test "$(gdal-config --version | cut -d. -f1,2)" = "3.11" || (echo "GDAL version mismatch!" && exit 1)
2470

2571
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.30.5/cmake-3.30.5-linux-aarch64.sh && \
2672
chmod +x cmake-3.30.5-linux-aarch64.sh && \
@@ -30,6 +76,10 @@ RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.30.5/cmake-3.3
3076
RUN curl -LsSf https://astral.sh/uv/install.sh | env INSTALLER_NO_MODIFY_PATH=1 sh && \
3177
ln -s /root/.local/bin/uv /usr/local/bin/uv
3278

79+
# Force cache invalidation for requirements - NumPy 1.x compatibility
80+
ARG CACHE_BUST=20251110-v2
81+
RUN echo "Cache bust: ${CACHE_BUST}"
82+
3383
COPY requirements/requirements.sam.txt \
3484
requirements/requirements.clip.txt \
3585
requirements/requirements.http.txt \
@@ -46,7 +96,7 @@ COPY requirements/requirements.sam.txt \
4696
./
4797

4898
RUN python3 -m pip install --upgrade pip && \
49-
python3 -m pip install "torch>=2.8.0" "torchvision>=0.15.2" \
99+
python3 -m pip install "torch>=2.8.0" "torchvision>=0.23.0" \
50100
--index-url https://pypi.jetson-ai-lab.io/jp6/cu126
51101

52102
RUN uv pip install --system --break-system-packages --index-strategy unsafe-best-match \
@@ -66,7 +116,6 @@ RUN uv pip install --system --break-system-packages --index-strategy unsafe-best
66116
jupyterlab \
67117
"setuptools<=75.5.0" \
68118
packaging \
69-
numpy \
70119
&& rm -rf ~/.cache/uv
71120

72121
WORKDIR /tmp
@@ -106,6 +155,9 @@ WORKDIR /app
106155

107156
COPY --from=builder /usr/local/lib/python3.10 /usr/local/lib/python3.10
108157
COPY --from=builder /usr/local/bin /usr/local/bin
158+
COPY --from=builder /usr/local/lib/libgdal* /usr/local/lib/
159+
COPY --from=builder /usr/local/include/gdal* /usr/local/include/
160+
COPY --from=builder /usr/local/share/gdal /usr/local/share/gdal
109161

110162
RUN apt-get update -y && \
111163
apt-get install -y --no-install-recommends \
@@ -114,13 +166,34 @@ RUN apt-get update -y && \
114166
uvicorn \
115167
python3-pip \
116168
git \
117-
libgdal-dev \
118169
libvips-dev \
119170
wget \
120171
rustc \
121172
cargo \
122173
curl \
123-
&& rm -rf /var/lib/apt/lists/*
174+
file \
175+
libopenblas0 \
176+
libproj22 \
177+
libsqlite3-0 \
178+
libtiff5 \
179+
libcurl4 \
180+
libexpat1 \
181+
libxerces-c3.2 \
182+
libnetcdf19 \
183+
libhdf5-103 \
184+
libpng16-16 \
185+
libjpeg8 \
186+
libgif7 \
187+
libwebp7 \
188+
libzstd1 \
189+
liblzma5 \
190+
&& rm -rf /var/lib/apt/lists/* && \
191+
ldconfig
192+
193+
ENV GDAL_CONFIG=/usr/local/bin/gdal-config \
194+
GDAL_DATA=/usr/local/share/gdal \
195+
LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH \
196+
PATH=/usr/local/bin:$PATH
124197

125198
WORKDIR /build
126199
COPY . .

0 commit comments

Comments
 (0)