Creating a Swap file

Today I was trying to train the complete CIFAR-10 dataset on Xavier. The CIFAR-10 dataset is 60,000 32x32 RGB images. After installing Tensorflow I decided to give it a go. My 2.1 GB of memory usage soared to over the 15.4 GB limit during training. Then my Xavier froze. This is no good. The short term solution was to create a 8GB Swap file.

  1. -$ df -h
    This will show your file system and how much space you have left.

  2. -$ sudo fallocate -l 8.0G /swapfile
    Create a 8 GB of swap

  3. -$ sudo chmod 600 /swapfile
    Change file permissions

  4. -$ sudo mkswap /swapfile

  5. -$ sudo swapon /swapfile

  6. -$ free -m
    This will show you the swap file is on. You can also pull up the System Monitor
    However this is only temporary. If you reboot, swap file is gone.

  7. -$ sudo nano /etc/fstab

  8. Within this file add the line “/swapfile none swap 0 0”. Do not include the quotes.
    Exit and save file

  9. Now you can reboot and your Swap will be activated.

  10. Then you can successfully train the CIFAR-10 dataset.

Ideally you would want to create a swap partition on an attached SSD or M.2 SSD and not use any of the internal memory.

Thanks GeForceX. I just picked up a NVMe SSD today. I will appreciate the extra space.
[url]Amazon.com

Can you directly boot off of it? I know with the TX2 there was a procedure by JetsonHacks.

Unfortunately, /etc/fstab is way too late in the lifecycle to tell the Jetson where to boot from.

The TX2 boot selector used the uboot boot loader and re-configured it; Xavier uses some new kind of boot system that’s not uboot, so the uboot-specific approach won’t work. (You can see other threads where people are unhappy that you can’t even select which kernel to boot right now, much less what device to boot from.)

I’m able to boot from NVME directly based on the tutorial here: Boot Jetson Xavier from M.2 NVMe SSD - Latest Open Tech From Seeed

1 Like