Mangio621 / Mangio-RVC-Fork

*CREPE+HYBRID TRAINING* A very experimental fork of the Retrieval-based-Voice-Conversion-WebUI repo that incorporates a variety of other f0 methods, along with a hybrid f0 nanmedian method.
MIT License
931 stars 207 forks source link

Fixing CUDA Error in Mangio-RVC for NVIDIA T1200 Laptop GPU - Solved #192

Open gerrycola opened 5 months ago

gerrycola commented 5 months ago

Hello everyone,

I recently encountered a persistent CUDA error while working with Mangio-RVC on my NVIDIA T1200 Laptop GPU. After several hours of trying various troubleshooting methods, I discovered that the issue was not with the hardware or the software setup, but with the configuration settings in the config.py file. I got chatGPT to write this summary up for me, and i'm hoping it helps someone save some time.

The Error Message

If you're encountering an error like this, my solution might work for you:

RuntimeError: CUDA error: device-side assert triggered
...
Assertion `srcIndex < srcSelectDimSize` failed.

The Solution: Config File Adjustment

I realized that the problem was due to settings in the config.py file not being optimized for a 4GB GPU like the NVIDIA T1200. Here's the specific code change that resolved the issue:

print("Found GPU", self.gpu_name)
use_fp32_config()  # Adjust config files as needed for GPU.
self.gpu_mem = int(
    torch.cuda.get_device_properties(i_device).total_memory
    / 1024
    / 1024
    / 1024
    + 0.4
)
# Adjust settings for GPUs with <= 4GB memory.
if self.gpu_mem <= 4:
    print(f"GPU has {self.gpu_mem}GB memory, adjusting settings for reduced memory usage.")
    self.is_half = False  # Using FP32 for 4GB GPU.
    with open("trainset_preprocess_pipeline_print.py", "r") as f:
        modified_content = f.read().replace("3.7", "3.0")
    with open("trainset_preprocess_pipeline_print.py", "w") as f:
        f.write(modified_content)
    # Adjust these settings based on your specific memory constraints.
    x_pad = 1
    x_query = 4
    x_center = 20
    x_max = 24
else:
    # Default settings for GPUs with more than 4GB memory.
    x_pad = 1
    x_query = 6
    x_center = 38
    x_max = 41

Implementing the Fix

  1. Backup the Original File: Always backup your existing config.py file before making changes.
  2. Edit the Config File: Replace the relevant section in your config.py file with the code above.
  3. Test the Changes: After saving the changes, run Mangio-RVC again.

Conclusion

This modification was specifically for the NVIDIA T1200 Laptop GPU with 4GB memory. It's crucial to understand that tweaking config files might have different effects based on your hardware setup. So, always backup your original file before making any changes.

I hope this solution helps anyone facing a similar issue. Feel free to share this post with anyone who might find it useful in resolving their CUDA errors with Mangio-RVC.

Happy voice converting!