SillyTavern / SillyTavern-Extras

Extensions API for SillyTavern.
GNU Affero General Public License v3.0
563 stars 133 forks source link

[ERROR] RVC returns error 500 #151

Closed user177013 closed 1 year ago

user177013 commented 1 year ago

When hitting narrate button, it prints a popup:

<RVC module> RVC Voice Conversion Failed INTERNAL SERVER ERROR


2023-09-07 20:25:49 | INFO | werkzeug | 192.168.1.8 - - [07/Sep/2023 20:25:49] "OPTIONS /api/edge-tts/list HTTP/1.1" 200 -
2023-09-07 20:25:51 | INFO | werkzeug | 192.168.1.8 - - [07/Sep/2023 20:25:51] "GET /api/edge-tts/list HTTP/1.1" 200 -
2023-09-07 20:25:52 | INFO | werkzeug | 192.168.1.8 - - [07/Sep/2023 20:25:52] "GET /api/edge-tts/list HTTP/1.1" 200 -
2023-09-07 20:25:55 | INFO | werkzeug | 192.168.1.8 - - [07/Sep/2023 20:25:55] "OPTIONS /api/edge-tts/generate HTTP/1.1" 200 -
2023-09-07 20:25:56 | INFO | werkzeug | 192.168.1.8 - - [07/Sep/2023 20:25:56] "POST /api/edge-tts/generate HTTP/1.1" 200 -
2023-09-07 20:25:56 | INFO | werkzeug | 192.168.1.8 - - [07/Sep/2023 20:25:56] "OPTIONS /api/voice-conversion/rvc/process-audio HTTP/1.1" 200 -
<RVC module> received: <FileStorage: 'record' ('audio/mpeg')>
<RVC module> Received audio conversion request with model {'modelName': 'lisa-jp', 'pitchOffset': 0, 'pitchExtraction': 'rmvpe', 'indexRate': 0.88, 'filterRadius': 3, 'protect': 0.33}
<RVC module> EXPERIMENT MODE: emotions
> Searching overide code ($emotion$)
'text'
2023-09-07 20:25:56 | INFO | werkzeug | 192.168.1.8 - - [07/Sep/2023 20:25:56] "POST /api/voice-conversion/rvc/process-audio HTTP/1.1" 500 -```
user177013 commented 1 year ago

After doing git pull and installing ffmpeg-python via conda then pressing the narrate button, it installs HuBERT and rmvpe

<RVC module> Check for index file data/models/rvc/lisa-jp/
 > set index as  lisa-jp.index
<RVC module> loading data/models/rvc/lisa-jp/lisa-jp.pth
loading data/models/rvc/lisa-jp/lisa-jp.pth
gin_channels: 256 self.spk_embed_dim: 109
<All keys matched successfully>
Downloading HuBERT for RVC
Downloading hubert_base.pt: 100%|███████████████████████████████████████████████████| 190M/190M [00:49<00:00, 3.82MB/s]
Downloaded HuBERT for RVC
2023-09-08 04:01:44 | INFO | fairseq.tasks.hubert_pretraining | current directory is G:\AI\SillyTavern\SillyTavern-extras
2023-09-08 04:01:44 | INFO | fairseq.tasks.hubert_pretraining | HubertPretrainingTask Config {'_name': 'hubert_pretraining', 'data': 'metadata', 'fine_tuning': False, 'labels': ['km'], 'label_dir': 'label', 'label_rate': 50.0, 'sample_rate': 16000, 'normalize': False, 'enable_padding': False, 'max_keep_size': None, 'max_sample_size': 250000, 'min_sample_size': 32000, 'single_target': False, 'random_crop': True, 'pad_audio': False}
2023-09-08 04:01:44 | INFO | fairseq.models.hubert.hubert | HubertModel Config: {'_name': 'hubert', 'label_rate': 50.0, 'extractor_mode': default, 'encoder_layers': 12, 'encoder_embed_dim': 768, 'encoder_ffn_embed_dim': 3072, 'encoder_attention_heads': 12, 'activation_fn': gelu, 'layer_type': transformer, 'dropout': 0.1, 'attention_dropout': 0.1, 'activation_dropout': 0.0, 'encoder_layerdrop': 0.05, 'dropout_input': 0.1, 'dropout_features': 0.1, 'final_dim': 256, 'untie_final_proj': True, 'layer_norm_first': False, 'conv_feature_layers': '[(512,10,5)] + [(512,3,2)] * 4 + [(512,2,2)] * 2', 'conv_bias': False, 'logit_temp': 0.1, 'target_glu': False, 'feature_grad_mult': 0.1, 'mask_length': 10, 'mask_prob': 0.8, 'mask_selection': static, 'mask_other': 0.0, 'no_mask_overlap': False, 'mask_min_space': 1, 'mask_channel_length': 10, 'mask_channel_prob': 0.0, 'mask_channel_selection': static, 'mask_channel_other': 0.0, 'no_mask_channel_overlap': False, 'mask_channel_min_space': 1, 'conv_pos': 128, 'conv_pos_groups': 16, 'latent_temp': [2.0, 0.5, 0.999995], 'skip_masked': False, 'skip_nomask': False, 'checkpoint_activations': False, 'required_seq_len_multiple': 2, 'depthwise_conv_kernel_size': 31, 'attn_type': '', 'pos_enc_type': 'abs', 'fp16': False}
Downloading rmvpe.pt: 100%|█████████████████████████████████████████████████████████| 181M/181M [00:46<00:00, 3.89MB/s]
loading rmvpe model

but immediately returns error 500 again

Traceback (most recent call last):
  File "G:\AI\SillyTavern\SillyTavern-extras\modules\voice_conversion\rvc\rvc.py", line 233, in vc_single
    audio_opt = vc.pipeline(
                ^^^^^^^^^^^^
  File "G:\AI\SillyTavern\SillyTavern-extras\modules\voice_conversion\rvc\vc_infer_pipeline.py", line 298, in pipeline
    pitch, pitchf = self.get_f0(
                    ^^^^^^^^^^^^
  File "G:\AI\SillyTavern\SillyTavern-extras\modules\voice_conversion\rvc\vc_infer_pipeline.py", line 94, in get_f0
    f0 = cpe.pitch_extract(f0_method, x, f0_min, f0_max, p_len, time_step, self.sr, self.window, crepe_hop_length, filter_radius)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\AI\SillyTavern\SillyTavern-extras\modules\voice_conversion\rvc\custom_pitch_extraction.py", line 158, in pitch_extract
    f0 = model_rmvpe.infer_from_audio(x, thred=0.03)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\AI\SillyTavern\SillyTavern-extras\modules\voice_conversion\rvc\rmvpe.py", line 283, in infer_from_audio
    mel = self.mel_extractor(audio, center=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\miniconda3\envs\extras\Lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\AI\SillyTavern\SillyTavern-extras\modules\voice_conversion\rvc\rmvpe.py", line 241, in forward
    log_mel_spec = torch.log(torch.clamp(mel_output, min=self.clamp))
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: "clamp_min_scalar_cpu" not implemented for 'Half'

'NoneType' object has no attribute 'dtype'
2023-09-08 04:02:35 | INFO | werkzeug | 192.168.1.8 - - [08/Sep/2023 04:02:35] "POST /api/voice-conversion/rvc/process-audio HTTP/1.1" 500 -

Is this related with running extras with CPU?

user177013 commented 1 year ago

Issue resolved. It's really because extras run with CPU and I use rmvpe, turns out that and Torchcrepe is GPU-only. Use argument --cuda in start_extras.bat but seems like my torch cuda installation is borked, it prints:

torch cuda is not available in this device.
torch mps is not available in this device.

So I ran (in administrator mode):

cd /d (the path to your extras folder)
conda activate extras

Then input the suitable install command from pytorch.org. To find out the CUDA version:

nvcc --version

Mine is 11.8, so for me it's:

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu118

Then restart the start_extras.bat.

Just a note though, it's VRAM hungry, my 6GB card completely used up by it.