Skip to content

Commit

Permalink
Provide prebuild Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
jordimas committed Jan 6, 2025
1 parent 34da493 commit 6b3e1f0
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
39 changes: 39 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish to GitHub Container Registry

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
run: docker build -t ghcr.io/softcatala/whisper-ctranslate2:latest .

- name: Use Docker image
run: docker run -v "$(pwd)":/srv/files/ ghcr.io/softcatala/whisper-ctranslate2:latest /srv/files/e2e-tests/gossos.mp3

- name: Push Docker image
run: docker push ghcr.io/softcatala/whisper-ctranslate2:latest

# These are untagged images left behind in the Docker public registry
- name: Delete old images
run: |
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
gh api -X GET /user/packages/container/whisper-ctranslate2/versions \
| jq -r '.[] | select(.metadata.container.tags | index("latest") | not) | .id' \
| xargs -I {} gh api -X DELETE /user/packages/container/whisper-ctranslate2/versions/{}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04

RUN apt-get update && apt-get install -y python3-pip

WORKDIR /app
COPY . /app

RUN pip3 install --no-cache-dir -U .
RUN python3 -c 'from faster_whisper import WhisperModel; WhisperModel("small"); WhisperModel("medium"); WhisperModel("large-v2")'

ENTRYPOINT ["whisper-ctranslate2"]
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
.PHONY: run install-dependencies-e2e-tests run-e2e-tests run-tests publish-release dev
.PHONY: run install-dependencies-e2e-tests run-e2e-tests run-tests publish-release dev docker-build docker-run

docker-build:
docker build -t whisper-ctranslate2 . -f Dockerfile
docker image ls | grep whisper-ctranslate2

docker-run:
docker run --gpus "device=0" -v "$(shell pwd)":/srv/files/ -it --rm whisper-ctranslate2 /srv/files/e2e-tests/gossos.mp3 --output_dir /srv/files/

run:
python3 setup.py sdist bdist_wheel
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ Alternatively, if you are interested in the latest development (non-stable) vers

pip install git+https://github.com/Softcatala/whisper-ctranslate2

# Using prebuild Docker image

You can use build docker image. First pull the image:

docker pull ghcr.io/softcatala/whisper-ctranslate2:latest

The Docker image includes the small, medium" and large-v2.

To run it:

docker run --gpus "device=0" \
-v "$(pwd)":/srv/files/ \
-it ghcr.io/softcatala/whisper-ctranslate2:latest \
/srv/files/e2e-tests/gossos.mp3 \
--output_dir /srv/files/

Notes:
* _--gpus "device=0"_ gives access to the GPU. If you do not have a GPU, remove this.
* _"$(pwd)":/srv/files/_ maps your current directory to /srv/files/ inside the container

# CPU and GPU support

GPU and CPU support are provided by [CTranslate2](https://github.com/OpenNMT/CTranslate2/).
Expand Down

0 comments on commit 6b3e1f0

Please sign in to comment.