com.facebook.jni.CppException: version_ <= kMaxSupportedFileFormatVersion

I am trying to integrate keypoint_rcnn on android. But after solving errors i succeeded to generate .pt file using following script with torch 1.5 and torchvision 0.6.0

import torch
import torchvision

model = torchvision.models.detection.keypointrcnn_resnet50_fpn(pretrained=True)
model.eval()
example = torch.rand(1, 3, 800, 800)
traced_script_module = torch.jit.script(model, example)
traced_script_module.save("/home/bemrr/Desktop/model4.pt")

But now while installing it on android device, error is like this:

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.helloworld/org.pytorch.helloworld.MainActivity}: com.facebook.jni.CppException: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at …/caffe2/serialize/inline_container.cc:132, please report a bug to PyTorch. Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 2. Your PyTorch installation may be too old. (init at …/caffe2/serialize/inline_container.cc:132)

Thats why I am assuming that as my gradle dependency is like

implementation 'org.pytorch:pytorch_android:1.4.0'
implementation 'org.pytorch:pytorch_android_torchvision:1.4.0'

is incompatible with .pt file which is generated using torch 1.5, so I want to take a pull from latest pytorch repo and then build torch mobile using source. But I can not find any good instructions anywhere. Can someone please help me?

(See the section “Building PyTorch Android from Source”)