RVC-Project / Retrieval-based-Voice-Conversion-WebUI

Easily train a good VC model with voice data <= 10 mins!
MIT License
24.98k stars 3.65k forks source link

Training on Apple Silicon #767

Open eliasnassar opened 1 year ago

eliasnassar commented 1 year ago

Hey all,

I used my M1 MacBook Pro and trained a model with a dataset with .wav format that is 30 min long without slicing it, and I have some questions:

  1. Is it reasonable that it took more than 6 hours?
  2. Do slicing the dataset into < 10sec for every part, can make the training process faster?
  3. Is it that slow because RVC still doesn't support Apple Silicon, and the GPU is not being used?
  4. Are there any MPS updates coming to make training faster?

Hope some of you can help me with this 👯

Naozumi520 commented 1 year ago

Hi eliasnassar,

I think I can answer your questions.

  1. Yes. It takes long time to train even for 10 min long, I left it overnight.
  2. Not sure, but slicing the dataset should be necessary.
  3. No, you can absolutely train a model using Apple Silicon. And the GPU is being used but some function not supported with MPS (Metal Performance Shaders), so it will use the CPU as a fallback :(
  4. I hope so. I saw some of the RVC developer use Macs as well :D
guhaizhous commented 1 year ago

Hi eliasnassar,

After I finished using m2 max, I encountered the following error when executing python ./infer-web.py Traceback (most recent call last): File "/Users/guhaizhou/work/AI/RVConversion-WebUI/infer-web.py", line 21, in import faiss ModuleNotFoundError: No module named 'faiss'

It's obvious that I saw faiss cpu=>1.7.4 in requirements. txt

I really hope to receive your help. Thank you!!

Arslan007 commented 1 year ago

@eliasnassar Can you please help me to run on my MAC M1 Max. Shukran

tobidev615 commented 8 months ago

@eliasnassar I can’t even get my to train on Mac m2. I had to use a windows gpu pc.

Acelogic commented 8 months ago

@Naozumi520 What particular part of the training pipeline isn't compatible with MPS?

Naozumi520 commented 8 months ago

@Naozumi520 What particular part of the training pipeline isn't compatible with MPS?

Not sure, but you can find out with the line os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" removed. This will stop using cpu as a fallback while training.

Jay987654321 commented 6 months ago

how to install it on macbook pro m1 any tutorial?

bparousis commented 5 months ago

how to install it on macbook pro m1 any tutorial?

Any luck figuring this out? I try running it but it complains about missing modules.

hiiggghhh commented 2 months ago

it is nightmare I have tried for about 24 hours in total to get this running on a m1 MacBook using all the available tutorials from Youtube and elsewhere. I don't think it works, you can try putting the endless errors in ChatGPT but just goes in circles of uninstalling and installing stuff forever.

Johndgnzj commented 2 months ago

I use the MacBook Pro M2 chip with Applio to train the models, and it works fine.

Popshells commented 1 month ago

I have it running on a mac studio M1 but didn't train yet. Install python3.10 in you system brew install python@3.10 (you can have different versions), brew install ffmpeg (if you don't have it), make a folder for rvc, create an activate a rvc-venv with 3.10 python3.10 -m venv rvc-venv source rvc-venv/bin/activate, pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu on the env, git clone https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git in the rvc folder, open requirements.txt and comment out # aria2 (you can install it later if you ever have the patience), Move into the project directory cd Retrieval-based-Voice-Conversion-WebUI pip3 install -r requirements.txt, ( if some fail you can pip install omegaconf==2.0.5 pip install fairseq==0.12.2 --no-deps pip install hydra-core==1.0.7 --no-deps), run tools/download_models.py (to get the models into the folders), then run run.sh (that's a long one, maybe I could started there, but not sure, im not good at this). To start the webui, I made a rcv.command file, so you can latter double click it, (make it executable), and put something like this on it:

!/bin/bash

cd /yourpath/rvc source rvc-venv/bin/activate export PYTORCH_ENABLE_MPS_FALLBACK=1 cd /yourpath/rvc/Retrieval-based-Voice-Conversion-WebUI exec python3 infer-web.py

hope these helps somebody, if i made a mistake or omitted something, tell me and ill correct it.

luckyvictor commented 1 month ago

