pytorch / audio

Data manipulation and transformation for audio signal processing, powered by PyTorch
https://pytorch.org/audio
BSD 2-Clause "Simplified" License
2.43k stars 636 forks source link

WLS2 compatibilty issue #3712

Open arnodelorme opened 7 months ago

arnodelorme commented 7 months ago

🐛 Describe the bug

This repo https://github.com/facebookresearch/brainmagick works fine on Ubuntu vanilla. On the exact same WLS2 configuration, the following error arises. This is using torchaudio 2.2.1

Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/concurrent/futures/process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/home/ubuntu/brainmagick_abdhu/bm/dataset.py", line 381, in _preload
    recording.events()
  File "/home/ubuntu/brainmagick_abdhu/bm/studies/api.py", line 264, in events
    self._events = self._load_events()
  File "/home/ubuntu/brainmagick_abdhu/bm/studies/brennan2019.py", line 307, in _load_events
    events = _read_meta(file)
  File "/home/ubuntu/brainmagick_abdhu/bm/studies/brennan2019.py", line 167, in _read_meta
    events = events.event.create_blocks(groupby='sentence')
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/pandas/core/accessor.py", line 224, in __get__
    accessor_obj = self._accessor(obj)
  File "/home/ubuntu/brainmagick_abdhu/bm/events.py", line 549, in __init__
    self._frame = self.validate()
  File "/home/ubuntu/brainmagick_abdhu/bm/events.py", line 603, in validate
    return pd.DataFrame(self._frame.apply(self._validate_event, axis=1).tolist())
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/pandas/core/frame.py", line 10034, in apply
    return op.apply().__finalize__(self, method="apply")
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/pandas/core/apply.py", line 837, in apply
    return self.apply_standard()
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/pandas/core/apply.py", line 963, in apply_standard
    results, res_index = self.apply_series_generator()
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/pandas/core/apply.py", line 979, in apply_series_generator
    results[i] = self.func(v, *self.args, **self.kwargs)
  File "/home/ubuntu/brainmagick_abdhu/bm/events.py", line 586, in _validate_event
    event_obj = event_class.from_dict(event)
  File "/home/ubuntu/brainmagick_abdhu/bm/events.py", line 53, in from_dict
    return cls(**{k: v for k, v in row.items() if k in [f.name for f in fields(cls)]})
  File "<string>", line 9, in __init__
  File "/home/ubuntu/brainmagick_abdhu/bm/events.py", line 132, in __post_init__
    info = torchaudio.info(self.filepath)
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/torchaudio/_backend/utils.py", line 97, in info
    backend = dispatcher(uri, format, backend)
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/torchaudio/_backend/utils.py", line 53, in dispatcher
    raise RuntimeError(f"Couldn't find appropriate backend to handle uri {uri} and format {format}.")
RuntimeError: Couldn't find appropriate backend to handle uri /home/ubuntu/brainmagick_abdhu/data/brennan2019/download/audio/DownTheRabbitHoleFinal_SoundFile1.wav and format None.
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/dora/__main__.py", line 174, in <module>
    main()
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/dora/__main__.py", line 170, in main
    args.action(args, main)
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/dora/run.py", line 69, in run_action
    main()
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/dora/main.py", line 86, in __call__
    return self._main()
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/dora/hydra.py", line 228, in _main
    return hydra.main(
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/hydra/main.py", line 94, in decorated_main
    _run_hydra(
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra
    _run_app(
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/hydra/_internal/utils.py", line 457, in _run_app
    run_and_report(
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
    raise ex
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/hydra/_internal/utils.py", line 220, in run_and_report
    return func()
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/hydra/_internal/utils.py", line 458, in <lambda>
    lambda: hydra.run(
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/site-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
  File "/home/ubuntu/brainmagick_abdhu/bm/train.py", line 186, in main
    return run(args)
  File "/home/ubuntu/brainmagick_abdhu/bm/train.py", line 141, in run
    solver = get_solver(args)
  File "/home/ubuntu/brainmagick_abdhu/bm/train.py", line 52, in get_solver
    dsets = dset.get_datasets(
  File "/home/ubuntu/brainmagick_abdhu/bm/dataset.py", line 467, in get_datasets
    all_recordings = [j.result() for j in jobs]  # check for exceptions
  File "/home/ubuntu/brainmagick_abdhu/bm/dataset.py", line 467, in <listcomp>
    all_recordings = [j.result() for j in jobs]  # check for exceptions
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/home/ubuntu/anaconda3/envs/p310env/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
RuntimeError: Couldn't find appropriate backend to handle uri /home/ubuntu/brainmagick_abdhu/data/brennan2019/download/audio/DownTheRabbitHoleFinal_SoundFile1.wav and format None.

Versions

Environement below

PyTorch version: 2.1.1+cu118
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.35

Python version: 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090
Nvidia driver version: 546.01
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):                             32
On-line CPU(s) list:                0-31
Vendor ID:                          GenuineIntel
Model name:                         13th Gen Intel(R) Core(TM) i9-13900K
CPU family:                         6
Model:                              183
Thread(s) per core:                 2
Core(s) per socket:                 16
Socket(s):                          1
Stepping:                           1
BogoMIPS:                           5990.40
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni umip waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm serialize flush_l1d arch_capabilities
Virtualization:                     VT-x
Hypervisor vendor:                  Microsoft
Virtualization type:                full
L1d cache:                          768 KiB (16 instances)
L1i cache:                          512 KiB (16 instances)
L2 cache:                           32 MiB (16 instances)
L3 cache:                           36 MiB (1 instance)
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Mitigation; Enhanced IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] flake8==6.1.0
[pip3] mypy==1.7.1
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.2
[pip3] torch==2.1.1+cu118
[pip3] torchaudio==2.1.1+cu118
[pip3] torchvision==0.16.1+cu118
[pip3] triton==2.1.0
[conda] numpy                     1.26.2                   pypi_0    pypi
[conda] torch                     2.1.1+cu118              pypi_0    pypi
[conda] torchaudio                2.1.1+cu118              pypi_0    pypi
[conda] torchvision               0.16.1+cu118             pypi_0    pypi
[conda] triton                    2.1.0                    pypi_0    pypi
arnodelorme commented 6 months ago

It turned out that this is an issue with the SOX library that cannot autodetect wav files. Installing the "soundfile" and uninstalling sox worked. Still in the file /home/ubuntu/anaconda3/lib/python3.9/site-packages/torchaudio/_backend/utils.py, it would be nice to warn users when the sox library is being used -- and tell them to use the soundfile library instead.