From 8bfac796e6bbff1f71dcf75032b7236437231eb4 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 6 Aug 2024 18:21:48 +0200 Subject: [PATCH] Fix Docker git permissions (#14995) Signed-off-by: Glenn Jocher --- docker/Dockerfile | 16 ++++++++++------ docker/Dockerfile-arm64 | 15 +++++++++------ docker/Dockerfile-conda | 6 ++++++ docker/Dockerfile-cpu | 17 ++++++++++------- docker/Dockerfile-jetson-jetpack4 | 12 ++++++++---- docker/Dockerfile-jetson-jetpack5 | 14 ++++++++++---- docker/Dockerfile-jetson-jetpack6 | 14 ++++++++++---- docker/Dockerfile-python | 17 ++++++++++------- docker/Dockerfile-runner | 12 +++++++++--- 9 files changed, 82 insertions(+), 41 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index cdba060cad..44c84b0021 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,7 +7,11 @@ FROM pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime # Set environment variables # Avoid DDP error "MKL_THREADING_LAYER=INTEL is incompatible with libgomp.so.1 library" https://github.com/pytorch/pytorch/issues/37377 -ENV MKL_THREADING_LAYER=GNU +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 \ + MKL_THREADING_LAYER=GNU # Downloads to user config dir ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ @@ -27,24 +31,24 @@ RUN apt upgrade --no-install-recommends -y openssl tar # Create working directory WORKDIR /ultralytics -# Copy contents and assign permissions +# Copy contents and configure git COPY . . -RUN git remote set-url origin https://github.com/ultralytics/ultralytics.git +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . # Install pip packages RUN python3 -m pip install --upgrade pip wheel # Pin TensorRT-cu12==10.1.0 to avoid 10.2.0 bug https://github.com/ultralytics/ultralytics/pull/14239 (note -cu12 must be used) -RUN pip install --no-cache-dir -e ".[export]" "tensorrt-cu12==10.1.0" "albumentations>=1.4.6" comet pycocotools +RUN pip install -e ".[export]" "tensorrt-cu12==10.1.0" "albumentations>=1.4.6" comet pycocotools # Run exports to AutoInstall packages # Edge TPU export fails the first time so is run twice here RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32 || yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32 RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32 # Requires <= Python 3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991 -RUN pip install --no-cache-dir "paddlepaddle>=2.6.0" x2paddle +RUN pip install "paddlepaddle>=2.6.0" x2paddle # Fix error: `np.bool` was a deprecated alias for the builtin `bool` segmentation error in Tests -RUN pip install --no-cache-dir numpy==1.23.5 +RUN pip install numpy==1.23.5 # Remove exported models RUN rm -rf tmp diff --git a/docker/Dockerfile-arm64 b/docker/Dockerfile-arm64 index 179ea7eb20..7eeade1024 100644 --- a/docker/Dockerfile-arm64 +++ b/docker/Dockerfile-arm64 @@ -6,6 +6,12 @@ # Start FROM Debian image for arm64v8 https://hub.docker.com/r/arm64v8/debian (new) FROM arm64v8/debian:bookworm-slim +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + # 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 \ @@ -20,17 +26,14 @@ RUN apt update \ # Create working directory WORKDIR /ultralytics -# Copy contents and assign permissions +# Copy contents and configure git COPY . . -RUN git remote set-url origin https://github.com/ultralytics/ultralytics.git +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . -# Remove python3.11/EXTERNALLY-MANAGED to avoid 'externally-managed-environment' issue, Debian 12 Bookworm error -RUN rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED - # Install pip packages RUN python3 -m pip install --upgrade pip wheel -RUN pip install --no-cache-dir -e ".[export]" +RUN pip install -e ".[export]" # Creates a symbolic link to make 'python' point to 'python3' RUN ln -sf /usr/bin/python3 /usr/bin/python diff --git a/docker/Dockerfile-conda b/docker/Dockerfile-conda index 305e6d1c2d..c6a31f1cc0 100644 --- a/docker/Dockerfile-conda +++ b/docker/Dockerfile-conda @@ -5,6 +5,12 @@ # Start FROM miniconda3 image https://hub.docker.com/r/continuumio/miniconda3 FROM continuumio/miniconda3:latest +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + # 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 \ diff --git a/docker/Dockerfile-cpu b/docker/Dockerfile-cpu index 054aee6be3..fcd5336ece 100644 --- a/docker/Dockerfile-cpu +++ b/docker/Dockerfile-cpu @@ -5,6 +5,12 @@ # Start FROM Ubuntu image https://hub.docker.com/_/ubuntu FROM ubuntu:23.10 +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + # 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 \ @@ -18,23 +24,20 @@ RUN apt update \ # Create working directory WORKDIR /ultralytics -# Copy contents (previously used git clone to avoid permission errors) +# Copy contents and configure git COPY . . -RUN git remote set-url origin https://github.com/ultralytics/ultralytics.git +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . -# Remove python3.11/EXTERNALLY-MANAGED or use 'pip install --break-system-packages' avoid 'externally-managed-environment' Ubuntu nightly error -RUN rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED - # Install pip packages RUN python3 -m pip install --upgrade pip wheel -RUN pip install --no-cache-dir -e ".[export]" --extra-index-url https://download.pytorch.org/whl/cpu +RUN pip install -e ".[export]" --extra-index-url https://download.pytorch.org/whl/cpu # Run exports to AutoInstall packages RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32 RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32 # Requires Python<=3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991 -# RUN pip install --no-cache-dir "paddlepaddle>=2.6.0" x2paddle +# RUN pip install "paddlepaddle>=2.6.0" x2paddle # Remove exported models RUN rm -rf tmp diff --git a/docker/Dockerfile-jetson-jetpack4 b/docker/Dockerfile-jetson-jetpack4 index dadf4513c4..ca238b9676 100644 --- a/docker/Dockerfile-jetson-jetpack4 +++ b/docker/Dockerfile-jetson-jetpack4 @@ -5,6 +5,10 @@ # Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-cuda FROM nvcr.io/nvidia/l4t-cuda:10.2.460-runtime +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 + # 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 \ @@ -26,9 +30,9 @@ RUN ln -s /usr/bin/pip3 /usr/bin/pip # Create working directory WORKDIR /ultralytics -# Copy contents and assign permissions +# Copy contents and configure git COPY . . -RUN chown -R root:root . +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . # Download onnxruntime-gpu 1.8.0 and tensorrt 8.2.0.6 @@ -38,12 +42,12 @@ ADD https://forums.developer.nvidia.com/uploads/short-url/hASzFOm9YsJx6VVFrDW1g4 # Install pip packages RUN python3 -m pip install --upgrade pip wheel -RUN pip install --no-cache-dir \ +RUN pip install \ onnxruntime_gpu-1.8.0-cp38-cp38-linux_aarch64.whl \ tensorrt-8.2.0.6-cp38-none-linux_aarch64.whl \ https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-1.11.0a0+gitbc2c6ed-cp38-cp38-linux_aarch64.whl \ https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.12.0a0+9b5a3fe-cp38-cp38-linux_aarch64.whl -RUN pip install --no-cache-dir -e ".[export]" +RUN pip install -e ".[export]" RUN rm *.whl # Usage Examples ------------------------------------------------------------------------------------------------------- diff --git a/docker/Dockerfile-jetson-jetpack5 b/docker/Dockerfile-jetson-jetpack5 index 07e81ab791..9ec2e64a06 100644 --- a/docker/Dockerfile-jetson-jetpack5 +++ b/docker/Dockerfile-jetson-jetpack5 @@ -5,6 +5,12 @@ # 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 PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + # 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 \ @@ -20,13 +26,13 @@ RUN apt update \ # Create working directory WORKDIR /ultralytics -# Copy contents and assign permissions +# Copy contents and configure git COPY . . -RUN git remote set-url origin https://github.com/ultralytics/ultralytics.git +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . # 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 +RUN sed -i '/opencv-python/d' 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 @@ -34,7 +40,7 @@ ADD https://nvidia.box.com/shared/static/mvdcltm9ewdy2d5nurkiqorofz1s53ww.whl on # 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]" +RUN pip install -e ".[export]" RUN rm *.whl diff --git a/docker/Dockerfile-jetson-jetpack6 b/docker/Dockerfile-jetson-jetpack6 index 7d3d09468d..3b53c31d41 100644 --- a/docker/Dockerfile-jetson-jetpack6 +++ b/docker/Dockerfile-jetson-jetpack6 @@ -5,6 +5,12 @@ # Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-jetpack FROM nvcr.io/nvidia/l4t-jetpack:r36.3.0 +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + # 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 \ @@ -17,9 +23,9 @@ RUN apt update && \ # Create working directory WORKDIR /ultralytics -# Copy contents and assign permissions +# Copy contents and configure git COPY . . -RUN chown -R root:root . +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . # Download onnxruntime-gpu 1.18.0 from https://elinux.org/Jetson_Zoo and https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048 @@ -27,11 +33,11 @@ ADD https://nvidia.box.com/shared/static/48dtuob7meiw6ebgfsfqakc9vse62sg4.whl on # Pip install onnxruntime-gpu, torch, torchvision and ultralytics RUN python3 -m pip install --upgrade pip wheel -RUN pip install --no-cache-dir \ +RUN pip install \ onnxruntime_gpu-1.18.0-cp310-cp310-linux_aarch64.whl \ https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-2.3.0-cp310-cp310-linux_aarch64.whl \ https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.18.0a0+6043bc2-cp310-cp310-linux_aarch64.whl -RUN pip install --no-cache-dir -e ".[export]" +RUN pip install -e ".[export]" RUN rm *.whl # Usage Examples ------------------------------------------------------------------------------------------------------- diff --git a/docker/Dockerfile-python b/docker/Dockerfile-python index ffecbab9c0..f8a8611c4c 100644 --- a/docker/Dockerfile-python +++ b/docker/Dockerfile-python @@ -5,6 +5,12 @@ # Use the official Python 3.10 slim-bookworm as base image FROM python:3.10-slim-bookworm +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + # 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 \ @@ -18,23 +24,20 @@ RUN apt update \ # Create working directory WORKDIR /ultralytics -# Copy contents and assign permissions +# Copy contents and configure git COPY . . -RUN git remote set-url origin https://github.com/ultralytics/ultralytics.git +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . -# Remove python3.11/EXTERNALLY-MANAGED or use 'pip install --break-system-packages' avoid 'externally-managed-environment' Ubuntu nightly error -# RUN rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED - # Install pip packages RUN python3 -m pip install --upgrade pip wheel -RUN pip install --no-cache-dir -e ".[export]" --extra-index-url https://download.pytorch.org/whl/cpu +RUN pip install -e ".[export]" --extra-index-url https://download.pytorch.org/whl/cpu # Run exports to AutoInstall packages RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32 RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32 # Requires Python<=3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991 -RUN pip install --no-cache-dir "paddlepaddle>=2.6.0" x2paddle +RUN pip install "paddlepaddle>=2.6.0" x2paddle # Remove exported models RUN rm -rf tmp diff --git a/docker/Dockerfile-runner b/docker/Dockerfile-runner index 8c7bd40e12..8f01477252 100644 --- a/docker/Dockerfile-runner +++ b/docker/Dockerfile-runner @@ -5,6 +5,14 @@ # Start FROM Ultralytics GPU image FROM ultralytics/ultralytics:latest +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 \ + RUNNER_ALLOW_RUNASROOT=1 \ + DEBIAN_FRONTEND=noninteractive + # Set the working directory WORKDIR /actions-runner @@ -15,9 +23,7 @@ RUN FILENAME=actions-runner-linux-x64-2.317.0.tar.gz && \ rm $FILENAME # Install runner dependencies -ENV RUNNER_ALLOW_RUNASROOT=1 -ENV DEBIAN_FRONTEND=noninteractive -RUN pip install --no-cache-dir pytest-cov +RUN pip install pytest-cov RUN ./bin/installdependencies.sh && \ apt-get -y install libicu-dev