# Jetson Nano - using old version pytorch model

**URL:** <https://forums.developer.nvidia.com/t/jetson-nano-using-old-version-pytorch-model/178618>\
**Category:** Jetson Nano\
**Tags:** pytorch\
**Created:** [May 21, 2021, 10:12am UTC](https://forums.developer.nvidia.com/t/jetson-nano-using-old-version-pytorch-model/178618 "2021-05-21T10:12:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joseslava](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@joseslava](https://forums.developer.nvidia.com/u/joseslava)\
**Post date:** [May 21, 2021, 10:12am UTC](https://forums.developer.nvidia.com/t/jetson-nano-using-old-version-pytorch-model/178618/1 "2021-05-21T10:12:47Z")

</div>

Hello,

I am currently trying to use a pytorch model done with pytorch 1.0. I am doing a C++ code to load the model using torch script like this: module = torch::jit::load(net\_fn);

First I tried to use JetPack 4.3 with pytorch 1.1 and I successfully used the model.

Now I am trying to use JetPack 4.5 with pytorch 1.8, I did the following sequence:

- I open load my model with pytorch 1.2 and I saved it again, then with pytorch 1.3, then pytorch 1.5 until getting the model on pytorh 1.8:  
[gcn2\_640x480\_conv18.pt](https://forums.developer.nvidia.com/uploads/short-url/meKJmFEJt1mT9bFoQHIRqi0UMcM.pt) (13.9 MB)

- Then I tried to use this model with pytorch 1.8 on Jetson Nano but I got this error:

terminate called after throwing an instance of ‘std::runtime\_error’  
what(): The following operation failed in the TorchScript interpreter.  
Traceback of TorchScript, serialized code (most recent call last):  
File “code/ **torch**.py”, line 65, in forward  
\_14 = torch.to(\_11, dtype=4, layout=0, device=torch.device(“cuda:0”), pin\_memory=False, non\_blocking=False, copy=False, memory\_format=None)  
\_15 = torch.to(\_13, dtype=4, layout=0, device=torch.device(“cuda:0”), pin\_memory=False, non\_blocking=False, copy=False, memory\_format=None)  
\_16 = torch.unsqueeze(torch.index(det, [\_14, \_15]), 1)  
~~~~~~~~~~~ \<— HERE  
pts = torch.cat([\_6, \_9, \_16], 1)  
\_17 = torch.slice(pts, 0, 0, 9223372036854775807, 1)

Traceback of TorchScript, original code (most recent call last):  
File “code/gcn2\_640x480\_conv11.py”, line 42, in forward  
\_12 = torch.to(\_9, dtype=4, layout=0, device=torch.device(“cuda:0”), pin\_memory=False, non\_blocking=False, copy=False)  
\_13 = torch.to(\_11, dtype=4, layout=0, device=torch.device(“cuda:0”), pin\_memory=False, non\_blocking=False, copy=False)  
\_14 = torch.unsqueeze(torch.index(det, [\_12, \_13]), 1)  
~~~~~~~~~~~ \<— HERE  
pts = torch.cat([\_4, \_7, \_14], 1)  
\_15 = torch.slice(pts, 0, 0, 9223372036854775807, 1)  
RuntimeError: Tried to cast a List to a List\<Tensor?\>. Types mismatch.

./run.sh: line 24: 9346 Aborted (core dumped) ./Examples/Monocular/mono\_webcam

Could you please give me some highlights to solve this problem?

Regards.

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [May 24, 2021, 3:11am UTC](https://forums.developer.nvidia.com/t/jetson-nano-using-old-version-pytorch-model/178618/3 "2021-05-24T03:11:07Z")

</div>

Hi,

Do you mean you can serialize and de-serialize the model with v1.2, v1.3 and v1.5.  
But only get the error with v1.8?

If yes, have you tried to load the file serialized with v1.5?  
Thanks.

---

<div class="post-metadata">

**Author:** ![joseslava](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@joseslava](https://forums.developer.nvidia.com/u/joseslava)\
**Post date:** [May 24, 2021, 8:45am UTC](https://forums.developer.nvidia.com/t/jetson-nano-using-old-version-pytorch-model/178618/4 "2021-05-24T08:45:55Z")

</div>

Hello,

I only tried to de-serialize and use the model with Pytorch 1.1 and 1.8.

For Pytorch 1.2 , 1.3 , 1.5 , I only loaded and saved the model in order to have a more recent pt file format because I thought that the format was the problem.  
To be clear, I loaded and save the model with this script (where gcn2\_640x480\_conv15.pt is the model on Pytorch 1.5 and gcn2\_640x480\_conv18.pt is the resulting model on pytorch 1.8):

import torch

orig\_model = torch.jit.load(“gcn2\_640x480\_conv15.pt”)  
orig\_model.save(“gcn2\_640x480\_conv18.pt”)

For Pytorch 1.8 I tried to de-serialize and use the model and I got the error I described. I actually need to work with Pytorch 1.8 because the camera drivers I have are not compatible with older JetPacks.

Regards.

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [June 8, 2021, 6:00am UTC](https://forums.developer.nvidia.com/t/jetson-nano-using-old-version-pytorch-model/178618/5 "2021-06-08T06:00:49Z")

</div>

Hi,

We try to reproduce this, but the serialization works good in our environment.  
Below is our testing details for your reference:

- JetPack 4.5.1
- PyTorch 1.8.0 from **[here](https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-8-0-now-available/72048)**

```auto
$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> orig_model = torch.jit.load("gcn2_640x480_conv18.pt")
>>>

```

Thanks.

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 15, 2021, 3:20am UTC](https://forums.developer.nvidia.com/t/jetson-nano-using-old-version-pytorch-model/178618/7 "2021-10-15T03:20:36Z")

</div>

Closed on October 15, 2021, 3:20am UTC


