diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2910d7f..5729903 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,6 +18,13 @@ permissions: jobs: build_and_publish: runs-on: ubuntu-latest + strategy: + matrix: + include: + - docker_file: Dockerfile + label: "latest" + - docker_file: Dockerfile.cuda + label: "latest-cuda" steps: - uses: actions/checkout@v4 @@ -29,6 +36,13 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=sha,prefix=sha- + labels: | + type=raw,value=image-type=${{ matrix.label }} - uses: docker/login-action@v3 with: @@ -40,7 +54,10 @@ jobs: uses: docker/build-push-action@v5 with: context: . + file: ${{ matrix.docker_file }} push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: | + ${{ steps.meta.outputs.tags }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest${{ matrix.label =='latest-cuda' && '-cuda' || '' }} + # labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/Dockerfile.cuda b/Dockerfile.cuda new file mode 100644 index 0000000..9f6ce17 --- /dev/null +++ b/Dockerfile.cuda @@ -0,0 +1,8 @@ +FROM nvidia/cuda:12.5.0-runtime-ubuntu22.04 +WORKDIR /app +COPY . /app +RUN apt-get update && \ + apt-get install -y python3-pip && \ + pip install --upgrade pip +RUN pip install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121 +CMD ["fastapi", "run", "main.py", "--proxy-headers", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file diff --git a/README.md b/README.md index da0704d..1f8abfc 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ ## Installation - For ease of use it's recommended to use the provided [docker-compose.yml](https://github.com/doppeltilde/image_video_classification/blob/main/docker-compose.yml). -```yml -version: '3.9' +**CPU Support:** Use the `latest` tag. +```yml services: image_video_classification: image: ghcr.io/doppeltilde/image_video_classification:latest @@ -30,6 +30,33 @@ volumes: models: ``` +**NVIDIA GPU Support:** Use the `latest-cuda` tag. +```yml +services: + image_video_classification_cuda: + image: ghcr.io/doppeltilde/image_video_classification:latest-cuda + ports: + - "8000:8000" + volumes: + - models:/root/.cache/huggingface/hub:rw + environment: + - DEFAULT_ASR_MODEL_NAME + - COMPUTE_TYPE + - USE_API_KEYS + - API_KEYS + restart: unless-stopped + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [ gpu ] + +volumes: + models: +``` + - Create a `.env` file and set the preferred values. ```sh DEFAULT_MODEL_NAME=Falconsai/nsfw_image_detection