|
|
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
|
|
|
# Builds ultralytics/ultralytics:jetson image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
|
|
|
|
# Supports JetPack for YOLOv8 on Jetson Nano, TX1/TX2, Xavier NX, AGX Xavier, AGX Orin, and Orin NX
|
|
|
|
|
|
|
|
# Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-pytorch
|
|
|
|
FROM nvcr.io/nvidia/l4t-pytorch:r35.2.1-pth2.0-py3
|
|
|
|
|
|
|
|
# Set environment variables
|
|
|
|
ENV APP_HOME /usr/src/ultralytics
|
|
|
|
|
|
|
|
# Downloads to user config dir
|
|
|
|
ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
|
|
|
|
https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
|
|
|
|
/root/.config/Ultralytics/
|
|
|
|
|
|
|
|
# Install linux packages
|
|
|
|
# g++ required to build 'tflite_support' and 'lap' packages
|
|
|
|
# libusb-1.0-0 required for 'tflite_support' package when exporting to TFLite
|
|
|
|
# pkg-config and libhdf5-dev (not included) are needed to build 'h5py==3.11.0' aarch64 wheel required by 'tensorflow'
|
|
|
|
RUN apt update \
|
|
|
|
&& apt install --no-install-recommends -y gcc git zip curl htop libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0
|
|
|
|
|
|
|
|
# Create working directory
|
|
|
|
WORKDIR $APP_HOME
|
|
|
|
|
|
|
|
# Copy contents and assign permissions
|
|
|
|
COPY . $APP_HOME
|
|
|
|
RUN git remote set-url origin https://github.com/ultralytics/ultralytics.git
|
|
|
|
ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt $APP_HOME
|
|
|
|
|
|
|
|
# Remove opencv-python from Ultralytics dependencies as it conflicts with opencv-python installed in base image
|
|
|
|
RUN grep -v "opencv-python" pyproject.toml > temp.toml && mv temp.toml pyproject.toml
|
|
|
|
|
|
|
|
# Download onnxruntime-gpu 1.15.1 for Jetson Linux 35.2.1 (JetPack 5.1). Other versions can be seen in https://elinux.org/Jetson_Zoo#ONNX_Runtime
|
|
|
|
ADD https://nvidia.box.com/shared/static/mvdcltm9ewdy2d5nurkiqorofz1s53ww.whl onnxruntime_gpu-1.15.1-cp38-cp38-linux_aarch64.whl
|
|
|
|
|
|
|
|
# Install pip packages manually for TensorRT compatibility https://github.com/NVIDIA/TensorRT/issues/2567
|
|
|
|
RUN python3 -m pip install --upgrade pip wheel
|
|
|
|
RUN pip install onnxruntime_gpu-1.15.1-cp38-cp38-linux_aarch64.whl
|
|
|
|
RUN pip install --no-cache-dir -e ".[export]"
|
|
|
|
|
|
|
|
|
|
|
|
# Usage Examples -------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Build and Push
|
|
|
|
# t=ultralytics/ultralytics:latest-jetson && sudo docker build --platform linux/arm64 -f docker/Dockerfile-jetson -t $t . && sudo docker push $t
|
|
|
|
|
|
|
|
# Run
|
|
|
|
# t=ultralytics/ultralytics:latest-jetson && sudo docker run -it --ipc=host $t
|
|
|
|
|
|
|
|
# Pull and Run
|
|
|
|
# t=ultralytics/ultralytics:latest-jetson && sudo docker pull $t && sudo docker run -it --ipc=host $t
|
|
|
|
|
|
|
|
# Pull and Run with NVIDIA runtime
|
|
|
|
# t=ultralytics/ultralytics:latest-jetson && sudo docker pull $t && sudo docker run -it --ipc=host --runtime=nvidia $t
|