Last active
June 23, 2022 17:11
-
-
Save reisenmachtfreude/52ab227a8ae502a7c75a31f16c77991d to your computer and use it in GitHub Desktop.
Backtrader runs out of memory fixed by increasing Ubuntus SWAP memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For some backtests with large data python library backtrader runs out of memory and freezes the system | |
# Since I use Ubuntu I can prevent this by increasing available SWAP memory | |
# Add more SWAP memory | |
sudo fallocate -l 10g /mnt/additional.swap # Create a file with a fixed size | |
sudo chmod 600 /mnt/additional.swap # Set needed permissions in order to use as SWAP file | |
sudo mkswap /mnt/additional.swap # Format as swap file | |
sudo swapon /mnt/additional.swap # Use NOW as SWAP temporarily | |
echo '/mnt/additional.swap swap swap defaults 0 0' | sudo tee -a /etc/fstab # Use permanently as SWAP | |
# Test if the system recognise the SWAP file | |
cat /proc/swaps | |
# Read for reference: https://help.ubuntu.com/community/SwapFaq | |
#Try on debian 10 VPS(works with KVM but not with LXC) | |
fallocate -l 2g /mnt/additional.swap | |
chmod 600 /mnt/additional.swap | |
/sbin/mkswap /mnt/additional.swap | |
/sbin/swapon /mnt/additional.swap #Error: swapon: /mnt/additional.swap: swapon failed: Operation not permitted | |
# Seems that this is not allowed on VPS using OpenVZ | |
https://unix.stackexchange.com/questions/2893/swapon-operation-not-permitted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment