Amphetamine

From Stat DS Computing Wiki


Modern laptops implement several functionalities to reduce power usage, e.g. by putting drives to sleep, dimming the display, or going into sleep or hibernate modes. This is especially true for Macs.

What if you need your laptop to stay awake?

For example, what if you're giving a presentation, or you have a job running locally either from the terminal or from a Python notebook in VSCode? Enter Amphetamine!

DISCLAIMER: We do not recommend running very long scripts on your local machine to the point that you need extra software to keep it awake. Instead, we recommend using external compute resources (see Department Servers for more information).

What is Amphetamine?

Amphetamine.png

Amphetamine is a free utility by William Gustafson that lets you click, schedule, or trigger Mac alertness from the menu bar. 

In the simplest case, you can choose an item from the menu: Indefinitely keeps your Mac awake until canceled, but you can also select a duration, while a given app remains running, or until a file is downloaded. The last one, for example, works by asking you to pick an observation interval after which Amphetamine checks if the file has changed in size so it can predict that the file has completed its download.

For research purposes, Amphetamine comes particularly handy when we need a process to keep running in the background without having to monitor the laptop constantly to avoid it going to sleep. This happens especially often with VSCode when connected to a remote machine via SSH. If a Jupyter notebook is running through a remote ssh connection, any cell running will be interrupted if the connection drops, which happens if the Mac goes to sleep. Amphetamine easily prevents this issue: it's enought to start a session indefintely and stop it when the job has finished. 

Keep an eye on your battery consumption though! The price to pay for Amphetamine sessions (especially those that prevent any kind of sleep mode) is increased battery consumption. 

Amphetamine Enhancer

Amphetamine Enhancer is a helper application that enhances a couple of Amphetamine's features. In its 1.0 release, Amphetamine Enhancer adds the following abilities to Amphetamine:

• Adds a fail-safe for the closed-display mode feature found in Amphetamine 5.0+
• Gives Amphetamine 5.0+ the ability to use all running processes with Triggers and app-based sessions

Download

For Mac users, the app is freely available on the App Store. Windows users can download Amphetamine from the Microsoft Store.

Amphetamine Enhancer is freely available for download on Github.

Check this article for a guide on how to install Amphetamine for Ubuntu.