Google Compute Engine Backend Guide

SadTalker Google Colab Guide: Free T4 GPU Setup, Error Fixes & Notebook

Run SadTalker in the cloud using Google Colab's free Tesla T4 GPU. Learn how to resolve recent Python 3.13 NumPy 2.x breakages, auto-accept Conda Terms of Service, upload custom portraits and audio with interactive pickers, and access our tested, error-free notebook.

Live Execution Telemetry

Google Compute Engine Backend (GPU) Resources

Recorded during active inference session on Google Colab (Duration: 19:13 to 19:33 • 20 minutes)

Tesla T4 15,360 MiB • Active • Healthy
System RAM28.3% Used
3.6 / 12.7 GB

Lightweight host overhead. Ample system memory headroom for audio decoding and video buffering.

GPU VRAM (Tesla T4)48.0% Used
7.2 / 15.0 GB

Peak VRAM during 512px Face Renderer and GFPGAN neural network super-resolution pass.

Colab Disk Space55.1% Used
62.0 / 112.6 GB

Includes Miniconda environment, PyTorch CUDA wheels, SadTalker weights, and GFPGAN models.

Verified Verification Output

Real Video Output Generated on Google Colab T4

This exact MP4 video was generated on Google Colab using the working sequence detailed below with 512px resolution, still mode, and GFPGAN face enhancement enabled.

Result File: ./results/2026_09_12_13.03.47.mp4

Source Portrait Image
sadtalker-corporate-presenter-source.png

Clean, frontal corporate presenter portrait with natural lighting and neutral head orientation.

Driven Speech Audio
sadtalker-corporate-male-audio.wav

Crystal-clear 16-bit 16kHz mono WAV voiceover recording providing phonetic landmarks for lip synchronization.

Execution Parameters
  • --size: 512
  • --still: True (preserves background)
  • --preprocess: crop
  • --enhancer: gfpgan
Step-by-Step Guide

How to Run SadTalker on Google Colab (Free T4 GPU)

Follow this sequential procedure to initialize your environment, resolve upstream library bugs, upload files, and produce realistic talking head videos.

1

Step 1: Switch Runtime to Hardware Accelerator (T4 GPU)

Select Google Compute Engine backend with GPU acceleration

In Google Colab, open the top menu bar, click on Runtime > Change runtime type, select T4 GPU as the Hardware accelerator, and click Save. Running SadTalker on CPU will fail due to CUDA tensor operations.

Google Colab Change Runtime Type dialog selecting T4 GPU hardware accelerator
Runtime type dialog showing T4 GPU selected under Hardware accelerator
2

Step 2: Verify GPU Allocation with nvidia-smi

Check driver version, CUDA version, and dedicated VRAM

Execute !nvidia-smi in the first cell. This verifies your allocated GPU is a Tesla T4 with 15,360 MiB total VRAM running NVIDIA Driver 580.82.07 and CUDA 13.0.

Colab Cell 1: Hardware Verification
bash
!nvidia-smi
Colab cell output running nvidia-smi confirming Tesla T4 GPU with 15360 MiB VRAM
Output of nvidia-smi showing Tesla T4 15,360 MiB VRAM running on Driver 580.82.07
3

Step 3: Install System Libraries & Clone SadTalker Repository

Install FFmpeg, Git, and pull OpenTalker/SadTalker

SadTalker requires system-level FFmpeg for audio extraction and video stream muxing. Run apt-get update to install FFmpeg, then clone the official SadTalker repository into /content/SadTalker.

Colab Cell 2: System Packages & Clone
bash
!apt-get update -qq && apt-get install -y -qq ffmpeg git wget
!git clone https://github.com/OpenTalker/SadTalker.git /content/SadTalker
%cd /content/SadTalker
Colab execution of apt-get update and git clone of SadTalker
Command cell updating apt-get, installing FFmpeg, and cloning SadTalker into /content/SadTalker
4

Step 4: Deploy Python 3.8 Environment & Accept Conda Terms of Service

The crucial fix for Python 3.13 / NumPy 2.x breakages in modern Google Colab

