Closed Aztorius closed 2 years ago
Hi @Aztorius
I have never used PyInstaller, but I think it's related to the fact that C++ libraries is not packaged properly.
I think you need something similar to https://stackoverflow.com/a/47528057
Checkout torchaudio/lib
directory of your installation (not source). You should see C++ library files there.
The combination of the files found there differs from distributions from distributions.
Then add the files to the hook.
I'm running some tests. The folder tochaudio/lib
is empty in my installation folder (pip site-packages).
I just found those warnings when running pyinstaller :
2234 WARNING: lib not found: c10.dll dependency of C:\Users\xxx\AppData\Local\Programs\Python\Python39\lib\site-packages\torchaudio\_torchaudio.pyd
2234 WARNING: lib not found: torch_cpu.dll dependency of C:\Users\xxx\AppData\Local\Programs\Python\Python39\lib\site-packages\torchaudio\_torchaudio.pyd
2406 WARNING: lib not found: torch_python.dll dependency of C:\Users\xxx\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\_C.cp39-win_amd64.pyd
Those dlls are inside torch/lib
folder. I'm trying to include them with hooks with no success so far.
There are couple of conflicting observations I am making;
torchaudio/lib/libtorchaudio
and torchaudio/_torchaudio
.
According to the output of your collect_env
, the package you are using is torchaudio-0.11.0-cp39-cp39-win_amd64.whl, and I checked that the package contains both torchaudio/_torchaudio.pyd
and torchaudio/lib/libtorchaudio.pyd
, so if it is installed properly, libtorchaudio.pyd
should exist.requires_sox
decorator function is designed to work without sox backend, and it assumes both torchaudio/lib/libtorchaudio
and torchaudio/_torchaudio
exist or neither.
The reason why requires_sox
is failing with No such operator torchaudio::is_sox_available
is because _torchaudio.pyd
exists but libtorchaudio.pyd
does not. In this case libtorchaudio.pyd
was not dlopen
-ed. This happens if libtorchaudio.pyd
does not exist. (Which is the original issue for PyInstaller)
But you mentioned that it works fine without PyInstaller. So I expected that libtorchaudio.pyd
exists in your package install, but The folder tochaudio/lib is empty
. In this case, I'd expect that the same issue would happen for pip installation.In your PIP installation, what would happen if you try import torchaudio._torchaudio
?
Ok, so let me recap. In my pip installed torchaudio package :
torchaudio/lib/libtorchaudio.pyd
and torchaudio/_torchaudio.pyd
After using pyinstaller :
torchaudio/_torchaudio.pyd
I suppose that I am missing the torchaudio/lib/libtorchaudio.pyd. I will try to include it with a hook.
So you are right assuming that requires_sox
is failing because of the missing libtorchaudio.pyd
.
Ok, just tried to manually copy the missing lib/libtorchaudio.pyd
and now it is working.
One working solution is to add torchaudio.lib.libtorchaudio
as a hidden import to pyinstaller.
It should be possible to include this in the torchaudio package for future pyinstaller users.
Thank you for the help.
Grad that it helps.
🐛 Describe the bug
When running this sample on Windows :
It doesn't work on Windows after PyInstaller. The error is :
Maybe PyInstaller execute the torchaudio decorator
@_mod_utils.requires_sox()
. This obviously causes a crash on Windows because of the missing sox backend.Before using PyInstaller (by running the .py file directly) it works without any issue.
Versions
Collecting environment information... PyTorch version: 1.11.0+cpu Is debug build: False CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A
OS: Microsoft Windows 10 Professionnel GCC version: Could not collect Clang version: Could not collect CMake version: Could not collect Libc version: N/A
Python version: 3.9.12 (tags/v3.9.12:b28265d, Mar 23 2022, 23:52:46) [MSC v.1929 64 bit (AMD64)] (64-bit runtime) Python platform: Windows-10-10.0.19044-SP0 Is CUDA available: False CUDA runtime version: No CUDA 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
Versions of relevant libraries: [pip3] numpy==1.22.1 [pip3] torch==1.11.0 [pip3] torchaudio==0.11.0 [conda] Could not collect