Quantcast
Channel: JetsonHacks
Viewing all articles
Browse latest Browse all 339

Jetson Nano – Use More Memory!

$
0
0

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:

Background

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.

Installation

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

$ https://github.com/JetsonHacksNano/installSwapfile
$ 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.

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. 

Also, you may want to be a little more hard core about your swap area. You can set aside a ‘swap partition’ and use that instead of a swap file. This approach may be faster because the swap area is set aside contiguously. This route is similar to setting up a swap file, but is beyond the scope of this article.

Conclusion

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.

The post Jetson Nano – Use More Memory! appeared first on JetsonHacks.


Viewing all articles
Browse latest Browse all 339

Trending Articles