-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Description
🐛 Bug
Trying to load a simple saved scripted_model produces an error:
File "example_save_torch_script.py", line 62, in <module>
new_scripted_model = torch.jit.load("script_model.pt")
File "/home/agis/anaconda3/envs/fastai-v1/lib/python3.6/site-packages/torch/jit/__init__.py", line 98, in load
torch._C.import_ir_module(module_lookup, f)
RuntimeError: it != value_type_map_.end() ASSERT FAILED at /opt/conda/conda-bld/pytorch-nightly_1538471633750/work/torch/csrc/jit/import.cpp:281, please report a bug to PyTorch. (buildIntermediateValue at /opt/conda/conda-bld/pytorch-nightly_1538471633750/work/torch/csrc/jit/import.cpp:281)
To Reproduce
Providing the following code to reproduce the error:
import torch
class MyModuleS(torch.jit.ScriptModule):
def __init__(self, N, M):
super(MyModuleS, self).__init__()
self.weight = torch.nn.Parameter(torch.rand(N, M))
@torch.jit.script_method
def forward(self, input: torch.Tensor):
if bool(input.sum() > 0):
output = self.weight.mv(input)
else:
output = self.weight + input
return output
my_script_module = MyModuleS(200, 200)
test_input = torch.rand(200)
output = my_script_module(test_input)
print(my_script_module.graph)
print("scripted model: ", output.size())
my_script_module.save("script_model.pt")
new_scripted_model = torch.jit.load("script_model.pt") # crash happens here
output = new_scripted_model(test_input)
print(output)
Steps to reproduce the behavior:
- run script
Expected behavior
The scripted module should be loaded and the code should be run
Environment
Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).
You can get the script and run it with:
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
Collecting environment information...
PyTorch version: 1.0.0.dev20181002
Is debug build: No
CUDA used to build PyTorch: 9.2.148
OS: Ubuntu 16.04.5 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
CMake version: version 3.12.2
Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: GeForce GTX 1080 Ti
Nvidia driver version: 396.37
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.2.1
/usr/local/cuda-9.2/targets/x86_64-linux/lib/libcudnn.so
/usr/local/cuda-9.2/targets/x86_64-linux/lib/libcudnn.so.7
/usr/local/cuda-9.2/targets/x86_64-linux/lib/libcudnn.so.7.2.1
/usr/local/cuda-9.2/targets/x86_64-linux/lib/libcudnn_static.a
Versions of relevant libraries:
[pip] msgpack-numpy (0.4.3.2)
[pip] numpy (1.15.2)
[pip] torch (1.0.0.dev20181002)
[pip] torchvision (0.2.1)
[conda] cuda92 1.0 0 pytorch
[conda] pytorch-nightly 1.0.0.dev20181002 py3.6_cuda9.2.148_cudnn7.1.4_0 [cuda92] pytorch
[conda] torchvision 0.2.1 py_0 fastai