Google Colab recently upgraded to Python 3.13 with NumPy 2.x. When running SadTalker directly, it crashes with AttributeError: module 'numpy' has no attribute 'VisibleDeprecationWarning'. Furthermore, running conda in Colab halts unless Terms of Service are accepted. The cell below sets export CONDA_PLUGINS_AUTO_ACCEPT_TOS=true, deploys Miniconda, creates a Python 3.8 environment, and installs tested wheels.

Colab Cell 3: Miniconda, Python 3.8 & Pinned Wheels
bash
%%bash
# Auto-accept Conda Terms of Service for non-interactive execution
export CONDA_PLUGINS_AUTO_ACCEPT_TOS=true

# Install Miniconda quietly if not already installed
if [ ! -d "/content/miniconda3" ]; then
  wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
  bash Miniconda3-latest-Linux-x86_64.sh -b -p /content/miniconda3
  rm -f Miniconda3-latest-Linux-x86_64.sh
fi

# Create dedicated Python 3.8 environment
source /content/miniconda3/bin/activate
if ! conda info --envs | grep -q "sadtalker"; then
  conda create -n sadtalker python=3.8 -y
fi

# Activate and install validated compatible packages
source /content/miniconda3/bin/activate sadtalker
pip install --quiet --upgrade pip
pip install --quiet numpy==1.23.5 torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 \
  facexlib==0.3.0 gfpgan insightface onnxruntime moviepy \
  opencv-python-headless imageio[ffmpeg] yacs kornia gtts \
  safetensors pydub librosa

# Apply BasicSR Torchvision compatibility patch
sed -i 's/from torchvision.transforms.functional_tensor import rgb_to_grayscale/from torchvision.transforms.functional import rgb_to_grayscale/' /content/miniconda3/envs/sadtalker/lib/python3.8/site-packages/basicsr/data/degradations.py 2>/dev/null || true

echo "Conda environment configured and ready!"
Colab execution accepting Conda terms of service and installing packages into python 3.8 sadtalker environment
Output confirming CONDA_PLUGINS_AUTO_ACCEPT_TOS=true, conda environment sadtalker created, and wheels installed
5

Step 5: Fetch Pre-Trained Checkpoints & GFPGAN Weights

Acquire 256/512 safetensors, mapping weights, and face alignment models

SadTalker relies on pre-trained checkpoints (SadTalker_V0.0.2_256.safetensors, SadTalker_V0.0.2_512.safetensors) and GFPGAN weights. Fetching them directly with wget -nc prevents redundant network transfers if the cell is rerun.

Colab Cell 4: Checkpoints & Model Acquisition
bash
%%bash
cd /content/SadTalker
mkdir -p ./checkpoints ./gfpgan/weights

# Core SadTalker models
wget -nc https://github.com/OpenTalker/SadTalker/releases/download/v0.0.2-rc/mapping_00109-model.pth.tar -O ./checkpoints/mapping_00109-model.pth.tar
wget -nc https://github.com/OpenTalker/SadTalker/releases/download/v0.0.2-rc/mapping_00229-model.pth.tar -O ./checkpoints/mapping_00229-model.pth.tar
wget -nc https://github.com/OpenTalker/SadTalker/releases/download/v0.0.2-rc/SadTalker_V0.0.2_256.safetensors -O ./checkpoints/SadTalker_V0.0.2_256.safetensors
wget -nc https://github.com/OpenTalker/SadTalker/releases/download/v0.0.2-rc/SadTalker_V0.0.2_512.safetensors -O ./checkpoints/SadTalker_V0.0.2_512.safetensors

# GFPGAN & face enhancement models
wget -nc https://github.com/xinntao/facexlib/releases/download/v0.1.0/alignment_WFLW_4HG.pth -O ./gfpgan/weights/alignment_WFLW_4HG.pth
wget -nc https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth -O ./gfpgan/weights/detection_Resnet50_Final.pth
wget -nc https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth -O ./gfpgan/weights/GFPGANv1.4.pth
wget -nc https://github.com/xinntao/facexlib/releases/download/v0.2.2/parsing_parsenet.pth -O ./gfpgan/weights/parsing_parsenet.pth
Colab execution fetching SadTalker and GFPGAN model weights
Setup script saving mapping_00109, 256/512 safetensors, and GFPGAN weights into checkpoints/
6

Step 6: Upload Custom Image and Audio with Google Colab Picker

Interactive file upload buttons right inside your Colab notebook

