Merge pull request #186 from BWagener/feature/container-optimizations

optimize container related configuration and documentation
This commit is contained in:
Vadim Rangnau authored and GitHub committed 2024-12-18 21:31:14 +01:00
commit 4c57cf50af
10 files changed
+162 -70

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
evaluation
.git
.env
.vscode/
# virtual environment
venv
.venv
# python
**__pycache__
# test data
test_input
test_output
# default output folder
output
/UltraSinger*.spec
/registry_path.txt
+21 -12
View File
@@ -1,18 +1,27 @@
FROM nvidia/cuda:12.5.0-runtime-ubuntu22.04
FROM nvidia/cuda:12.6.3-runtime-ubuntu22.04
WORKDIR /app
RUN apt-get update && apt-get install git python3-pip -y && apt-get clean && rm -rf /var/lib/apt/lists/*
# 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 clean \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/rakuri255/UltraSinger.git
COPY . /app/UltraSinger
WORKDIR /app/UltraSinger
RUN apt-get update && apt-get install ffmpeg curl -y && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir -r requirements.txt
RUN 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
RUN pip install --no-cache-dir tensorflow[and-cuda]==2.16.1
ENV UID=0
ENV GID=0
ENV UMASK=022
EXPOSE 8088
# no need to run as root
RUN chown -R 1000:1000 /app/UltraSinger
USER 1000:1000
# setup venv
ENV VIRTUAL_ENV=/app/UltraSinger/.venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# install dependencies
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
WORKDIR /app/UltraSinger/src
CMD ["bash" ]
+6 -56
View File
@@ -61,8 +61,8 @@ This will help me a lot to keep this project alive and improve it.
- [🏆 Ultrastar Score Calculation](#-ultrastar-score-calculation)
- [📟 Use GPU](#-use-gpu)
- [Considerations for Windows users](#considerations-for-windows-users)
- [Info](#info)
- [Docker](#docker)
- [Crashes due to low VRAM](#crashes-due-to-low-vram)
- [📦 Containerized](#containerized-docker-or-podman)
## 💻 How to use this source code
@@ -285,65 +285,15 @@ 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:
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).
* [install WSL2](https://learn.microsoft.com/en-us/windows/wsl/install)
* within the Ubuntu WSL2 installation
* run `sudo apt update && sudo apt install nvidia-cuda-toolkit`
* follow the setup instructions for UltraSinger at the top of this document
#### Info
#### Crashes due to low VRAM
If something crashes because of low VRAM then use a smaller model.
Whisper needs more than 8GB VRAM in the `large` model!
You can also force cpu usage with the extra option `--force_cpu`.
#### Docker
to run the docker run `git clone https://github.com/rakuri255/UltraSinger.git`
enter the UltraSinger folder.
run this command to build the docker
`docker build -t ultrasinger .` make sure to include the "." at the end
let this run till complete.
then run this command
`docker run --gpus all -it --name UltraSinger -v $pwd/src/output:/app/src/output ultrasinger`
Docker-Compose
there are two files that you can pick from.
cd into `docker-compose` folder and then cd into `Nvidia` or `NonGPU`
Run `docker-compose up` to download and setup
Nvidia is for if you have a nvidia gpu to use with UltraSinger.
NonGPU is for if you wish to only use the CPU for UltraSinger.
Output
by default the docker-compose will setup the output folder as `/output` inside the docker.
on the host machine it will map to the folder with the `docker-compose.yml` file under `output`
you may chnage this by editing the `docker-compose.yml`
to edit the file.
use any text editor you wish. i would recoment nano.
run `nano docker-compose.yml`
then change this line
` - ./output:/app/UltraSinger/src/output`
to anything you line for on your host machine.
` - /yourfolderpathhere:/app/UltraSinger/src/output`
sample
` - /mnt/user/appdata/UltraSinger:/output`
note the blank space before the `-`
formating is important here in this file.
this will create and drop you into the docker.
now run this command.
`python3 UltraSinger.py -i file`
or
`python3 UltraSinger.py -i youtube_url`
to use mp3's in the folder you git cloned you must place all songs you like in UltraSinger/src/output.
this will be the place for youtube links aswell.
to quit the docker just type exit.
to reenter docker run this command
`docker start UltraSinger && Docker exec -it UltraSinger /bin/bash`
### Containerized (Docker or Podman)
See [container/README.md](container/README.md)
+16
View File
@@ -0,0 +1,16 @@
# Containerized UltraSinger
## Getting started
1. There are specific instructions for either Docker or Podman:
1. [Docker](docker.md)
1. [Podman](podman.md)
## Why run UltraSinger as a container?
Running UltraSinger in a container bears the following advantages
- Environment Consistency: Containers ensure that the application runs in the same environment across different machines, reducing the "it works on my machine" problem.
- Isolation: Containers isolate the application from the host system, preventing conflicts with other applications and dependencies.
- Simplified Deployment: Containers package the application and its dependencies together, simplifying the deployment process.
- Security: Containers provide an additional layer of security by isolating applications from the host system and each other.
File renamed without changes.
File renamed without changes.
+47
View File
@@ -0,0 +1,47 @@
# Containerized UltraSinger (Docker)
To run the docker run `git clone https://github.com/rakuri255/UltraSinger.git`
enter the UltraSinger folder.
run this command to build the docker
`docker build -t ultrasinger .` make sure to include the "." at the end
let this run till complete.
then run this command
`docker run --gpus all -it --name UltraSinger -v $pwd/src/output:/app/src/output ultrasinger`
Docker-Compose
- there are two files that you can pick from.
- cd into the `container` folder
- to download and setup, run either
- `docker-compose -f compose-gpu.yml up` if you have an nvidia gpu to use with UltraSinger
- or`docker-compose -f compose-nogpu.yml up` if you wish to only use the CPU for UltraSinger
Output
by default the docker-compose will setup the output folder as `/output` inside the docker.
on the host machine it will map to the folder with the `compose<gpu|nogpu>.yml` file under `output`
you may change this by editing the `compose<gpu|nogpu>.yml`
to edit the file.
use any text editor you wish. i would recoment nano.
run `nano compose<gpu|nogpu>.yml`
then change this line
` - ./output:/app/UltraSinger/src/output`
to anything you line for on your host machine.
` - /yourfolderpathhere:/app/UltraSinger/src/output`
sample
` - /mnt/user/appdata/UltraSinger:/output`
note the blank space before the `-`
formating is important here in this file.
this will create and drop you into the docker.
now run this command.
`python3 UltraSinger.py -i file`
or
`python3 UltraSinger.py -i youtube_url`
to use mp3's in the folder you git cloned you must place all songs you like in UltraSinger/src/output.
this will be the place for youtube links aswell.
to quit the docker just type exit.
to reenter docker run this command
`docker start UltraSinger && Docker exec -it UltraSinger /bin/bash`
+52
View File
@@ -0,0 +1,52 @@
# Containerized UltraSinger (Podman)
1. prerequisites
1. Podman installed (for Windows WSL2 machine provider is recommended) -> [installation instructions](https://podman-desktop.io/docs/installation)
1. (optional) for GPU acceleration Nvidia Container Toolkit installed -> [GPU container access](https://podman-desktop.io/docs/podman/gpu)
1. clone this repository:
```commandline
git clone https://github.com/rakuri255/UltraSinger.git
```
1. build the container image
```commandline
podman build -t ultrasinger .
```
1. run the container (note that the first time you run the container models will be downloaded which may take a while)
1. PowerShell:
```powershell
# remember to replace <desired-output-folder> below
podman run `
--rm -it --name ultrasinger `
--device nvidia.com/gpu=all `
-v $env:USERPROFILE\.cache:/app/UltraSinger/src/.cache `
-v <desired-output-folder>:/app/UltraSinger/src/output `
ultrasinger `
python3 UltraSinger.py -i <refer to top-level README.md>
# explanation:
podman run `
--rm -it --name ultrasinger ` # remove container after run, interactive mode, name the container
--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 <desired-output-folder>:/app/UltraSinger/src/output ` # output directory
ultrasinger ` # container image name, we built this in step 3
python3 UltraSinger.py -i <refer to top-level README.md> # run UltraSinger, refer to top-level README.md for all options
```
1. Bash:
```bash
# remember to replace <desired-output-folder> below
podman run \
--rm -it --name ultrasinger \
--device nvidia.com/gpu=all \
-v $HOME/.cache:/app/UltraSinger/src/.cache \
-v <desired-output-folder>:/app/UltraSinger/src/output \
ultrasinger \
python3 UltraSinger.py -i <refer to top-level README.md>
1. to use cookies for YouTube downloads, you can mount your cookies.txt file into the container:
```powershell
podman run `
... ` # same as above
-v <path-to-cookies.txt>:/app/UltraSinger/src/cookies.txt `
ultrasinger `
python3 UltraSinger.py --cookiefile cookies.txt -i <refer to top-level README.md>
```
-1
View File
@@ -1 +0,0 @@
this file is here to save folder path
@@ -1 +0,0 @@
this file is here to save folder path