sigsep / open-unmix-pytorch

Open-Unmix - Music Source Separation for PyTorch
https://sigsep.github.io/open-unmix/
MIT License
1.24k stars 181 forks source link

How VRAM-hungry is umx supposed to be? #132

Closed enn-nafnlaus closed 1 year ago

enn-nafnlaus commented 1 year ago

🐛 Bug

I don't know what's considered "normal" here, but when I run umx, it quickly consumes all 24GB of my RTX 3090 and then throws a torch.cuda.OutOfMemory error. Exactly how much VRAM are we supposed to have to run this? If this requires some high-end server card to run, is there any chance of a float16, float8, or even float4 version?

To Reproduce

Steps to reproduce the behavior:

umx --model umxl /tmp/160k_15_85_80_v2_audio.wav

The wave file is 1687s long and is 44,1kHz.

Expected behavior

Doesn't do this:

Traceback (most recent call last): File "/usr/local/bin/umx", line 8, in sys.exit(separate()) File "/usr/local/lib/python3.10/site-packages/openunmix/cli.py", line 167, in separate estimates = predict.separate( File "/usr/local/lib/python3.10/site-packages/openunmix/predict.py", line 78, in separate estimates = separator(audio) File "/usr/local/lib64/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/usr/local/lib/python3.10/site-packages/openunmix/model.py", line 313, in forward targets_stft = targets_stft.permute(0, 5, 3, 2, 1, 4).contiguous() torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 8.88 GiB (GPU 0; 23.69 GiB total capacity; 18.73 GiB already allocated; 2.58 GiB free; 19.89 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

Environment

PyTorch version: 1.13.1+cu117 Is debug build: False CUDA used to build PyTorch: 11.7 ROCM used to build PyTorch: N/A

OS: Fedora Linux 36 (Workstation Edition) (x86_64) GCC version: (Homebrew GCC 11.3.0) 11.3.0 Clang version: 14.0.5 (Fedora 14.0.5-2.fc36) CMake version: version 3.24.1 Libc version: glibc-2.35

Python version: 3.10.10 (main, Feb 8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)] (64-bit runtime) Python platform: Linux-6.1.14-100.fc36.x86_64-x86_64-with-glibc2.35 Is CUDA available: True CUDA runtime version: 11.7.99 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090 GPU 1: NVIDIA GeForce RTX 3060

Nvidia driver version: 525.60.11 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 46 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 12 On-line CPU(s) list: 0-11 Vendor ID: GenuineIntel Model name: Intel(R) Core(TM) i7-7800X CPU @ 3.50GHz CPU family: 6 Model: 85 Thread(s) per core: 2 Core(s) per socket: 6 Socket(s): 1 Stepping: 4 CPU(s) scaling MHz: 99% CPU max MHz: 4000,0000 CPU min MHz: 1200,0000 BogoMIPS: 6999,82 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault cat_l3 cdp_l3 invpcid_single pti ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_pkg_req md_clear flush_l1d arch_capabilities Virtualization: VT-x L1d cache: 192 KiB (6 instances) L1i cache: 192 KiB (6 instances) L2 cache: 6 MiB (6 instances) L3 cache: 8,3 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-11 Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable

Versions of relevant libraries: [pip3] mypy-extensions==0.4.3 [pip3] numpy==1.23.3 [pip3] pytorch-lightning==1.7.6 [pip3] pytorch-triton==0.0.1 [pip3] rotary-embedding-torch==0.1.5 [pip3] torch==1.13.1 [pip3] torchaudio==0.13.1 [pip3] torchdiffeq==0.2.3 [pip3] torchmetrics==0.10.1 [pip3] torchvision==0.14.1 [pip3] triton==2.0.0 [conda] Could not collect

Additional context

faroit commented 1 year ago

That's a very long recording of almost 30min. The separator is designed to run efficiently on typical 3min songs.

I suggest you use the python api and iterate over chunks of a minute or so to avoid copying the full 30min into the gpu ram

markstock commented 7 months ago

Had the same issue on my 8GB card. Worked around with some sox command-lines to split into 2-minute chunks and re-assemble:

sox MySong.ogg Part.wav trim 0 120 : newfile : restart
umx Part001.wav
...
sox Part00?_umxl/vocals.wav MySongVocals.mp3