Dockerfile-jetson-jetpack4 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Ultralytics YOLO 🚀, AGPL-3.0 license
  2. # Builds ultralytics/ultralytics:jetson-jetpack4 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
  3. # Supports JetPack4.x for YOLOv8 on Jetson Nano, TX2, Xavier NX, AGX Xavier
  4. # Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-cuda
  5. FROM nvcr.io/nvidia/l4t-cuda:10.2.460-runtime
  6. # Set environment variables
  7. ENV APP_HOME /usr/src/ultralytics
  8. # Downloads to user config dir
  9. ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
  10. https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
  11. /root/.config/Ultralytics/
  12. # Add NVIDIA repositories for TensorRT dependencies
  13. RUN wget -q -O - https://repo.download.nvidia.com/jetson/jetson-ota-public.asc | apt-key add - && \
  14. echo "deb https://repo.download.nvidia.com/jetson/common r32.7 main" > /etc/apt/sources.list.d/nvidia-l4t-apt-source.list && \
  15. echo "deb https://repo.download.nvidia.com/jetson/t194 r32.7 main" >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
  16. # Install dependencies
  17. RUN apt update && \
  18. apt install --no-install-recommends -y git python3.8 python3.8-dev python3-pip python3-libnvinfer libopenmpi-dev libopenblas-base libomp-dev gcc
  19. # Create symbolic links for python3.8 and pip3
  20. RUN ln -sf /usr/bin/python3.8 /usr/bin/python3
  21. RUN ln -s /usr/bin/pip3 /usr/bin/pip
  22. # Create working directory
  23. WORKDIR $APP_HOME
  24. # Copy contents and assign permissions
  25. COPY . $APP_HOME
  26. RUN chown -R root:root $APP_HOME
  27. ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt $APP_HOME
  28. # Download onnxruntime-gpu, TensorRT, PyTorch and Torchvision
  29. # Other versions can be seen in https://elinux.org/Jetson_Zoo and https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048
  30. ADD https://nvidia.box.com/shared/static/gjqofg7rkg97z3gc8jeyup6t8n9j8xjw.whl onnxruntime_gpu-1.8.0-cp38-cp38-linux_aarch64.whl
  31. ADD https://forums.developer.nvidia.com/uploads/short-url/hASzFOm9YsJx6VVFrDW1g44CMmv.whl tensorrt-8.2.0.6-cp38-none-linux_aarch64.whl
  32. ADD https://github.com/ultralytics/yolov5/releases/download/v1.0/torch-1.11.0a0+gitbc2c6ed-cp38-cp38-linux_aarch64.whl \
  33. torch-1.11.0a0+gitbc2c6ed-cp38-cp38-linux_aarch64.whl
  34. ADD https://github.com/ultralytics/yolov5/releases/download/v1.0/torchvision-0.12.0a0+9b5a3fe-cp38-cp38-linux_aarch64.whl \
  35. torchvision-0.12.0a0+9b5a3fe-cp38-cp38-linux_aarch64.whl
  36. # Install pip packages
  37. RUN python3 -m pip install --upgrade pip wheel
  38. RUN pip install onnxruntime_gpu-1.8.0-cp38-cp38-linux_aarch64.whl tensorrt-8.2.0.6-cp38-none-linux_aarch64.whl \
  39. torch-1.11.0a0+gitbc2c6ed-cp38-cp38-linux_aarch64.whl torchvision-0.12.0a0+9b5a3fe-cp38-cp38-linux_aarch64.whl
  40. RUN pip install --no-cache-dir -e ".[export]"
  41. # Usage Examples -------------------------------------------------------------------------------------------------------
  42. # Build and Push
  43. # t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-jetson-jetpack4 -t $t . && sudo docker push $t
  44. # Run
  45. # t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker run -it --ipc=host $t
  46. # Pull and Run
  47. # t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker pull $t && sudo docker run -it --ipc=host $t
  48. # Pull and Run with NVIDIA runtime
  49. # t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker pull $t && sudo docker run -it --ipc=host --runtime=nvidia $t