Skip to content

Commit

Permalink
Add Dockerfile-runner for CI actions runner images (ultralytics#4595)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored Aug 27, 2023
1 parent 2567b28 commit bd96c08
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions docker/Dockerfile-runner
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit bd96c08

Please sign in to comment.