Running Google MedGemma 4B on Hugging Face with Google Colab

Learn how to set up and run Google's medical AI model for analyzing medical images like X-rays using free GPU resources in Google Colab.

15–20 minutes
Beginner
T4 GPU (Free Tier)
Updated: Dec 30, 2025

Prerequisites

  • A Hugging Face account with an access token
  • A Google account for Google Colab access
  • Basic Python knowledge (helpful but not required)
  • Accept the MedGemma model license on Hugging Face

Hugging Face Setup

1

Create a Hugging Face Access Token

Generate an authentication token to access gated models

Navigate to your Hugging Face account settings to create a new access token:

  1. 1. Click on your profile icon in the top-right corner
  2. 2. Select Access Tokens from the dropdown menu
  3. 3. Click the "+ Create new token" button
💡

Tip: Access tokens authenticate your identity and allow applications to perform actions on your behalf. Never share your tokens publicly.

Google Colab Setup

3

Enable GPU Runtime

Configure Colab to use T4 GPU for model inference

MedGemma 4B requires GPU acceleration. In Google Colab:

  1. Go to Runtime → Change runtime type
  2. Select T4 GPU (or higher) as the hardware accelerator
  3. Click Save

Free Tier: T4 GPU is available on Google Colab's free tier, making MedGemma accessible without any cost.