Forums - snpe-pytorch-to-dlc conversion error

3 posts / 0 new
Last post
snpe-pytorch-to-dlc conversion error
achalhoub
Join Date: 12 May 21
Posts: 6
Posted: Thu, 2022-01-20 13:20

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
  • Up0
  • Down0
weihuan
Join Date: 12 Apr 20
Posts: 270
Posted: Thu, 2022-02-10 21:02

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

  • Up0
  • Down0
chausner
Join Date: 9 Mar 22
Posts: 5
Posted: Thu, 2022-03-17 09:17

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....

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.