You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Packing app with Pyinstaller rises OSError: TorchScript requires source access in order to carry out compilation, make sure original .py files are available.
#54828
Closed
giuliodz opened this issue
Mar 27, 2021
· 3 comments
am trying to create an executable for a flask application that uses haystack to serve a QA System. Haystack uses transformers, and transformers library is built using torch.
If I run my API normally using a python interpreterpython app.py it works fine.
When I pack it with PyInstaller pyinstaller --onedir app.spec --clean --distpath distAPP the executable gets created fine. However, when I run it with ./distAPP/app/app I get the following error:
03/27/2021 11:16:39 - INFO - faiss - Loading faiss with AVX2 support.
03/27/2021 11:16:39 - INFO - faiss - Loading faiss.
Traceback (most recent call last):
File "torch/_utils_internal.py", line 49, in get_source_lines_and_file
File "inspect.py", line 967, in getsourcelines
File "inspect.py", line 798, in findsource
OSError: could not get source code
....
....
File "transformers/models/deberta/modeling_deberta.py", line 462, in <module>
File "torch/jit/_script.py", line 936, in script
File "torch/jit/frontend.py", line 197, in get_jit_def
File "torch/_utils_internal.py", line 56, in get_source_lines_and_file
OSError: Can't get source for <function c2p_dynamic_expand at 0x7fb81c95e3a0>. TorchScript requires source access in order to carry out compilation, make sure original .py files are available.
To Reproduce
You can find a minimal repository that will generate the same error here.
You can clone it (it only includes few light .py files) and follow the instructions in the README.md file. This will take you few seconds to get to work as I made it quite easy and light.
Expected behavior
PyInstaller should be able to get the source code at "torch/_utils_internal.py", but torch is not allowing it. My assumption is torch it is determined to use raw .py files.
Environment
PyTorch version: 1.7.1
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A
OS: Ubuntu 20.04.2 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: Could not collect
Python version: 3.8 (64-bit runtime)
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
Versions of relevant libraries:
[pip3] numpy==1.20.0
[pip3] torch==1.7.1
[conda] blas 1.0 mkl
[conda] mkl 2020.2 256
[conda] mkl-service 2.3.0 py38he904b0f_0
[conda] mkl_fft 1.2.0 py38h23d657b_0
[conda] mkl_random 1.1.1 py38h0573a6f_0
[conda] numpy 1.19.2 py38h54aff64_0
[conda] numpy-base 1.19.2 py38hfa32c7d_0
[conda] numpydoc 1.1.0 pyhd3eb1b0_1
This bug has also been posted on the PyInstaller github Issue board, where I show a few changes I did in my PyInstaller .spec file that tried to get the source code manually, but that did not work.
This looks more like PyInstaller issue rather than a TorchScript issue. Since there is an issue tracking this on the PyInstaller GH board, we do not plan on addressing this for now. Feel free to re-open if this turns out to be an issue with TorchScript.
馃悰 Bug
am trying to create an executable for a flask application that uses haystack to serve a QA System. Haystack uses transformers, and transformers library is built using torch.
If I run my API normally using a python interpreter
python app.py
it works fine.When I pack it with PyInstaller
pyinstaller --onedir app.spec --clean --distpath distAPP
the executable gets created fine. However, when I run it with./distAPP/app/app
I get the following error:To Reproduce
You can find a minimal repository that will generate the same error here.
You can clone it (it only includes few light .py files) and follow the instructions in the README.md file. This will take you few seconds to get to work as I made it quite easy and light.
Expected behavior
PyInstaller should be able to get the source code at
"torch/_utils_internal.py"
, but torch is not allowing it. My assumption is torch it is determined to use raw.py
files.Environment
cc @gmagogsfm
The text was updated successfully, but these errors were encountered: