Jetson TX1 Swap File and Development Preparation

Adding a swapfile and doing some preparation for development is one of the first things to do after flashing a NVIDIA Jetson Development Kit. Looky here:

Background

Over the last couple of years, the software capabilities of the Jetson Development Kits have increased dramatically. JetPack does a great job of keeping track and installing the many software libraries and Jetson specific software packages and demos. However, this does come at a cost. Because the Jetson Development Kit has a relatively small “hard drive” and a limited amount of memory, sometimes development can get bogged down a bit because of lack of system resources.

Fortunately, there are work arounds. Some of the larger programs and applications out there, such as TensorFlow and ROS to name just a couple, require more memory to build than the Jetson has available. A good work around for this is to use what is called a swap file, which allows the Jetson to use disk space as virtual memory. We talked about this in an earlier article.

Also, sometimes we would like to reclaim some of that disk space used by the installed software and demos, and repurpose it for development. In the video, we show how to get rid of some of the low hanging fruit.

Getting to Work

The video was performed directly after flashing the Jetson using JetPack 2.3.1. JetPack installed:

  • L4T 24.2.1
  • CUDA 8.0
  • cuDNN 5.1

which is need for the project that I’m currently working on. Other libraries and demos were also installed such as VisionWorks.

On the JetsonHacks account on Github, there is a repository named postFlashTX1 which contains some convenience scripts for creating a swap file and reclaiming some of the disk space from some applications that sometimes are not used on development machines.

Swapfile

In the video, a 250GB Samsung EVO 850 SSD is connected to the Jetson TX1. The SSD is formatted as ext4. In order to create a swap file:

$ sudo ./createSwapfile.sh -d [directory location] -s [size in gigabytes] -a

All of the arguments are optional. The default is for a 8GB swapfile to be created in the current directory. 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 to set up the media that it is on so that it is available when the machine boots.

For the 4 GB Jetson TX1, a 8 GB swapfile is a good size. The rule of thumb for the swap file size is about 2X real memory size. Also, try to place the swapfile on external media that is as fast as possible. While you can place the swapfile on a USB stick or SD card, note that there will be a real performance hit when compared to placing it on a SSD.

Important Note

Setting up a swapfile on a SSD or other flash type memory can lead to wear of the device. Most current flash memory has a lifetime number of reads and writes it can perform, a busy swap file can consume a good chunk of those. Note that this is also true of hard drives. Newer SSDs have built in mechanisms to help distribute the “write wear”. As always, make backups of your drives and store them away.

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.

More stuff

The other convenience files in the repository do some more cleanup work.

$ ./uninstallLibreoffice.sh

Will remove the Libre Office suite from the machine. While these are useful tools, they may not be needed for a development machine.

$ ./uninstall_unity_scope.sh

Will remove a lot of the links which support desktop like activities, such as shopping.

Conclusion

This is just a general purpose rough cut to get started on getting the machine ready for development. Obviously the development environment needs to reflect the applications that are being built. However, more memory and some more disk space is a real fine way to start.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


%d bloggers like this:
Skip to toolbar