When I am performing a Deep Learning training, one problem that I have from time to time due to size of the datasets and architectures is running out of memory on my desktop pc. In Linux you can solve this on the fly, you have only to write the following commands on a terminal. The following bash commands should made the trick to set a 32Gbytes swapfile on that session.
sudo swapoff -a
fallocate -l 32G /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile