Alright so here’s the solution I found
tl;dr
- Flash a large SD card
- Make sure your camera works
- Set your swap to anything 8GB or larger
- Set the resources for the container when you run it.
The long version
- Flash a large SD card
Because we’re going to use at least 8GB for swapping and potentially more in the future, I went for a 128GB SD card. The larger, the better is my guess.
- Make sure your camera works
Yeaah, that one sort of puzzled me because of the whole unresponsive page situation but what I figured out is that I could tell that the camera wasn’t working just by running this:
gst-launch-1.0 nvarguscamerasrc sensor_id=0 ! nvoverlaysink
if what you are getting looks like:
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3264 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 3264 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1640 x 1232 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 2
Output Stream W = 1920 H = 1080
seconds to Run = 0
Frame Rate = 29.999999
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
you’re good. If you’re getting any sort of error, try reseating your camera and make sure that the cable is facing the right way. If along the way, your camera stops responding and you get an error when running this line of code, the only solution I can offer is to reboot.
- Set your swap to anything 8GB or larger
Now, the instructions sort of differ from my experience and here’s what I did. I set up the Jetson with a screen and a keyboard like normal, and I selected the default swap size. I’m assuming you could choose not to create a swap file and then do the next steps but using the default options worked for me. I ended up with a swap of 4GB, give or take, which could be verified by running:
free -h
the -h stands for “human readable” and it’s just to make it easier to figure out how much we’ve got without having to convert from kibibi or mebibi or whatever bibi option they chose (don’t come at me, I find it hilarious to call them bibi’s and there’s nothing you can do to change my mind).
Then I basically followed the steps in the tutorial.
sudo systemctl disable nvzramconfig
sudo fallocate -l 4G /mnt/4GB.swap
sudo chmod 600 /mnt/4GB.swap
sudo mkswap /mnt/4GB.swap
I went for 4GB here because 1. I already had 4GB and figured 8GB would be enough and 2. I’m lazy. Then:
mkdir -p ~/nvdli-data
sudo vim /etc/fstab
then type "i", navigate to the end of the file with your keyboard arrows and type at the end of the file :
/mnt/4GB.swap swap swap defaults 0 0
then ctrl-c and “:wq” to write and quit. That will append that line to the file that determines how much more resources are allocated.
We’re now at 4GB as defined when we first set up the jetson + 4GB that we just added. I haven’t checked whether it made a difference to create just one big swap file but I’m assuming that since it’s fairly small and we’re not looking at stellar performances anyway, it might not be worth the hassle. I found that 8GB total might be a minimum here.
- Set the resources for the container when you run it
For some weird reason that I can’t explain right now, the container runs better if you set what it can use when running it, even though I haven’t seen a difference in actual usage with or without the arguments. I’m assuming there’s some process that can’t be bumped to swapping because it’s slower but note that setting swap to anything less than 8GB didn’t work for me even though it only uses about 1.7GB of swap. Very strange.
Now, if you’ve done everything using the GUI, with a screen and a keyboard plugged directly into the Jetson, you’ll want to unplug all that and ssh into your machine. Running a window manager (what you see on the screen) will hog up all of your precious 2GB of RAM and it’s not required. So the final line to run is
sudo docker run --runtime nvidia -it --rm --network host --volume ~/nvdli-data:/nvdli-nano/data --volume /tmp/argus_socket:/tmp/argus_socket --memory=500M --memory-swap=8G --device /dev/video0 nvcr.io/nvidia/dli/dli-nano-ai:v2.0.1-r32.4.4
I set the version to v2.0.1-r32.4.4 so you can just copy-paste it as of November 2020 but be careful with the version, people of the future! How did 2020 end by the way? Hope it didn’t get any worse because wow, what a roller coaster.
And there you have it! You can play around with the tutorials but remember to set the camera to CSI camera in the notebooks or it won’t work.
Phew!