I have it running on a mac studio M1 but didn't train yet. Install python3.10 in you system brew install python@3.10 (you can have different versions), brew install ffmpeg (if you don't have it), make a folder for rvc, create an activate a rvc-venv with 3.10 python3.10 -m venv rvc-venv source rvc-venv/bin/activate, pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu on the env, git clone https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git in the rvc folder, open requirements.txt and comment out # aria2 (you can install it later if you ever have the patience), Move into the project directory cd Retrieval-based-Voice-Conversion-WebUI pip3 install -r requirements.txt, ( if some fail you can pip install omegaconf==2.0.5 pip install fairseq==0.12.2 --no-deps pip install hydra-core==1.0.7 --no-deps), run tools/download_models.py (to get the models into the folders), then run run.sh (that's a long one, maybe I could started there, but not sure, im not good at this). To start the webui, I made a rcv.command file, so you can latter double click it, (make it executable), and put something like this on it: #!/bin/bash cd /yourpath/rvc source rvc-venv/bin/activate export PYTORCH_ENABLE_MPS_FALLBACK=1 cd /yourpath/rvc/Retrieval-based-Voice-Conversion-WebUI exec python3 infer-web.py

hope these helps somebody, if i made a mistake or omitted something, tell me and ill correct it.

Hi Popshells

I am following your guide to get it run on my M1 machine. I have done the works up to installing the requirements. I didn't download the models using download_models.py, because I want to train my own model. I have got a wav saved, but I don't know how to upload it under the Train tab.

I have the following error, when I use this path '/Users/user/Documents/RVC/Voice/' in Enter the path of the training folder:

from preprocess log

