[SOLVED] RPi V2.1 cam freezes while following Nvidia's course on Jetson Nano 2gb

I bought a Jetson Nano 2gb only to follow Nvidia’s course Getting Started with AI on Jetson Nano, but i’m stuck at Thumbs project under Image classification.
After following the instructions and completing the training of the model, my Raspberry Pi Cam V2.1 freezes and I cannot use it anymore to test the model. I tried to restart the (Python) kernel on the notebook, and even to run again the Docker container, but the only way I can use the camera again is to reboot the Jetson Nano.

The error message I get from the Jupyter Notebook (second code cell, when the camera object is created) when I try to start once again is:

RuntimeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/csi_camera.py in init(self, *args, **kwargs)
23 if not re:
—> 24 raise RuntimeError(‘Could not read image from camera.’)
25 except:

RuntimeError: Could not read image from camera.

During handling of the above exception, another exception occurred:

RuntimeError Traceback (most recent call last)
7 # for CSI Camera (Raspberry Pi Camera Module V2), uncomment the following line
----> 8 camera = CSICamera(width=224, height=224, capture_device=0) # confirm the capture_device number
10 camera.running = True

/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/csi_camera.py in init(self, *args, **kwargs)
25 except:
26 raise RuntimeError(
—> 27 ‘Could not initialize camera. Please see error trace.’)
29 atexit.register(self.cap.release)

RuntimeError: Could not initialize camera. Please see error trace.

I sometimes get a Sytem throttled due to overcurrent message, but I’m using a trusted power supply (Lenovo) that provides 5v 3A. I tried Jetson’s 5W power mode and nothing changed.

As said, even after terminating the Docker container, I cannot use the camera. If I run gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink I get:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:568 Failed to create CaptureSession
Got EOS from element "pipeline0".
Execution ended after 0:00:00.005206323
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

The Raspberry Pi Cam V2.1 is connected correctly to the CSI port, there is nothing connected to the 2gb Jetson Nano besides the microSD, the power supply (USB 3) and the microUSB cable for SSH access from my laptop, from which I run the Jupyter Notebook on Firefox.

After trying a lot of stuff, like killing the graphic session (sudo systemctl stop --now lightdm) on the Nano for extra 300mb of RAM and seeing some improvement, I changed the Swapfile’s priority to 10 and incremented the swapiness to the maximum editing /etc/fstab and /etc/sysctl.conf.

Nevertheless, a bit later on the course (“Face XY Project”) I faced the same problem, and this time not even that made the cam survive the heavy memory hungry training. I also deactivated the zram module. I’m giving up, I will return my useless Jetson Nano 2gb.

So the issue got resolved or not? Any suggestion required?

The C++ and Python version of the course Hello AI World(built from source) works and does basically the same, so I found the Docker container (the only option presented for the Getting Started with AI on Jetson Nano course) wastes a lot of valuable memory. My solution was to run the code outside the Docker container, after finding and building all the dependencies. A guide for doing so when following the course with a 2gb Jetson Nano would be useful for others.

EDIT: After some research on Docker containers, I found that if a container or other processes start consuming more and more memory, Linux will start killing processes by throwing Out of memory exception and there is no guarantee which process Linux will kill.
Maybe limiting the memory available for the container will save the Camera process from being killed.