Hello,
I am trying to work through converting a PyTorch '.pt' file to DLC. However, I am getting the following error:
RuntimeError: PytorchStreamReader failed locating file constants.pkl: file not found
I have tried performing the training and conversion using PyTorch v1.6, 1.8, and 1.10 (all of which result in the same error).
The task I am performing is training the DeepLabv3 Resnet101 PyTorch model on a custom dataset. The final model is saved using torch.save()
The source code I am using for training can be found here: https://github.com/msminhas93/DeepLabv3FineTuning
The full output received after running the command is the following:
2022-01-20 16:18:53,379 - 209 - ERROR - Encountered Error: PytorchStreamReader failed locating file constants.pkl: file not found
Traceback (most recent call last):
File "/home/achalhoub/dev/snpe-1.55.0.2958/bin/x86_64-linux-clang/snpe-pytorch-to-dlc", line 46, in main
converter = PyTorchConverterFrontend(args)
File "/home/achalhoub/dev/snpe-1.55.0.2958/lib/python/qti/aisw/converters/pytorch/pytorch_to_ir.py", line 23, in __init__
**kwargs)
File "/home/achalhoub/dev/snpe-1.55.0.2958/lib/python/qti/aisw/converters/relay/relay_to_ir.py", line 242, in __init__
self.importer.convert_to_relay(self.input_model_path)
File "/home/achalhoub/dev/snpe-1.55.0.2958/lib/python/qti/aisw/converters/relay/importers/pytorch_importer.py", line 138, in convert_to_relay
pytorch_model = torch.jit.load(input_model_path)
File "/home/achalhoub/.local/lib/python3.6/site-packages/torch/jit/_serialization.py", line 161, in load
cpp_module = torch._C.import_ir_module(cu, str(f), map_location, _extra_files)
RuntimeError: PytorchStreamReader failed locating file constants.pkl: file not found
free(): invalid pointer
Aborted (core dumped)
I would appreciate any support!
Thanks,
Ahmad
Dear customer,
Could you please help to convert the pytroch model to ONNX replacement and try it again? That action may convert successfully for your model.
BR.
Wei
I ran into the same error. The solution is to first convert the PyTorch model to TorchScript as is documented at https://developer.qualcomm.com/sites/default/files/docs/snpe/model_conv_... and https://pytorch.org/tutorials/advanced/cpp_export.html#converting-to-tor....