Skip to content

Instantly share code, notes, and snippets.

@szagoruyko
Last active July 29, 2017 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szagoruyko/4cbbba5ac8b53b0fe32f43e7b3d0cda6 to your computer and use it in GitHub Desktop.
Save szagoruyko/4cbbba5ac8b53b0fe32f43e7b3d0cda6 to your computer and use it in GitHub Desktop.

Setting up cron to clear page cache periodically

This is usefull for ImageNet training when it loads a ton of images which are kept in page memory until training starts to lag.

Assume we are on Ubuntu.

First, create a cron job from root:

sudo crontab -e

And add this lines:

*/15 * * * * date >> /root/cronlog.txt && sync && /sbin/sysctl -w vm.drop_caches=3

Yes, keeping the empty line in the end. This will clear pages every 15 minutes.

Resources:

  1. http://askubuntu.com/questions/155768/how-do-i-clean-or-disable-the-memory-cache
@pedropgusmao
Copy link

THANK YOU!!!!!! I have been struggling with this for about an year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment