pytorch / audio

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

FileNotFoundError: Missing libtorchaudio.pyd file on Windows #3282

Closed CWhite1 closed 1 year ago

CWhite1 commented 1 year ago

🐛 Describe the bug

Description of Bug

I'm encountering an issue when using the bark library, which relies on torchaudio. When I try to run the code that imports and uses bark, I receive the following error message: An issue with the missing libtorchaudio.pyd file still persists.

FileNotFoundError: Could not find module 'C:\Users\chris\Downloads\GPTbarkAsssist\myenv\Lib\site-packages\torchaudio\lib\libtorchaudio.pyd' (or one of its dependencies). Try using the full path with constructor syntax.

Steps to reproduce:

pip install git+https://github.com/suno-ai/bark.git
pip install torch -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install torchaudio

Attempted solutions:

I have tried reinstalling torch and torchaudio multiple times, both globally and within a virtual environment. I have also tried installing different versions of torch and torchaudio, as well as creating a number of virtual environments in various folders with the same result of a missing libtorchaudio.pyd file . I've received guidance from an AI assistant to try various solutions, but none have resolved the issue so far.

Python Sample Code: (Program I am building more complicated that this, but this was simple test with same result)

from bark import SAMPLE_RATE, generate_audio

audio_array = generate_audio("Hello world!")

Full Traceback

myenv) PS C:\Users\chris\Downloads\GPTbarkAsssist> python test.py
Traceback (most recent call last):
  File "C:\Users\chris\Downloads\GPTbarkAsssist\test.py", line 1, in <module>
    from bark import SAMPLE_RATE, generate_audio
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\bark\__init__.py", line 1, in <module>
    from .api import generate_audio, text_to_semantic, semantic_to_waveform, save_as_prompt
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\bark\api.py", line 5, in <module>
    from .generation import codec_decode, generate_coarse, generate_fine, generate_text_semantic
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\bark\generation.py", line 8, in <module>
    from encodec import EncodecModel
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\encodec\__init__.py", line 12, in <module>
    from .model import EncodecModel
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\encodec\model.py", line 19, in <module>
    from .utils import _check_checksum, _linear_overlap_add, _get_checkpoint_url
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\encodec\utils.py", line 14, in <module>
    import torchaudio
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\torchaudio\__init__.py", line 1, in <module>
    from torchaudio import (  # noqa: F401
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\torchaudio\_extension\__init__.py", line 43, in <module>    
    _load_lib("libtorchaudio")
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\torchaudio\_extension\utils.py", line 61, in _load_lib      
    torch.ops.load_library(path)
  File "C:\Users\chris\Downloads\GPTbarkAsssist\myenv\lib\site-packages\torch\_ops.py", line 643, in load_library
    ctypes.CDLL(path)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\chris\Downloads\GPTbarkAsssist\myenv\Lib\site-packages\torchaudio\lib\libtorchaudio.pyd' (or one of its dependencies). Try using the full path with constructor syntax.

Versions

PyTorch version: 2.0.0+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 11 Home
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.22000-SP0
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture=9
CurrentClockSpeed=1101
DeviceID=CPU0
Family=15
L2CacheSize=4096
L2CacheSpeed=
Manufacturer=GenuineIntel
MaxClockSpeed=1101
Name=Intel(R) Celeron(R) N4020 CPU @ 1.10GHz
ProcessorType=3
Revision=31240

Versions of relevant libraries:
[pip3] numpy==1.24.3
[pip3] torch==2.0.0+cpu
[pip3] torchaudio==2.0.1
[conda] Could not collect
nateanl commented 1 year ago

@atalman can you help look into it? It seems torch 2.0.1 is not on pypi website yet, is that expected?

mthrok commented 1 year ago

I just tried the repro and it worked fine, but I see some differences than what's in report, which I do not think is critical.

I also inspected the content of https://download.pytorch.org/whl/cpu/torchaudio-2.0.1%2Bcpu-cp310-cp310-win_amd64.whl, and I verify that the said library file is part of the package.

So this looks more like issue with runtime environment.

@CWhite1 First, can you check if the said file exist? If installed properly, it should be there, but I cannot quite tell. Secondly, what I found peculiar is that your stack trace has seemingly mixed Python env. The last line has WindowsApps in the path, while the others are not. I don't use virtual env other than conda, so I cannot tell if it's normal. If there is an interpreter mixed along the way, then it is possible that the error message inaccurate and what really is happening is Python finds the library file but failed to load it.

makingmusic commented 1 year ago

Curious to know how you could fix this issue @CWhite1 - I am running in to the same issue. I see the following:

    File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\torchaudio\_extension\__init__.py", line 43, in <module>
      _load_lib("libtorchaudio")
    File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\torchaudio\_extension\utils.py", line 61, in _load_lib
      torch.ops.load_library(path)
    File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\torch\_ops.py", line 643, in load_library
      ctypes.CDLL(path)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\ctypes\__init__.py", line 376, in __init__
      self._handle = _dlopen(self._name, mode)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  FileNotFoundError: Could not find module 'C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\torchaudio\lib\libtorchaudio.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.