start preprocess /Users/user/Documents/RVC/Voice/.DS_Store -> Traceback (most recent call last): File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer/lib/audio.py", line 43, in load_audio ffmpeg.input(file, threads=0) File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/ffmpeg/_run.py", line 313, in run process = run_async( File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/ffmpeg/_run.py", line 284, in run_async return subprocess.Popen( File "/opt/anaconda3/envs/py310/lib/python3.10/subprocess.py", line 971, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/opt/anaconda3/envs/py310/lib/python3.10/subprocess.py", line 1863, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer/modules/train/preprocess.py", line 83, in pipeline audio = load_audio(path, self.sr) File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer/lib/audio.py", line 49, in load_audio raise RuntimeError(f"Failed to load audio: {e}") RuntimeError: Failed to load audio: [Errno 2] No such file or directory: 'ffmpeg'

/Users/user/Documents/RVC/Voice/myvoice.wav -> Traceback (most recent call last): File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer/lib/audio.py", line 43, in load_audio ffmpeg.input(file, threads=0) File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/ffmpeg/_run.py", line 313, in run process = run_async( File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/ffmpeg/_run.py", line 284, in run_async return subprocess.Popen( File "/opt/anaconda3/envs/py310/lib/python3.10/subprocess.py", line 971, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/opt/anaconda3/envs/py310/lib/python3.10/subprocess.py", line 1863, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer/modules/train/preprocess.py", line 83, in pipeline audio = load_audio(path, self.sr) File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer/lib/audio.py", line 49, in load_audio raise RuntimeError(f"Failed to load audio: {e}") RuntimeError: Failed to load audio: [Errno 2] No such file or directory: 'ffmpeg'

end preprocess

Popshells commented 1 month ago

@luckyvictor Hi, I haven't try to train yet, I got distracted installing Applio. I recommend you install ffmpeg system wide, If you didn't already. ffmpeg doesn't have to be inside the venv. Also, even you are gonna train, you should download the required models, they serve different parts of the app, them you replace them with ones you train. Sorry for the delay.

luckyvictor commented 1 month ago

@luckyvictor Hi, I haven't try to train yet, I got distracted installing Applio. I recommend you install ffmpeg system wide, If you didn't already. ffmpeg doesn't have to be inside the venv. Also, even you are gonna train, you should download the required models, they serve different parts of the app, them you replace them with ones you train. Sorry for the delay.

I have pip3 install it in my terminal now. so how do I correctly reference the voice clip in Mac? because there is no browse option, I don't know how to type the full path just like windows, not sure whether I put the address correctly.

/Users/user/Documents/RVC/Voice/myvoice.wav

image

/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/gradio_client/documentation.py:106: UserWarning: Could not get documentation group for <class 'gradio.mix.Parallel'>: No known documentation group for module 'gradio.mix' warnings.warn(f"Could not get documentation group for {cls}: {exc}") /Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/gradio_client/documentation.py:106: UserWarning: Could not get documentation group for <class 'gradio.mix.Series'>: No known documentation group for module 'gradio.mix' warnings.warn(f"Could not get documentation group for {cls}: {exc}") 2024-10-25 23:27:13 | INFO | main | Use Language: en_US Running on local URL: http://0.0.0.0:7865 2024-10-25 23:31:33 | INFO | main | Execute: "/Users/user/Documents/RVC/rvc-venv/bin/python" infer/modules/train/preprocess.py "/Users/user/Documents/RVC/Voice/myvoice.wav" 40000 6 "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/logs/mi-test" False 3.0 /Users/user/Documents/RVC/Voice/myvoice.wav 40000 6 /Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/logs/mi-test False 3.0 start preprocess Fail. Traceback (most recent call last): File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer/modules/train/preprocess.py", line 115, in pipeline_mp_inp_dir for idx, name in enumerate(sorted(list(os.listdir(inp_root)))) NotADirectoryError: [Errno 20] Not a directory: '/Users/user/Documents/RVC/Voice/myvoice.wav'

end preprocess 2024-10-25 23:31:36 | INFO | main | start preprocess Fail. Traceback (most recent call last): File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer/modules/train/preprocess.py", line 115, in pipeline_mp_inp_dir for idx, name in enumerate(sorted(list(os.listdir(inp_root)))) NotADirectoryError: [Errno 20] Not a directory: '/Users/user/Documents/RVC/Voice/myvoice.wav'

end preprocess

2024-10-25 23:31:36 | INFO | main | Execute: /Users/user/Documents/RVC/rvc-venv/bin/python infer/modules/train/extract/extract_f0_rmvpe_dml.py "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/logs/mi-test" Traceback (most recent call last): File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer/modules/train/extract/extract_f0_rmvpe_dml.py", line 19, in import torch_directml ModuleNotFoundError: No module named 'torch_directml' 2024-10-25 23:31:37 | INFO | main | 2024-10-25 23:31:37 | INFO | main | Execute: "/Users/user/Documents/RVC/rvc-venv/bin/python" infer/modules/train/extract_feature_print.py mps 1 0 "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/logs/mi-test" v2 False infer/modules/train/extract_feature_print.py mps 1 0 /Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/logs/mi-test v2 False exp_dir: /Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/logs/mi-test load model(s) from assets/hubert/hubert_base.pt Error: Extracting is shut down because assets/hubert/hubert_base.pt does not exist, you may download it from https://huggingface.co/lj1995/VoiceConversionWebUI/tree/main 2024-10-25 23:31:40 | INFO | main | infer/modules/train/extract_feature_print.py mps 1 0 /Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/logs/mi-test v2 False exp_dir: /Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/logs/mi-test load model(s) from assets/hubert/hubert_base.pt Error: Extracting is shut down because assets/hubert/hubert_base.pt does not exist, you may download it from https://huggingface.co/lj1995/VoiceConversionWebUI/tree/main

Traceback (most recent call last): File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/gradio/routes.py", line 437, in run_predict output = await app.get_blocks().process_api( File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/gradio/blocks.py", line 1346, in process_api result = await self.call_function( File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/gradio/blocks.py", line 1090, in call_function prediction = await utils.async_iteration(iterator) File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/gradio/utils.py", line 341, in async_iteration return await iterator.anext() File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/gradio/utils.py", line 334, in anext return await anyio.to_thread.run_sync( File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2441, in run_sync_in_worker_thread return await future File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 943, in run result = context.run(func, *args) File "/Users/user/Documents/RVC/rvc-venv/lib/python3.10/site-packages/gradio/utils.py", line 317, in run_sync_iterator_async return next(iterator) File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer-web.py", line 756, in train1key click_train( File "/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/infer-web.py", line 496, in click_train & set([name.split(".")[0] for name in os.listdir(f0_dir)]) FileNotFoundError: [Errno 2] No such file or directory: '/Users/user/Documents/RVC/Retrieval-based-Voice-Conversion-WebUI/logs/mi-test/2a_f0'

Popshells commented 1 month ago

in Mac you right click any file or folder holding the option key and select: copy .... as pathname to get the path. But anyway, your app is still looking for the required models, you have to download them, with the script or manually and put them in the right folders (the script does it for you), "Error: Extracting is shut down because assets/hubert/hubert_base.pt does not exist,". "hubert_base.pt" is one of the AI models that the app requires to run.