Rather than having to mount Google Drive or manually move files via the sidebar, use Google Colab's native files.upload(). This presents a "Choose Files" button directly under the cell for both your image and audio. If skipped, the notebook falls back to demo assets automatically.

Colab Cell 5: Interactive File Pickers
python
from google.colab import files
import os

print("=== Select Source Portrait Image (PNG, JPG, WEBP) ===")
uploaded_img = files.upload()
if uploaded_img:
    img_name = list(uploaded_img.keys())[0]
    source_img_path = f"/content/{img_name}"
    print(f"Source Image loaded: {source_img_path}")
else:
    source_img_path = "/content/SadTalker/examples/source_image/full_body_1.png"
    print(f"No image selected. Using demo portrait: {source_img_path}")

print("\n=== Select Driven Speech Audio (WAV, MP3) ===")
uploaded_aud = files.upload()
if uploaded_aud:
    aud_name = list(uploaded_aud.keys())[0]
    driven_audio_path = f"/content/{aud_name}"
    print(f"Driven Audio loaded: {driven_audio_path}")
else:
    driven_audio_path = "/content/SadTalker/examples/driven_audio/bus_chinese.wav"
    print(f"No audio selected. Using demo audio: {driven_audio_path}")

# Persist environment variables for bash execution
with open("/content/sadtalker_inputs.env", "w") as f:
    f.write(f"export SOURCE_IMAGE='{source_img_path}'\n")
    f.write(f"export DRIVEN_AUDIO='{driven_audio_path}'\n")

print("\nInputs saved successfully! Proceed to generation.")
7

Step 7: Execute SadTalker Inference Command

Generate lip-synced talking head video with GFPGAN enhancement

Activate the conda environment, source the input file paths, and launch python inference.py. The cell runs landmark extraction, 3DMM coefficient generation, face rendering across all 155 frames, and GFPGAN face enhancement.

Colab Cell 6: Run Inference
bash
%%bash
source /content/miniconda3/bin/activate sadtalker
cd /content/SadTalker
source /content/sadtalker_inputs.env

echo "Processing Source Image: $SOURCE_IMAGE"
echo "Processing Driven Audio: $DRIVEN_AUDIO"

python inference.py \
  --driven_audio "$DRIVEN_AUDIO" \
  --source_image "$SOURCE_IMAGE" \
  --result_dir ./results \
  --size 512 \
  --still \
  --preprocess crop \
  --enhancer gfpgan
Colab execution of python inference.py showing progress bars for 3DMM, Face Renderer, and Face Enhancer
Output showing 3DMM extraction, 155 Face Renderer frames at ~2.6s/it, and 309 Face Enhancer frames completed
8

Step 8: Inline Video Player & Automatic Local Saving

View your talking head video and transfer it to your local device

This final cell scans the ./results folder for the latest generated MP4 file, embeds an autoplaying HTML5 video player directly inside Colab, and initiates browser file saving to your local machine.

Colab Cell 7: Video Preview & Export
python
import glob
import os
from IPython.display import HTML, display
from base64 import b64encode
from google.colab import files

mp4_files = glob.glob("/content/SadTalker/results/*.mp4") + glob.glob("/content/SadTalker/results/*/*.mp4")
if mp4_files:
    latest_video = max(mp4_files, key=os.path.getctime)
    print(f"Generated Video: {latest_video}")

    # Render HTML5 video player
    video_data = open(latest_video, 'rb').read()
    data_url = "data:video/mp4;base64," + b64encode(video_data).decode()
    display(HTML(f"""
    <div style="text-align: center; margin: 16px 0;">
      <video width="512" height="512" controls autoplay loop style="border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); max-width: 100%;">
        <source src="{data_url}" type="video/mp4">
        Your browser does not support the video tag.
      </video>
    </div>
    """))

    # Download to local device
    print("Downloading video to your local device...")
    files.download(latest_video)
else:
    print("No generated video found in /content/SadTalker/results/")
Notebook Error Diagnostics

Errors Encountered in Google Colab & Verified Working Fixes

Running SadTalker out-of-the-box on Google Colab encounters several breaking errors caused by recent Colab infrastructure updates. Here is the technical breakdown of each error and its working resolution.

Error 1: Fatal

