-
Notifications
You must be signed in to change notification settings - Fork 22.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when loading jit traced FasterRCNN model in C++ #35881
Comments
Please check the following items:
|
Thanks for your reply. I've checked the abovementioned items and all of which are correct. Meanwhile, I did two little experiments with the latest released torchvision package (0.5.0):
Unhandled exception at 0x00007FFF5D1CA839 in RCNN_Pytorch_Demo.exe: Microsoft C++ exception: torch::jit::script::ErrorReport at memory location 0x000000E7E559E9A0.
The above python code can run successfully. So I was wondering is it because the Libtorch doesn't support RCNN family models? |
I caught the exception in Libtorch when loading the scripted model: schemas.size() > 0 INTERNAL ASSERT FAILED at ....\torch\csrc\jit\script\schema_matching.cpp:476, please report a bug to PyTorch. (matchSchemas at ....\torch\csrc\jit\script\schema_matching.cpp:476) |
same problem issue |
same problem issue too. |
Any update on this, I've hit this roadblock. Using nightly installs for both python training code and libtorch c++ inference code. |
@fmassa, any ideas here? Seems that torchvision models cannot be loaded when traced. |
Just to add more information because my situation is slightly different than OP's. I'm looking to switch from TF2 to pytorch and this is my last roadblock before switching over.
works fine in Python. I also did the same for fasterrcnn_resnet50_fpn because that's what I'm actually using. Load works as well as forward call for dummy input. In C++ torch::jit::load throws an exception same as above for the same model I just tested python with. schemas.size() > 0 INTERNAL ASSERT FAILED at "..\..\torch\csrc\jit\frontend\schema_matching.cpp":491, please report a bug to PyTorch. Using Windows 10 with binaries downloaded from main website for preview (nightly). Python is the same nightly option but with pip. C++ code is built in QT Creator with Qmake. My other models have worked and given good outputs. Compiler is MSVC 2017 Ran it in debug to catch exception. Release just crashes on jit::load (it's wrapped in try..catch) EDIT: nevermind on the FCN part, did the test again and it works. Not sure what I screwed up this morning. RCNN still does not |
same problem issue |
Hm @peterjc123 were you planning to look into this? Seems to only be happening for users with windows; I suspect it has to do with torchvision custom ops not getting registered? |
Same problem for me. Is there any workaround? Thanks |
I have a similar problem. On Windows, VisualStudio 2019 with I am loading the model with this code: The model has been scripted with the same version of torch and torchvision. model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=False) scripted_model = torch.jit.script(model) |
Same problem with Mask R-CNN resnet 50 model |
Any solution on this issue so far? |
This is not a Windows-specific issue. The exception in Python looks like this:
|
sorry,We changed our method and didn’t go further
| |
赵鹏程
|
|
***@***.***
|
签名由网易邮箱大师定制
On 4/21/2021 ***@***.***> wrote:
Any solution on this issue so far?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Any update on this? I got the same error with maskrcnn_resnet_50_fpn pretrained on cpu. The scripted version of the model can be loaded in Python and gives expected results. But the c++ side doesn't work. c++ code works fine with other models (unet type) in the same setting. This is a maskrcnn issue. Windows 10 The error is as follows: |
@suo schemas.size() > 0 INTERNAL ASSERT FAILED at "C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\jit\frontend\schema_matching.cpp":575, please report a bug to PyTorch. |
I will remove the module windows since I reproduced this issue on Linux as well. |
Same problem, waiting for solution |
Any update on this issue? I am getting the same error when loading a traced swinUNetR model in C++ using torch::jit::load("path to the traced model"). |
As a workaround to this issue import torchvision: |
Since the Windows label was removed, I am removing it from 'Pytorch on Windows' project as well. |
🐛 Bug
I used the torch.jit.trace() in python to trace the fasterrcnn_resnet50_fpn model provided in the latest torchvision (I installed the torchvision from source). However, an unhandled exception occured when I used libtorch API to load this model.
To Reproduce
Steps to reproduce the behavior:
1.Use Python API to trace model:
model = torchvision.models.detection.maskrcnn_resnet50_fpn(pretrained=True)
script_model = torch.jit.script(model)
script_model.save("./data/rcnn.pt")
Load "rcnn.pt" in Libtorch:
torch::jit::script::Module module = torch::jit::load("./data/rcnn.pt");
Then the exception occured:
Unhandled exception at 0x00007FFF5D1CA839 in RCNN_Pytorch_Demo.exe: Microsoft C++ exception: torch::jit::script::ErrorReport at memory location 0x00000037EDCEEF30.
Expected behavior
It should load the traced model without exception.
Environment
Visual Studio 2017
PyTorch version: 1.4.0+cu92
Is debug build: No
CUDA used to build PyTorch: 9.2
OS: Microsoft Windows 10 Professional
GCC version: Could not collect
CMake version: version 3.16.0-rc3
Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 9.2.148
GPU models and configuration:
GPU 0: GeForce GTX 1080 Ti
GPU 1: GeForce GTX 1080 Ti
Nvidia driver version: 432.00
cuDNN version: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\bin\cudnn64_7.dll
Versions of relevant libraries:
[pip] efficientnet-pytorch==0.5.1
[pip] numpy==1.17.4
[pip] numpydoc==0.8.0
[pip] torch==1.4.0+cu92
[pip] torchfile==0.1.0
[pip] torchnet==0.0.4
[pip] torchvision==0.5.0+cu92
[conda] blas 1.0 mkl defaults
[conda] efficientnet-pytorch 0.5.1
[conda] mkl 2018.0.2 1 defaults
[conda] mkl-service 1.1.2 py36h57e144c_4 defaults
[conda] mkl_fft 1.0.1 py36h452e1ab_0 defaults
[conda] mkl_random 1.0.1 py36h9258bd6_0 defaults
[conda] numpy 1.14.3 py36h9fa60d3_1 defaults
[conda] numpy 1.17.4
[conda] numpy-base 1.14.3 py36h555522e_1 defaults
[conda] numpydoc 0.8.0 py36_0 defaults
[conda] torch 1.4.0+cu92
[conda] torchfile 0.1.0
[conda] torchnet 0.0.4
[conda] torchvision 0.6.0a0
Libtorch 1.4.0
cc @peterjc123 @maxluk @nbcsm @guyang3532 @gunandrose4u @mszhanyi @skyline75489 @gmagogsfm @suo
The text was updated successfully, but these errors were encountered: