Issues with jupyter notebook collision avoidance example

Hi everyone!

I’m trying to go through the collision avoidance notebook, which I acces through the jupyterlab server running on the Nano (just like stated in the setup tutorial).

Everything worked just fine until I got to the live_demo_resnet18.ipynb notebook. I can run the first two cells in the notebook and load in my trained model with torch, but when I get to the thord cell, which is:

device = torch.device(‘cuda’)
model = model.to(device)
model = model.eval().half()

I get the following error message:
NameErrorTraceback (most recent call last)
in
----> 1 device = torch.device(‘cuda’)
2 model = model.to(device)
3 model = model.eval().half()

NameError: name ‘torch’ is not defined

Which I can’t understand, because I get that it means that either torch is not installed or it isn’t imported into the script, but since torch is installed on the Nano (I can import it from the command line on the device) and it is imported into the script in the very first cell of this notebook…I truly feel myself a bit lost.

I noticed something, which can be important in solving my problem, after I execute the second cell of the notebook, which is:

model.load_state_dict(torch.load(‘best_model_resnet18.pth’))

the kernel says Busy -> Restarting -> Idle which is quite strange I don’t understand why does it need to restart. Perhaps that’s the point where it forgets that torch was already imported into the script? If this is the case how can I prevent it from restarting?

The link to this notebook: https://github.com/NVIDIA-AI-IOT/jetbot/blob/master/notebooks/collision_avoidance/live_demo_resnet18.ipynb

I’m using the JP 4.4.1 SDK

Thanks in advance!

Hi,

PyTorch may take some time to load the model, please run the 3rd command after the previous one is finished.
If the error remains, could you share the log or screenshot (generated from the second steps) with us first?

Thanks.

Thank you for the instructions.

I ran all the cells after the kernel was in idle state as you advised, but it resulted in just the same output.

After I run the 2nd cell I get no error message nor log. I made screenshots of each phase of running the cell, which you can see below:

After restarting as I mentioned before the kernel goes back to idle without displaying any error message.

What is interesting though is that if I try to run the 2nd cell again (just after I have already run it once) I get the following error message:
pic4

Which (as far as I’m concerned) indicates the same thing namely the kernel somehow forgets everything which has happened in the first cell. Perhaps because it restarted itself.

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

Hi,

Sorry for the late update.

Since Nano has limited resources, it may fail to load the model and get stuck.
Would you mind to monitor the device at the same with tegrastats and share the log output with us?

$ sudo tegrastats

Thanks.