NumPy 2.x & Python 3.13: AttributeError: module 'numpy' has no attribute 'VisibleDeprecationWarning'

The Root Cause: Google Colab upgraded its default Linux runtime to Python 3.13 and installed NumPy 2.0+. In NumPy 2.0, legacy attributes such as np.VisibleDeprecationWarning were removed. When SadTalker initializes src/face3d/util/preprocess.py at line 12, Python immediately halts.

Colab traceback showing AttributeError module numpy has no attribute VisibleDeprecationWarning
Actual Colab traceback showing AttributeError: module 'numpy' has no attribute 'VisibleDeprecationWarning'
Working Solution in Notebook:

Do not attempt to downgrade NumPy inside the host Python 3.13 environment, as Colab's system libraries break. Instead, create an isolated Miniconda environment pinned to Python 3.8 and install numpy==1.23.5.

The Fix: Python 3.8 Isolation
bash
# Create and activate Python 3.8 environment
conda create -n sadtalker python=3.8 -y
source /content/miniconda3/bin/activate sadtalker
pip install numpy==1.23.5
Error 2: Blocking

CondaToSNonInteractiveError: Terms of Service have not been accepted

The Root Cause: In recent Miniconda builds, Anaconda enabled mandatory Terms of Service acceptance for default repository channels (repo.anaconda.com/pkgs/main). In headless Colab bash cells, conda halts with exit code 1 because no interactive prompt is available.

Working Solution in Notebook:

Export the auto-acceptance environment variable at the top of your bash cell before executing any conda commands.

The Fix: Auto-Accept Conda ToS
bash
export CONDA_PLUGINS_AUTO_ACCEPT_TOS=true
Error 3: Pip Install Failure

ERROR: No matching distribution found for TTS==0.13.3

The Root Cause: The official SadTalker Colab notebook previously included pip install TTS==0.13.3. Coqui TTS 0.13.3 requires Python >=3.7, <3.11 and fails completely on modern Python.

Working Solution in Notebook:

TTS is only used for optional text-to-speech generation. SadTalker's core talking head generation only requires a driven audio WAV file. Removing the TTS==0.13.3 dependency from pip eliminates the failure completely.

Error 4: Deprecation Patch

ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'

The Root Cause: BasicSR 1.4.2 imports rgb_to_grayscale from torchvision.transforms.functional_tensor, which was moved to torchvision.transforms.functional in newer TorchVision versions.

Working Solution in Notebook:

Apply a fast in-place regex patch using sed directly to BasicSR's installed degradations.py file inside the conda environment.

The Fix: In-place BasicSR Patch
bash
sed -i 's/from torchvision.transforms.functional_tensor import rgb_to_grayscale/from torchvision.transforms.functional import rgb_to_grayscale/' /content/miniconda3/envs/sadtalker/lib/python3.8/site-packages/basicsr/data/degradations.py 2>/dev/null || true
Frequently Asked Questions

Google Colab SadTalker FAQ

Official Notebook Access

Get SadTalker Google Colab Notebook

Select your preferred notebook version below. Choose the clean notebook ready for fresh runs, or inspect the full notebook containing all cell outputs, logs, and execution traces.

Option 1: Recommended11 KB

Clean Notebook (Without Output)

Lightweight, error-free notebook configured to run from scratch. Includes Google Colab interactive file pickers to upload your own portrait and speech audio, automated Python 3.8 conda environment setup, model weight fetching, and automatic video player.

  • Zero leftover cache or memory clutter
  • Interactive file pickers ready for your custom portrait
  • Pre-patched for NumPy 2.x and Conda Terms of Service
Get Notebook (Without Output)
Option 2: Reference & Debug190 KB

Full Notebook (With Output & Logs)

Complete working notebook containing all execution outputs, live terminal logs, step-by-step progress bars, error investigations, and the final generation telemetry from our verified test run.

  • Includes full nvidia-smi & system logs
  • Shows error tracebacks and corresponding working commands
  • Contains raw frame rendering speeds and timings
Get Full Notebook (With Output & Logs)
How to open in Google Colab: Go to colab.research.google.com → Click Upload → Select either saved .ipynb file → Ensure runtime is set to T4 GPU → Run the cells sequentially.

Explore More SadTalker Guides