Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of memory on 6GB Nvidia 2060 #209

Open
Chris-R-R opened this issue Feb 27, 2024 · 1 comment
Open

Out of memory on 6GB Nvidia 2060 #209

Chris-R-R opened this issue Feb 27, 2024 · 1 comment

Comments

@Chris-R-R
Copy link

I have been able to train and infer on this computer previously but I am running out of memory inferring a particular wav file (I have successfully processed longer wav files previously). Are the duration and sample rate of the wav file affecting memory usage?
I am using default parameters.

C:\Mangio-RVC-v23.7.0>runtime\python.exe infer-web.py --pycmd runtime\python.exe --port 7897
Found GPU NVIDIA GeForce RTX 2060
Set fp16_run to true in 32k.json
Set fp16_run to true in 40k.json
Set fp16_run to true in 48k.json
Use Language: en_US
Running on local URL: http://0.0.0.0:7897

To create a public link, set share=True in launch().
loading weights/Benny.pth
gin_channels: 256 self.spk_embed_dim: 109

loading rmvpe model
Traceback (most recent call last):
File "C:\Mangio-RVC-v23.7.0\infer-web.py", line 316, in vc_single
audio_opt = vc.pipeline(
File "C:\Mangio-RVC-v23.7.0\vc_infer_pipeline.py", line 564, in pipeline
self.vc(
File "C:\Mangio-RVC-v23.7.0\vc_infer_pipeline.py", line 450, in vc
(net_g.infer(feats, p_len, pitch, pitchf, sid)[0][0, 0])
File "C:\Mangio-RVC-v23.7.0\lib\infer_pack\models.py", line 752, in infer
m_p, logs_p, x_mask = self.enc_p(phone, pitch, phone_lengths)
File "C:\Mangio-RVC-v23.7.0\runtime\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "C:\Mangio-RVC-v23.7.0\lib\infer_pack\models.py", line 104, in forward
x = self.encoder(x * x_mask, x_mask)
File "C:\Mangio-RVC-v23.7.0\runtime\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "C:\Mangio-RVC-v23.7.0\lib\infer_pack\attentions.py", line 65, in forward
y = self.attn_layers[i](x, x, attn_mask)
File "C:\Mangio-RVC-v23.7.0\runtime\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "C:\Mangio-RVC-v23.7.0\lib\infer_pack\attentions.py", line 221, in forward
x, self.attn = self.attention(q, k, v, mask=attn_mask)
File "C:\Mangio-RVC-v23.7.0\lib\infer_pack\attentions.py", line 265, in attention
relative_weights = self._absolute_position_to_relative_position(p_attn)
File "C:\Mangio-RVC-v23.7.0\lib\infer_pack\attentions.py", line 346, in _absolute_position_to_relative_position
x_flat = F.pad(x_flat, commons.convert_pad_shape([[0, 0], [0, 0], [length, 0]]))
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 528.00 MiB (GPU 0; 6.00 GiB total capacity; 3.75 GiB already allocated; 0 bytes free; 4.81 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Traceback (most recent call last):
File "C:\Mangio-RVC-v23.7.0\runtime\lib\site-packages\gradio\routes.py", line 437, in run_predict
output = await app.get_blocks().process_api(
File "C:\Mangio-RVC-v23.7.0\runtime\lib\site-packages\gradio\blocks.py", line 1349, in process_api
data = self.postprocess_data(fn_index, result["prediction"], state)
File "C:\Mangio-RVC-v23.7.0\runtime\lib\site-packages\gradio\blocks.py", line 1283, in postprocess_data
prediction_value = block.postprocess(prediction_value)
File "C:\Mangio-RVC-v23.7.0\runtime\lib\site-packages\gradio\components.py", line 2586, in postprocess
file_path = self.audio_to_temp_file(
File "C:\Mangio-RVC-v23.7.0\runtime\lib\site-packages\gradio\components.py", line 360, in audio_to_temp_file
temp_dir = Path(dir) / self.hash_bytes(data.tobytes())

@Chris-R-R
Copy link
Author

After reading some of the other bug reports here I was able to get it working by setting the following parameters in config.py:
x_pad = 1 x_query = 5 x_center = 30 x_max = 32

Are these parameters explained anywhere?
The calculation of GPU memory confused me a little, why is 0.4 added to self.gpu_mem?
Maybe it would be better to subtract something here instead to take into account gpu memory used by other programs and have a safety margin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant