Skip to content

Commit 1a30e04

Browse files
authored
Add workflows for dev, nightly, and release Docker containers (#2153)
* initial builds for docker containers; release, dev and nightly * update intsallation * add torch cuda to all dockerfiles * update checks for release workflows * get version number * update dockerfiles to use updated cuda base image; bump up torch and torchvision to be compatible with vllm * fix typo * cleanup; update release file * update runner to use self-hosted runner * update runner * revert back to provided ubuntu runner
1 parent 121d7fe commit 1a30e04

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed

.github/workflows/build-container.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build Docker Container
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
branches:
6+
- main
7+
- 'release/[0-9]+.[0-9]+'
8+
push:
9+
branches:
10+
- 'main'
11+
release:
12+
types: [created, published]
13+
schedule:
14+
- cron: '0 2 * * *'
15+
16+
# TODO: docker containers created through a release cut vs PR to the release branch
17+
# will be pushed to different locations (i.e one will be sparseml the other will be test-sparseml).
18+
# These containers rely on the new internal pypi server being enabled. Once enabled,
19+
# this workflow can be expanded to make this distinction.
20+
env:
21+
RELEASE: ${{ github.event_name =='release' || (startsWith(github.base_ref, 'release/') && github.event_name == 'pull_request')}}
22+
DEV: ${{ github.base_ref == 'main' && github.event_name == 'pull_request'}}
23+
NAME: ${{ github.event.number }}
24+
25+
permissions:
26+
contents: read
27+
packages: write
28+
29+
jobs:
30+
build-container:
31+
name: Build sparseml container
32+
runs-on: ubuntu-20.04
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v3
36+
with:
37+
fetch-depth: 1
38+
- name: Set up Docker Buildx
39+
id: buildx
40+
uses: docker/setup-buildx-action@v2
41+
with:
42+
buildkitd-flags: --debug
43+
- name: Get current date
44+
id: date
45+
run: echo "::set-output name=date::$(date +'%Y%m%d')"
46+
- name: Get the current version
47+
if: ${{ env.RELEASE == 'true' }}
48+
id: version
49+
run: echo "::set-output name=version::$(echo ${{ github.base_ref }} | cut -c 9-15)"
50+
- name: Login to Github Packages
51+
uses: docker/login-action@v2
52+
with:
53+
registry: ghcr.io
54+
username: ${{ github.actor }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
- name: Build Dev Docker Container
57+
if: ${{ env.DEV == 'true' }}
58+
uses: docker/build-push-action@v4
59+
with:
60+
context: ./docker/containers/docker_dev
61+
build-args: |
62+
BRANCH=${{github.head_ref}}
63+
push: true
64+
tags: ghcr.io/neuralmagic/sparseml-dev:${{ env.NAME }}
65+
- name: Build Release Docker Container
66+
if: ${{ env.RELEASE == 'true' }}
67+
uses: docker/build-push-action@v4
68+
with:
69+
context: ./docker/containers/docker_release
70+
build-args: |
71+
VERSION=${{ steps.version.outputs.version }}
72+
push: true
73+
tags: ghcr.io/neuralmagic/test-sparseml:latest, ghcr.io/neuralmagic/test-sparseml:${{ steps.version.outputs.version }}
74+
- name: Build Nightly Docker Container
75+
if: ${{ env.DEV == 'false' && env.RELEASE == 'false'}}
76+
uses: docker/build-push-action@v4
77+
with:
78+
context: ./docker/containers/docker_nightly
79+
push: true
80+
tags: ghcr.io/neuralmagic/test-sparseml-nightly:latest, ghcr.io/neuralmagic/test-sparseml-nightly:${{ steps.date.outputs.date }}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ARG SOURCE=ghcr.io/neuralmagic/cuda-python3.10
2+
3+
ARG TORCH_VERSION=2.1.2
4+
ARG TORCHVISION_VERSION=0.16.2
5+
ARG CUDA=121
6+
ARG BRANCH
7+
8+
FROM $SOURCE
9+
10+
ARG BRANCH
11+
12+
RUN python3.10 -m pip install --upgrade pip \
13+
&& python3.10 -m pip install --upgrade setuptools
14+
15+
ARG CUDA
16+
ARG TORCH_VERSION
17+
ARG TORCHVISION_VERSION
18+
19+
RUN python3.10 -m pip install torch==${TORCH_VERSION}+cu${CUDA} torchvision==${TORCHVISION_VERSION}+cu${CUDA} -f https://download.pytorch.org/whl/torch_stable.html \
20+
&& git clone https://github.com/neuralmagic/sparseml.git --depth 1 --single-branch -b ${BRANCH} \
21+
&& python3.10 -m pip install -e "./sparseml[dev]"
22+
23+
HEALTHCHECK CMD python3.10 -c 'import sparseml'
24+
RUN python3.10 -m pip list | grep sparseml
25+
CMD bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ARG SOURCE=ghcr.io/neuralmagic/cuda-python3.10
2+
3+
ARG TORCH_VERSION=2.1.2
4+
ARG TORCHVISION_VERSION=0.16.2
5+
ARG CUDA=121
6+
7+
FROM $SOURCE
8+
9+
RUN python3.10 -m pip install --upgrade pip \
10+
&& python3.10 -m pip install --upgrade setuptools
11+
12+
ARG CUDA
13+
ARG TORCH_VERSION
14+
ARG TORCHVISION_VERSION
15+
16+
RUN python3.10 -m pip install torch==${TORCH_VERSION}+cu${CUDA} torchvision==${TORCHVISION_VERSION}+cu${CUDA} -f https://download.pytorch.org/whl/torch_stable.html \
17+
&& python3.10 -m pip install --no-cache-dir "sparseml-nightly[onnxruntime,torchvision,transformers,yolov5,ultralytics]"
18+
19+
HEALTHCHECK CMD python3.10 -c 'import sparseml'
20+
RUN python3.10 -m pip list | grep sparseml
21+
CMD bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ARG SOURCE=ghcr.io/neuralmagic/cuda-python3.10
2+
3+
ARG TORCH_VERSION=2.1.2
4+
ARG TORCHVISION_VERSION=0.16.2
5+
ARG CUDA=121
6+
ARG VERSION
7+
8+
FROM $SOURCE
9+
10+
ARG VERSION
11+
12+
ARG CUDA
13+
ARG TORCH_VERSION
14+
ARG TORCHVISION_VERSION
15+
16+
RUN python3.10 -m pip install --upgrade pip \
17+
&& python3.10 -m pip install --upgrade setuptools
18+
19+
RUN python3.10 -m pip install torch==${TORCH_VERSION}+cu${CUDA} torchvision==${TORCHVISION_VERSION}+cu${CUDA} -f https://download.pytorch.org/whl/torch_stable.html \
20+
&& python3.10 -m pip install --no-cache-dir "sparseml[onnxruntime,torchvision,transformers,yolov5,ultralytics]==$VERSION"
21+
22+
HEALTHCHECK CMD python3.10 -c 'import sparseml'
23+
RUN python3.10 -m pip list | grep sparseml
24+
CMD bash

0 commit comments

Comments
 (0)