diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index ee1d220c6f..17213931f8 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -117,6 +117,9 @@ jobs: if: github.event_name == 'push' || (github.event.inputs.dockerfile == matrix.dockerfile && github.event.inputs.push == 'true') run: | docker push ultralytics/ultralytics:${{ matrix.tags }} + if [[ "${{ matrix.tags }}" == "latest" ]]; then + t=ultralytics/ultralytics:latest-runner && sudo docker build -f docker/Dockerfile-runner -t $t . && sudo docker push $t + fi - name: Notify on failure if: github.event_name == 'push' && failure() # do not notify on cancelled() as cancelling is performed by hand diff --git a/docker/Dockerfile-runner b/docker/Dockerfile-runner new file mode 100644 index 0000000000..35f8713071 --- /dev/null +++ b/docker/Dockerfile-runner @@ -0,0 +1,37 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds GitHub actions CI runner image for deployment to DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Image is CUDA-optimized for YOLOv8 single/multi-GPU training and inference tests + +# Start FROM Ultralytics GPU image +FROM ultralytics/ultralytics:latest + +# Set the working directory +WORKDIR /actions-runner + +# Download and unpack the latest runner +RUN curl -o actions-runner-linux-x64-2.308.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.308.0/actions-runner-linux-x64-2.308.0.tar.gz && \ + tar xzf actions-runner-linux-x64-2.308.0.tar.gz && \ + rm actions-runner-linux-x64-2.308.0.tar.gz + +# Install runner dependencies +ENV RUNNER_ALLOW_RUNASROOT=1 +ENV DEBIAN_FRONTEND=noninteractive +RUN ./bin/installdependencies.sh && \ + apt-get -y install libicu-dev + +# Inline ENTRYPOINT command to configure and start runner with default TOKEN and NAME +ENTRYPOINT sh -c './config.sh --url https://github.com/ultralytics/ultralytics \ + --token ${GITHUB_RUNNER_TOKEN:-TOKEN} \ + --name ${GITHUB_RUNNER_NAME:-NAME} \ + --labels gpu-latest \ + --replace && \ + ./run.sh' + + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest-runner && sudo docker build -f docker/Dockerfile-runner -t $t . && sudo docker push $t + +# Pull and Run in detached mode with access to GPUs 0 and 1 +# t=ultralytics/ultralytics:latest-runner && sudo docker run -d -e GITHUB_RUNNER_TOKEN=TOKEN -e GITHUB_RUNNER_NAME=NAME --ipc=host --gpus '"device=0,1"' $t diff --git a/tests/test_cuda.py b/tests/test_cuda.py index ed6455676d..3585715b29 100644 --- a/tests/test_cuda.py +++ b/tests/test_cuda.py @@ -27,7 +27,7 @@ def test_checks(): @pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available') def test_train(): - device = 0 if CUDA_DEVICE_COUNT < 2 else [0, 1] + device = 0 if CUDA_DEVICE_COUNT == 1 else [0, 1] YOLO(MODEL).train(data=DATA, imgsz=64, epochs=1, batch=-1, device=device) # also test AutoBatch, requires imgsz>=64