Intro
Today, while running a Non-uniform Refinement job in CryoSPARC, the task was terminated unexpectedly. After some research, it appeared the process may have been killed by the system because of insufficient memory.
There are two ways to increase memory: spend money on more of it, or add swap space.
Since most tasks in the workflow don't have high memory requirements, and the task log indicated that only a small amount of additional memory was needed, I decided to try increasing the swap space first.
Detailed procedure
The following instructions are from ChatGPT4 and have been verified to work, with minor edits for readability.
- Open a terminal and disable the current swap file:
sudo swapoff -a
Create or resize the swap file with either
ddorfallocate.fallocateis faster, but not all file systems support it.Example using
fallocateto resize the swap file to 8GB:BASHsudo fallocate -l 8G /swapfileIf your system doesn't support
fallocate, useddinstead:BASHsudo dd if=/dev/zero of=/swapfile bs=1G count=8 # `bs=1G` indicates that each time a 1GB is written,`count=8` indicates that 8GB total written。
Set the permissions on the swap file so that only root can read and write:
sudo chmod 600 /swapfile
- Set up the file as a swap file:
sudo mkswap /swapfile
- Enable the new swap file:
sudo swapon /swapfile
- Make the swap setting persistent
To retain the swap setting after the system restarts, add it to the /etc/fstab file. Open /etc/fstab and add the following line:
/swapfile swap swap defaults 0 0
This way, the swap file is enabled automatically each time the system boots.
It seems that the /swapfile entry already exists in /etc/fstab, so you can optionally skip the last step.
Outro
After increasing the swap space from 2G to 8G, the task was completed successfully. 800 CNY saved—a good day.