Blog
How to Run a GROMACS MD Simulation on Google Colab (Free GPU, No Install)
- July 3, 2026
- Posted by: Stem Skills Lab
- Category: Molecular Modeling

To run GROMACS on Google Colab, switch the runtime to a GPU (Runtime, Change runtime type, T4 GPU), install GROMACS in the notebook with condacolab and conda-forge, then run your usual gmx grompp and gmx mdrun commands. Save the trajectory to Google Drive before the session ends, because Colab wipes local storage on disconnect. This gives you free GPU-accelerated MD without installing anything on your own machine.
Most students do not own a workstation with a CUDA GPU, and installing GROMACS with GPU support locally can be a half-day of dependency wrangling. Google Colab hands you a free GPU in the browser, which is enough to run real molecular dynamics on small protein systems. This guide shows the full path: enabling the GPU runtime, installing GROMACS in the notebook, running a simulation, and getting your results out before the session resets.
This is a spoke in our learn molecular dynamics with GROMACS series. For the bigger picture of where cloud computing fits into a research skill set, see the computational biology skills roadmap.
Why run GROMACS on Colab instead of your laptop?
Molecular dynamics is GPU-bound. A simulation that crawls on a laptop CPU can run an order of magnitude faster on even a modest GPU, because GROMACS offloads the expensive non-bonded force calculations to the device. Google Colab’s free tier typically assigns an NVIDIA T4, which is far more capable for MD than a typical integrated laptop GPU. You also skip installation entirely: no compilers, no CUDA toolkit setup, no fighting with library versions on your own operating system.
The catch is that Colab sessions are temporary. The free tier disconnects after a period of inactivity and caps total session length, and when a session ends the virtual machine’s local disk is erased. That single fact shapes the whole workflow: anything you want to keep must be copied to Google Drive while the session is alive.
How do you enable the free GPU runtime?
Open a new notebook at colab.research.google.com. From the menu, choose Runtime, then Change runtime type, and under hardware accelerator select T4 GPU. Save, and the notebook reconnects to a GPU-backed machine.
Confirm the GPU is actually attached before you do anything else:
!nvidia-smiThis prints the GPU model, driver version, and memory. If you see a Tesla T4 and a few gigabytes of free memory, you are ready. If the command reports no devices, the runtime did not switch; repeat the runtime-type step. Note that the Colab usage limits and available accelerators are described in the Google Colab FAQ, and the free tier is allocated dynamically, so the exact GPU can vary.
How do you install GROMACS in a Colab notebook?
The most reliable installation route is the conda ecosystem, because conda-forge ships prebuilt GROMACS binaries including CUDA-enabled variants. First install condacolab, which configures conda inside the notebook and restarts the kernel once:
!pip install -q condacolab
import condacolab
condacolab.install()The kernel will restart automatically after this cell. That is expected; do not re-run the cell. Once it reconnects, install GROMACS from conda-forge:
!mamba install -y -c conda-forge gromacsTo request a CUDA-enabled build specifically, you can constrain the package variant, then verify what you got:
!gmx --versionRead the version output carefully. It lists whether GPU support is compiled in and which acceleration is available. Because conda-forge offers both CPU-only and CUDA builds and the resolver picks based on the environment, always confirm from gmx --version that GPU support is present rather than assuming it. The official installation reference is the GROMACS installation guide, which documents the build options behind these packages.
| Concern | Local install | GROMACS on Colab |
|---|---|---|
| GPU access | Only if you own a CUDA GPU | Free T4 (subject to availability) |
| Setup time | Hours (toolkit, compilers) | Minutes (condacolab) |
| Cost | Hardware cost | Free tier |
| Persistence | Permanent | Wiped on disconnect; save to Drive |
| Max run length | Unlimited | Limited by session timeout |
| Best for | Long production runs | Learning, short runs, prototyping |
How do you connect Google Drive so your files persist?
Mount your Drive at the start of every session. This makes a folder on your Google Drive appear as a normal path inside the notebook:
from google.colab import drive
drive.mount('/content/drive')Approve the access prompt. Now create a project folder on Drive and work from there, so input files and outputs survive a disconnect:
import os
os.makedirs('/content/drive/MyDrive/gromacs_project', exist_ok=True)
os.chdir('/content/drive/MyDrive/gromacs_project')Upload your starting structure and .mdp files into this folder (drag them into the Drive folder, or use the notebook file browser). Running directly from the Drive folder is the simplest way to guarantee nothing is lost.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.
How do you run the actual MD simulation on the GPU?
The GROMACS commands are identical to a local run; only the speed changes. Take the standard lysozyme-in-water workflow as the example. After preparing your topology and solvated, ionized structure, energy minimize:
!gmx grompp -f minim.mdp -c solv_ions.gro -p topol.top -o em.tpr
!gmx mdrun -v -deffnm emRun NVT and NPT equilibration, then the production run. To make sure the production step uses the GPU, ask mdrun to offload the appropriate work:
!gmx grompp -f md.mdp -c npt.gro -t npt.cpt -p topol.top -o md_0_10.tpr
!gmx mdrun -deffnm md_0_10 -nb gpuThe -nb gpu flag forces the short-range non-bonded calculation onto the GPU. On a CUDA build, GROMACS will also report in the log how it distributed the PME and bonded work. Check the performance summary at the end of md_0_10.log, which prints the simulation speed in nanoseconds per day, so you can estimate how long a full run will take.
How do you keep a long run going past the session limit?
For runs that will not finish inside one session, use GROMACS checkpointing. The mdrun command writes a checkpoint file (.cpt) periodically. If the session ends, start a fresh notebook, reinstall GROMACS, mount Drive, and continue from the checkpoint:
!gmx mdrun -deffnm md_0_10 -cpi md_0_10.cpt -nb gpuBecause the checkpoint sits on Drive, the run resumes exactly where it stopped. This is the standard way to complete longer simulations across multiple free Colab sessions. Keep the run on Drive and never in the ephemeral /content directory.
Troubleshooting GROMACS on Colab
gmx: command not found. The conda install has not finished, or the kernel restarted and you skipped the install cell. Re-run the condacolab and conda install cells in order.nvidia-smishows no GPU. The runtime is still CPU-only. Go to Runtime, Change runtime type, select the GPU, and reconnect.gmx --versionshows no GPU support. The resolver installed a CPU-only build. Reinstall and constrain to a CUDA variant, then re-check the version output.- Files vanished after a break. They were written to
/content, which is erased on disconnect. Always work inside your mounted Drive folder. - Session disconnected mid-run. Resume from the last checkpoint with
-cpi. If disconnects are frequent, keep the browser tab active, since idle sessions are reclaimed. mdrunruns but is slow. Confirm-nb gpuis set and that the log shows GPU offload. A CPU-only build will ignore the GPU regardless of the flag.
Frequently asked questions
Is Google Colab really free for GROMACS?
The free tier gives you a GPU runtime at no cost, with usage limits on session length and total compute. It is enough to learn MD and run short simulations on small systems. Heavy or very long production work is where the paid tiers or a dedicated machine make sense.
Which GPU does Colab give you?
The free tier commonly assigns an NVIDIA T4, but allocation is dynamic and not guaranteed. Always run !nvidia-smi at the start of a session to see exactly what you have before planning a run.
Will my files be deleted?
Anything in the session’s local storage (the /content folder) is erased when the runtime disconnects. Files written to a mounted Google Drive folder persist. Mount Drive and work from there every session.
Can I run a simulation that takes longer than one session?
Yes, using checkpoint files. GROMACS writes a .cpt file during the run; if you store it on Drive you can resume the simulation in a new session with gmx mdrun -cpi and continue across as many sessions as needed.
Do I still need to learn the GROMACS commands?
Yes. Colab only provides the hardware and a place to install the software. The simulation workflow, from gmx pdb2gmx through equilibration to production, is exactly the same as a local run, so the underlying GROMACS skills carry over directly.
Where this fits in your MD workflow
Colab is the fastest way to go from zero to a running GPU simulation when you do not own the hardware. Once you can run and resume jobs in the cloud, the rest of the pipeline, setting up a protein-ligand complex, equilibrating it, and analyzing the trajectory with RMSD and RMSF, is identical to any other GROMACS environment. Learn the workflow once and you can run it anywhere, from a laptop to an HPC cluster.
For the engine itself, the reference is Abraham et al., “GROMACS: High performance molecular simulations through multi-level parallelism from laptops to supercomputers,” SoftwareX 1-2 (2015) 19-25 (DOI: 10.1016/j.softx.2015.06.001).
Written by the StemSkills Lab team, with 10+ years in sequence and structural bioinformatics, drug discovery and design, and multiscale molecular modeling.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.