Skip to content

fix: Make infer-web.py work again: upgrade gradio, restrict versions for torch and matplotlib, fix temp path #2529

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Tsar
Copy link

@Tsar Tsar commented Mar 29, 2025

Pull request checklist

  • The PR has a proper title. Use Semantic Commit Messages. (No more branch-name title please)

  • Make sure this is ready to be merged into the relevant branch. Please don't create a PR and let it hang for a few days.

  • Ensure you can run the codes you submitted succesfully. These submissions will be prioritized for review:

    Introduce improvements in program execution speed;

    Introduce improvements in synthesis quality;

    Fix existing bugs reported by user feedback (or you met);

    Introduce more convenient user operations.

PR type

  • Bug fix

Description

  • torch must be older than 2.6, otherwise there will be errors like this:

    load model(s) from assets/hubert/hubert_base.pt
    Traceback (most recent call last):
      File "/mnt/ssd_ext4_data/develop/2D_chan/UsefulData/Retrieval-based-Voice-Conversion-WebUI/infer/modules/train/extract_feature_print.py", line 89, in <module>
        models, saved_cfg, task = fairseq.checkpoint_utils.load_model_ensemble_and_task(
      File "/home/tsar/.local/lib/python3.10/site-packages/fairseq/checkpoint_utils.py", line 425, in load_model_ensemble_and_task
        state = load_checkpoint_to_cpu(filename, arg_overrides)
      File "/home/tsar/.local/lib/python3.10/site-packages/fairseq/checkpoint_utils.py", line 315, in load_checkpoint_to_cpu
        state = torch.load(f, map_location=torch.device("cpu"))
      File "/home/tsar/.local/lib/python3.10/site-packages/torch/serialization.py", line 1470, in load
        raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
    _pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint. 
        (1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
        WeightsUnpickler error: Unsupported global: GLOBAL fairseq.data.dictionary.Dictionary was not an allowed global by default. Please use `torch.serialization.add_safe_globals([Dictionary])` or the `torch.serialization.safe_globals([Dictionary])` context manager to allowlist this global if you trust this class/function.
    
    Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.
    
  • matplotlib must be older than 3.10, otherwise there will be errors like this:

    Traceback (most recent call last):
      File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
        self.run()
      File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
        self._target(*self._args, **self._kwargs)
      File "/mnt/ssd_ext4_data/develop/2D_chan/UsefulData/Retrieval-based-Voice-Conversion-WebUI/infer/modules/train/train.py", line 268, in run
        train_and_evaluate(
      File "/mnt/ssd_ext4_data/develop/2D_chan/UsefulData/Retrieval-based-Voice-Conversion-WebUI/infer/modules/train/train.py", line 545, in train_and_evaluate
        "slice/mel_org": utils.plot_spectrogram_to_numpy(
      File "/mnt/ssd_ext4_data/develop/2D_chan/UsefulData/Retrieval-based-Voice-Conversion-WebUI/infer/lib/train/utils.py", line 238, in plot_spectrogram_to_numpy
        data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep="")
    AttributeError: 'FigureCanvasAgg' object has no attribute 'tostring_rgb'
    
  • gradio should be upgraded, otherwise there will be problems which were reported multiple times: broken "One-click training" button and etc:

    I upgraded it to 3.48.0 as suggested in Gradio version  #2355.

    Warning: UI starts looking a little bit different after this change! But at least it works.

  • Current dir + TEMP + temporary file path might get too long and you may start experiencing errors like this:

    Traceback (most recent call last):
      File "/usr/lib/python3.10/multiprocessing/queues.py", line 244, in _feed
        obj = _ForkingPickler.dumps(obj)
      File "/usr/lib/python3.10/multiprocessing/reduction.py", line 51, in dumps
        cls(buf, protocol).dump(obj)
      File "/usr/local/lib/python3.10/dist-packages/torch/multiprocessing/reductions.py", line 619, in reduce_storage
        df = multiprocessing.reduction.DupFd(fd)
      File "/usr/lib/python3.10/multiprocessing/reduction.py", line 198, in DupFd
        return resource_sharer.DupFd(fd)
      File "/usr/lib/python3.10/multiprocessing/resource_sharer.py", line 53, in __init__
        self._id = _resource_sharer.register(send, close)
      File "/usr/lib/python3.10/multiprocessing/resource_sharer.py", line 76, in register
        self._start()
      File "/usr/lib/python3.10/multiprocessing/resource_sharer.py", line 126, in _start
        self._listener = Listener(authkey=process.current_process().authkey)
      File "/usr/lib/python3.10/multiprocessing/connection.py", line 448, in __init__
        self._listener = SocketListener(address, family, backlog)
      File "/usr/lib/python3.10/multiprocessing/connection.py", line 591, in __init__
        self._socket.bind(address)
    OSError: AF_UNIX path too long
    

    That's why I decided to use temporary directory provided by OS instead of hardcoded TEMP inside current dir.

Screenshot

image

Sorry, something went wrong.

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

Successfully merging this pull request may close these issues.

1 participant