Intro#
Today, when using CryoSPARC for Non-uniform Refinement, the task was terminated unexpectedly. After searching, it was determined that the process may have been killed by the system because of insufficient memory.
There are two ways to increase memory, one is to pay the money, and the other is to increase swap memory.
Because most tasks in the workflow do not have high memory requirements, and according to the task log, only a small amount of memory is needed to solve the problem, so plan to try to increase swap memory first.
Detailed procedure#
All of the following are from ChatGPT4 and are proven to work, with some modifications to ensure readability.
- Close the current swap file, open the terminal, and execute the following command:
sudo swapoff -a
-
You can do this with
dd
orfallocate
command,fallocate
is faster thandd
, but not all file systems support it.-
An example of using
fallocate
to resize a swap file to 8GB:sudo fallocate -l 8G /swapfile
-
If your system does not support
fallocate
, you can use thedd
command:sudo 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 permissions on swap files so that only root can read and write:
sudo chmod 600 /swapfile
- Set the file to a swap file:
sudo mkswap /swapfile
- Enable the new swap file:
sudo swapon /swapfile
- Perpetuate swap settings
To retain the swap setting after the system restart, you need to add it to the /etc/fstab
file. Open the /etc/fstab
file and add the following lines:
/swapfile swap swap defaults 0 0
In this way, the swap file is automatically enabled each time the system boots.
[!NOTE]
It seems that the
/swapfile
setting already exists in the/etc/fstab
file, so you can optionally skip the last step.
Outro#
After increasing the swap memory from 2G to 8G, the task was successfully completed. 800CNY saved, a good day.
此文由 Mix Space 同步更新至 xLog
原始链接为 https://xxu.do/posts/geek/Adjust-swap-memory-size-on-Ubuntu