Jetson Nano – Use More Memory!

Jetson Nano Swapfile FF

The NVIDIA Jetson Nano Developer Kit has 4 GB of main memory. This may not enough memory for running many of the large deep learning models, or compiling very large programs. Let’s fix that! We are going to install a swapfile. Looky here:


There may be times when you are running your Jetson Nano when the screen suddenly freezes. You may have a lot of browser tabs open, or be running multiple YouTube videos, or other memory hungry applications.

If you are a developer, or are loading large trained models, sometimes in the Terminal console you will see your program aborted with the simple word ‘Killed’. More than likely, this is because you ran out of memory.

The Jetson Nano has 4 GB of RAM. Sometimes this is not enough for big jobs. Fear not! There is a feature in the Linux kernel, called a swapfile, which implements paged memory. You can read all about swapfiles here: Ubuntu Swap FAQ.


On the JetsonHacksNano account on Github, there is a repository named installSwapFile. Clone the repository, and then switch over to the repository directory:

$ cd installSwapfile

Here’s the usage instruction:

usage: installSwapFile [[[-d directory ] [-s size] -a] | [-h]]

All of the arguments are optional. The default is for a 6GB swapfile to be created in the directory /mnt. The -a flag indicates whether the swapfile should be automatically be loaded on boot. If the swapfile is to be loaded at boot time, make sure that the location is mounted when the machine boots.

Here’s an article on how to setup automount for external devices.

You can run the default:

$ ./installSwapfile

and a 6 GB swapfile will be installed at /mnt/swapfile

Note: You will need to have enough extra room on your device to install the swapfile.

For the 4 GB Jetson Nano, the 6 GB swapfile is what Ubuntu recommends assuming that you are using hibernation. Otherwise 2 GB should do.

In the video, the swap file is auto mounted when the machine boots. This is great for development, but afterwards you may want to disable that feature. To do so:

$ sudo gedit /etc/fstab

and comment out the line that does the ‘swapon’. Make sure to save the file, reboot and check to make sure that swap is off. 


It’s been noted in the comments that many people are against using a swapfile on the micro SD card. This is a for a variety reasons (mostly due to wear patterns and eventual failure of the SD card, and poorer performance), and is certainly a valid viewpoint.

There is certainly alternative, equally valid, viewpoints. Some of the previous experience that people mention comes from using a Raspberry Pi for long periods of time. One note, the Raspberry Pi in general have 1GB or less of memory; a Jetson Nano has 4GB. It is unlikely it will be swapping memory as much. Also, you can set the “swappiness” lower so that Linux is less eager to swap memory.

Of course, you are not limited to keeping your swapfile on a SD card, you could put it on a USB SSD. The SSD has better wear leveling algorithms. As an alternative, you could even use a USB Hard Disk Drive (HHD) which isn’t as susceptible to this issue.

You are also not forced to always use a swapfile. You may only want to use it for certain tasks, such as compiling large programs, or loading large deep learning models.

Certainly a developer/power user wants to be able to use the resources available to them. Professional users view removable media as consumables, and do not hesitate using/abusing them for their full life time. They also make backups in case of failure.


This is a pretty simple way to make your Jetson Nano much more responsive, and provide more memory for those large builds and deep learning models.