I am trying to import a pytorch model in tvm. I run the following code to get the torchscripted model from tracing.
model_name = "resnet18" model = getattr(torchvision.models, model_name)(pretrained=True) model = model.eval() input_shape = [1, 3, 224, 224] input_data = torch.randn(input_shape) scripted_model = torch.jit.trace(model, input_data).eval()
But I get this error:
libc++abi: terminating with uncaught exception of type pybind11::stop_iteration:
Fatal Python error: Aborted
In torch/jit/_trace.py", line 417 in graph_diagnostic_info.
I found out that the error occurs when the torch tries to iterate through a Dict. Any idea on how to solve this?
I build torch with libstdcpp and tvm with libcpp. I suspected that this might be the cause of this.
Since I cannot build tvm with libstdcpp, I tried building torch with libcpp but I still get the same error. When I get dir on the Dict variable which is casusing the error, I see pybind11_module_local_v4_clang_libstdcpp_cxxabi1002. So, it seems that pybind11 is still using libstdcpp. How to build pybind11 submodule with libcpp?