From 42ef9ad0df644a140f61c7b7aae67041efc58f39 Mon Sep 17 00:00:00 2001 From: rowellz Date: Wed, 22 Oct 2025 14:42:25 -0400 Subject: [PATCH] added docker for blackwell arch support --- Dockerfile | 16 ++++++++++++++++ README.md | 9 +++++++++ docker-compose.yml | 28 ++++++++++++++++++++++++++++ rvc_python/infer.py | 14 +++++++++++++- rvc_python/modules/vc/utils.py | 5 +++++ 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a28e676 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.10-slim + +RUN apt-get update -y && \ + apt-get install -y default-libmysqlclient-dev pkg-config gcc g++ libgl1 libglib2.0-0 + +COPY . /code + +WORKDIR /code + +RUN pip install -r requirements.txt + +RUN pip install --pre torch torchaudio --index-url https://download.pytorch.org/whl/nightly/cu126 + +ENV TORCH_CUDA_ARCH_LIST="5.0;6.0;7.0;7.5;8.0;8.6;9.0;12.0" + +ENV PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True diff --git a/README.md b/README.md index 42019a1..5c3cc2d 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,15 @@ You can add new models by: - `-rmr`, `--rms_mix_rate`: Volume envelope mix rate - `-pr`, `--protect`: Protection for voiceless consonants +### Docker (nvidia blackwell support) +You can run the rvc-python codebase in docker for easier debugging & contributing. It was implemented to help support newer rtx 5000 series hardware, but works with CPU as well. Run: + +```docker compose up -d``` + +Then, make your desired edits in `test.py` in the root of the project. Make sure to add your models to the `./models` directory. Then run: + +```docker compose exec rvc python test.py``` + ### API Server Options - `-p`, `--port`: API server port (default: 5050) - `-l`, `--listen`: Allow external connections to API server diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6b638e7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +services: + rvc: + restart: always + build: + context: . + dockerfile: Dockerfile + volumes: + - ./:/code + - ./models/:/models/ + extra_hosts: + - "host.docker.internal:host-gateway" + stdin_open: true + tty: true + ports: + - 5050:5050 + environment: + - PYTHONUNBUFFERED=1 + - TORCH_CUDA_ARCH_LIST="5.0;6.0;7.0;7.5;8.0;8.6;9.0;12.0" + - PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True + deploy: + resources: + reservations: + devices: + - driver: 'nvidia' + count: all + capabilities: [gpu] + + # python -m rvc_python cli -i input.wav -o output.wav -mp path/to/model.pth -de cuda:0 diff --git a/rvc_python/infer.py b/rvc_python/infer.py index 78a3aa0..7fbfeec 100644 --- a/rvc_python/infer.py +++ b/rvc_python/infer.py @@ -127,7 +127,7 @@ def infer_file(self, input_path, output_path): model_info = self.models[self.current_model] file_index = model_info.get("index", "") - wav_opt = self.vc.vc_single( + result = self.vc.vc_single( sid=0, input_audio_path=input_path, f0_up_key=self.f0up_key, @@ -142,6 +142,18 @@ def infer_file(self, input_path, output_path): file_index2="" ) + # Handle error case where vc_single returns a tuple (info, (times, wav_opt)) + if isinstance(result, tuple) and len(result) == 2: + info, audio_data = result + if isinstance(audio_data, tuple): + times, wav_opt = audio_data + if wav_opt is None: + raise RuntimeError(f"Voice conversion failed: {info}") + else: + wav_opt = audio_data + else: + wav_opt = result + wavfile.write(output_path, self.vc.tgt_sr, wav_opt) return output_path diff --git a/rvc_python/modules/vc/utils.py b/rvc_python/modules/vc/utils.py index ec28bcf..cba8ecd 100644 --- a/rvc_python/modules/vc/utils.py +++ b/rvc_python/modules/vc/utils.py @@ -19,6 +19,11 @@ def get_index_path_from_model(sid): def load_hubert(config,lib_dir): + import torch + # Temporarily allow unsafe globals for fairseq models + from fairseq.data.dictionary import Dictionary + torch.serialization.add_safe_globals([Dictionary]) + models, _, _ = checkpoint_utils.load_model_ensemble_and_task( [f"{lib_dir}/base_model/hubert_base.pt"], suffix="",