Skip to content

Instantly share code, notes, and snippets.

@ennanco
Last active September 19, 2022 15:40
Show Gist options
  • Save ennanco/1f4edbb2f41203d9020d57d1fb710a4b to your computer and use it in GitHub Desktop.
Save ennanco/1f4edbb2f41203d9020d57d1fb710a4b to your computer and use it in GitHub Desktop.
Change the size of the swap in Linux

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
#!/usr/bin/env bash
sudo swapoff -a
fallocate -l 32G /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment