JarodMica / audiobook_maker

GNU General Public License v3.0
203 stars 34 forks source link

Program will fail to launch if user is using a GPU with low VRAM (<= 4GB) #18

Closed kidyudiqy closed 10 months ago

kidyudiqy commented 11 months ago

Console log:

> call .\venv\Scripts\activate.bat
2023-10-09 08:46:11 | INFO | rvc.configs.config | Found GPU NVIDIA GeForce GTX 1050 Ti
Traceback (most recent call last):
  File "D:\GitApps\audiobook_maker\audio_book_app_2_0.py", line 35, in <module>
    from rvc_pipe.rvc_infer import rvc_convert
  File "D:\GitApps\audiobook_maker\venv\lib\site-packages\rvc_pipe\rvc_infer.py", line 16, in <module>
    config = Config()
  File "D:\GitApps\audiobook_maker\rvc\configs\config.py", line 35, in wrapper
    wrapper.instance = func(*args, **kwargs)
  File "D:\GitApps\audiobook_maker\rvc\configs\config.py", line 60, in __init__
    self.x_pad, self.x_query, self.x_center, self.x_max = self.device_config()
  File "D:\GitApps\audiobook_maker\rvc\configs\config.py", line 154, in device_config
    with open("infer/modules/train/preprocess.py", "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'infer/modules/train/preprocess.py'

This happens with both package install and manual install.

After looking at it, the problem seems to stem from the lightweight rvc that was installed; the config file from rvc seems to be modifying other parts of the rvc code if it detects it running on low-vram hardware.

(line 153-157 from rvc\configs\config.py)

            if self.gpu_mem <= 4:
                with open("infer/modules/train/preprocess.py", "r") as f:
                    strr = f.read().replace("3.7", "3.0")
                with open("infer/modules/train/preprocess.py", "w") as f:
                    f.write(strr)

The path listed isn't going to resolve properly since we put rvc inside a folder. The easiest way to fix it that I tried is by adding rvc to the hardcoded path:

             if self.gpu_mem <= 4:
-                with open("infer/modules/train/preprocess.py", "r") as f:
+                with open("rvc/infer/modules/train/preprocess.py", "r") as f:
                     strr = f.read().replace("3.7", "3.0")
-                with open("infer/modules/train/preprocess.py", "w") as f:
+                with open("rvc/infer/modules/train/preprocess.py", "w") as f:
                     f.write(strr)

After editing the file, the program launches just fine.

JarodMica commented 11 months ago

Good catch, I'll have to adjust this and make a patch for it!

JarodMica commented 10 months ago

Patched in the RVC package, will have to incorporate that into the next patch

JarodMica commented 10 months ago

Added update to package