diff --git a/.github/workflows/build-container-image.yml b/.github/workflows/build-container-image.yml new file mode 100644 index 0000000..760d0a5 --- /dev/null +++ b/.github/workflows/build-container-image.yml @@ -0,0 +1,84 @@ +name: Build container image +on: + push: + workflow_dispatch: + +env: + GITHUB_REPOSITORY_NAME_PART_SLUG_URL: '' # filled by rlespinasse/github-slug-action@v5 + REGISTRY_USER: ${{ github.actor }} + REGISTRY_PASSWORD: ${{ github.token }} + +jobs: + push-ghcr: + name: Build and push image + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Inject enhanced GitHub environment variables + uses: rlespinasse/github-slug-action@v5 # https://github.com/rlespinasse/github-slug-action + - name: lowercase IMAGE_REGISTRY + run: | + echo "IMAGE_REGISTRY=ghcr.io/${GITHUB_REPOSITORY_OWNER_PART_SLUG@L}" >> "${GITHUB_ENV}" + - name: Clear space + run: | + df -h / + sudo rm -rf \ + "$AGENT_TOOLSDIRECTORY" \ + /opt/google/chrome \ + /opt/microsoft/msedge \ + /opt/microsoft/powershell \ + /opt/pipx \ + /usr/lib/mono \ + /usr/local/julia* \ + /usr/local/lib/android \ + /usr/local/lib/node_modules \ + /usr/local/share/chromium \ + /usr/local/share/powershell \ + /usr/share/dotnet \ + /usr/share/swift + df -h / + # Determine tags using Docker Metadata action https://github.com/docker/metadata-action + - name: Docker Metadata + id: docker-metadata + uses: docker/metadata-action@v5 + with: + tags: | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + type=edge + type=sha + type=ref,event=branch + type=ref,event=pr + type=schedule + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + # Build image using Buildah action https://github.com/redhat-actions/buildah-build + - name: Build Image + id: build_image + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }} + tags: ${{ steps.docker-metadata.outputs.tags }} + containerfiles: | + ./Dockerfile + oci: true + layers: true + labels: | + ${{ steps.docker-metadata.outputs.labels }} + # Push the image to GHCR (Image Registry) https://github.com/redhat-actions/push-to-registry + - name: Push To Registry + uses: redhat-actions/push-to-registry@v2 + id: push + with: + image: ${{ steps.build_image.outputs.image }} + tags: ${{ steps.build_image.outputs.tags }} + registry: ${{ env.IMAGE_REGISTRY }} + username: ${{ env.REGISTRY_USER }} + password: ${{ env.REGISTRY_PASSWORD }} + extra-args: | + --disable-content-trust + - name: Echo outputs + run: | + echo "${{ toJSON(steps.push.outputs) }}" \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index a5a54cd..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: docker - -on: - push: - branches: - - 'main' - -jobs: - docker: - environment: docker - runs-on: ubuntu-latest - steps: - - name: Delete huge unnecessary tools folder - run: rm -rf /opt/hostedtoolcache - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 - with: - push: true - tags: rakuri255/ultrasinger:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ed33e07..d39388c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,12 @@ FROM nvidia/cuda:12.6.3-runtime-ubuntu22.04 # note: the python3-pip package contains Python 3.10 on Ubuntu 22.04 RUN apt-get update \ - && apt-get install git python3-pip python3.10-venv ffmpeg curl -y \ + && apt-get install git python3-pip python3.10-venv ffmpeg -y \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY . /app/UltraSinger +# copy only the requirements file to leverage container image build cache +COPY ./requirements.txt /app/UltraSinger/requirements.txt WORKDIR /app/UltraSinger # no need to run as root @@ -23,5 +24,7 @@ RUN pip install --no-cache-dir -r requirements.txt \ && pip install --no-cache-dir torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu121 \ && pip install --no-cache-dir tensorflow[and-cuda]==2.16.1 +# copy sources late to allow for caching of layers which contain all the dependencies +COPY . /app/UltraSinger WORKDIR /app/UltraSinger/src CMD ["bash" ] diff --git a/README.md b/README.md index 5137b9f..bef269f 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,6 @@ TensorFlow dropped GPU support for Windows for versions >2.10 as you can see in For now UltraSinger runs the latest version available that still supports GPUs on windows. For running later versions of TensorFlow on windows while still taking advantage of GPU support the suggested solution is to [run UltraSinger in a container](container/README.md). - #### Crashes due to low VRAM If something crashes because of low VRAM then use a smaller model. diff --git a/container/podman.md b/container/podman.md index b5c6207..c842de2 100644 --- a/container/podman.md +++ b/container/podman.md @@ -7,9 +7,11 @@ ```commandline git clone https://github.com/rakuri255/UltraSinger.git ``` -1. build the container image - ```commandline +1. build or pull the container image + ```bash podman build -t ultrasinger . + # or + podman pull ghcr.io/rakuri255/ultrasinger: # replace with the desired version or 'latest' ``` 1. run the container (note that the first time you run the container models will be downloaded which may take a while) 1. PowerShell: @@ -20,7 +22,7 @@ --device nvidia.com/gpu=all ` -v $env:USERPROFILE\.cache:/app/UltraSinger/src/.cache ` -v :/app/UltraSinger/src/output ` - ultrasinger ` + ghcr.io/rakuri255/ultrasinger ` python3 UltraSinger.py -i # explanation: @@ -29,7 +31,7 @@ --device nvidia.com/gpu=all ` # optional, enables GPU acceleration if available, requires step 1.ii -v $env:USERPROFILE\.cache:/app/UltraSinger/src/.cache ` # cache directory for models -v :/app/UltraSinger/src/output ` # output directory - ultrasinger ` # container image name, we built this in step 3 + ghcr.io/rakuri255/ultrasinger ` # latest container image, set to 'ultrasinger' to use the locally built image python3 UltraSinger.py -i # run UltraSinger, refer to top-level README.md for all options ``` 1. Bash: diff --git a/requirements.txt b/requirements.txt index 6490e41..0d5fa28 100644 --- a/requirements.txt +++ b/requirements.txt @@ -648,7 +648,7 @@ wrapt==1.16.0 # via tensorflow yarl==1.9.4 # via aiohttp -yt-dlp==2025.1.26 +yt-dlp==2025.01.26 # via -r requirements.in # The following packages are considered to be unsafe in a requirements file: