kuielab / mdx-net-submission

MIT License
124 stars 24 forks source link

Not enough memory error #18

Open ProgressiveProgression opened 2 years ago

ProgressiveProgression commented 2 years ago

Hi.

I tried to extrac the stems from the song which is 29 Mb large. My modul is allocated on C:\ drive which has 14,7 MB of free space. Still I get this exception:

(mdx-submit) PS C:\Users\elbit\mdx-net-submission> python predict_blend.py
C:\Users\elbit\mdx-net-submission/data/test/Schwarz\mixture.wav
C:\Users\elbit\mdx-net-submission\predict_blend.py:56: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at  C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\utils\tensor_new.cpp:210.)
  mix_waves = torch.tensor(mix_waves, dtype=torch.float32)
C:\Users\elbit\anaconda3\envs\mdx-submit\lib\site-packages\torch\functional.py:695: UserWarning: stft will soon require the return_complex parameter be given for real inputs, and will further require that return_complex=True in a future PyTorch release. (Triggered internally at  C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\SpectralOps.cpp:798.)
  return _VF.stft(input, n_fft, hop_length, win_length, window,  # type: ignore[attr-defined]
C:\Users\elbit\anaconda3\envs\mdx-submit\lib\site-packages\torch\functional.py:770: UserWarning: istft will require a complex-valued input tensor in a future PyTorch release. Matching the output from stft with return_complex=True.  (Triggered internally at  C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\SpectralOps.cpp:950.)
  return _VF.istft(input, n_fft, hop_length, win_length, window, center,  # type: ignore[attr-defined]
Traceback (most recent call last):
  File "C:\Users\elbit\mdx-net-submission\evaluator\music_demixing.py", line 146, in run
    self.evaluation()
  File "C:\Users\elbit\mdx-net-submission\evaluator\music_demixing.py", line 133, in evaluation
    self.prediction(mixture_file_path=self.get_music_file_location(music_name),
  File "C:\Users\elbit\mdx-net-submission\predict_blend.py", line 26, in prediction
    sources = self.demix(mixture_file_path)
  File "C:\Users\elbit\mdx-net-submission\predict_blend.py", line 33, in demix
    base_out = self.demix_base(mix)
  File "C:\Users\elbit\mdx-net-submission\predict_blend.py", line 60, in demix_base
    tar_waves = model.istft(torch.tensor(
  File "C:\Users\elbit\mdx-net-submission\models.py", line 152, in istft
    x = torch.istft(x, n_fft=self.n_fft, hop_length=self.hop, window=self.window, center=True)
  File "C:\Users\elbit\anaconda3\envs\mdx-submit\lib\site-packages\torch\functional.py", line 770, in istft
    return _VF.istft(input, n_fft, hop_length, win_length, window, center,  # type: ignore[attr-defined]
RuntimeError: [enforce fail at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\c10\core\impl\alloc_cpu.cpp:81] data. DefaultCPUAllocator: not enough memory: you tried to allocate 1543503872 bytes.

Traceback (most recent call last):
  File "C:\Users\elbit\mdx-net-submission\predict_blend.py", line 94, in <module>
    submission.run()
  File "C:\Users\elbit\mdx-net-submission\evaluator\music_demixing.py", line 152, in run
    raise e
  File "C:\Users\elbit\mdx-net-submission\evaluator\music_demixing.py", line 146, in run
    self.evaluation()
  File "C:\Users\elbit\mdx-net-submission\evaluator\music_demixing.py", line 133, in evaluation
    self.prediction(mixture_file_path=self.get_music_file_location(music_name),
  File "C:\Users\elbit\mdx-net-submission\predict_blend.py", line 26, in prediction
    sources = self.demix(mixture_file_path)
  File "C:\Users\elbit\mdx-net-submission\predict_blend.py", line 33, in demix
    base_out = self.demix_base(mix)
  File "C:\Users\elbit\mdx-net-submission\predict_blend.py", line 60, in demix_base
    tar_waves = model.istft(torch.tensor(
  File "C:\Users\elbit\mdx-net-submission\models.py", line 152, in istft
    x = torch.istft(x, n_fft=self.n_fft, hop_length=self.hop, window=self.window, center=True)
  File "C:\Users\elbit\anaconda3\envs\mdx-submit\lib\site-packages\torch\functional.py", line 770, in istft
    return _VF.istft(input, n_fft, hop_length, win_length, window, center,  # type: ignore[attr-defined]
RuntimeError: [enforce fail at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\c10\core\impl\alloc_cpu.cpp:81] data. DefaultCPUAllocator: not enough memory: you tried to allocate 1543503872 bytes.
ws-choi commented 1 year ago

Hi @ProgressiveProgression, Sorry for the delay. I forgot this thread for a while

I pushed a new branch where you can control the batch_size.

TLDR; please switch to this branch and try this commend: python separate.py --batch_size 4

Usage:

    parser.add_argument('--model_name', type=str, default='tdf_extra')
    parser.add_argument('--demucs_name', type=str, default='demucs_extra')
    parser.add_argument('--onnx_name', type=str, default='onnx_B')
    parser.add_argument('--mixture_dir_path', type=str, default='./data/test')
    parser.add_argument('--results_data_path', type=str, default='./data/results')
    parser.add_argument('--batch_size', default=None, type=int)
ws-choi commented 1 year ago

Hmm not sure it works for your environment. We'll see.

I hope it works at least with --batch_size 1 :)