How to Resolve CUDA Driver Mismatch Errors with Cosmos 3: Fixing `torch.cuda.is_available()` is False

You can resolve CUDA driver mismatch errors in Cosmos 3 by reinstalling PyTorch with the --torch-backend flag that matches your NVIDIA driver's supported CUDA version, ensuring torch.cuda.is_available() returns True.

Cosmos 3 relies on PyTorch compiled against specific CUDA versions, and when the installed wheel does not match your host driver's capabilities, GPU initialization fails silently. This guide explains how to diagnose and fix the "torch.cuda.is_available() is False" error using the precise backend selection mechanisms implemented in the NVIDIA Cosmos repository.

Understanding Why torch.cuda.is_available() Fails in Cosmos 3

The CUDA Version Mismatch Problem

When you install Cosmos 3 dependencies using uv pip install torch without specifying a backend, the resolver pulls the newest CUDA wheel (currently cu130 for CUDA 13.0). If your NVIDIA driver only supports CUDA 12.x, the driver cannot load the newer CUDA runtime, forcing PyTorch to fall back to CPU mode. As documented in the Cosmos 3 README.md, this mismatch causes immediate GPU unavailability when running Cosmos 3 notebooks or scripts.

Automatic Detection Limitations

The --torch-backend=auto flag attempts to detect your driver version, but the Cosmos 3 source notes that this detection only works reliably on recent driver versions. On many systems, it still resolves to the newest wheel (cu130), perpetuating the mismatch on machines with older CUDA 12.x drivers.

Checking Your CUDA Driver Compatibility

Before reinstalling, verify the mismatch by comparing your driver version against PyTorch's CUDA build:

import subprocess
import torch

# Query driver version

driver = subprocess.check_output(
    ["nvidia-smi", "--query", "driver_version", "--format=csv,noheader"]
).decode().strip()
print(f"NVIDIA Driver: {driver}")

# Check PyTorch CUDA build

print(f"PyTorch CUDA version: {torch.version.cuda}")
print(f"CUDA available: {torch.cuda.is_available()}")

If torch.version.cuda reports 13.0 while your driver only supports CUDA 12.8 or lower, you have confirmed the mismatch.

Selecting the Correct --torch-backend for Cosmos 3

CUDA 13.0 (cu130) for Latest Drivers

If your driver supports CUDA 13.0, use cu130. This is the default wheel installed by uv when no backend is specified.

CUDA 12.8 (cu128) for Common Drivers

Most production environments run CUDA 12.x drivers. According to the Cosmos 3 Reasoner cookbook at cookbooks/cosmos3/reasoner/README.md, you must explicitly select cu128 when running on CUDA 12.x drivers to avoid the "torch.cuda.is_available() returns False" error.

Step-by-Step Resolution Guide

Follow these steps to reinstall Cosmos 3 dependencies with the correct CUDA backend:

  1. Remove the existing environment (optional but recommended):

    rm -rf .venv
  2. Create a fresh virtual environment:

    uv venv --python 3.13 --seed --managed-python
    source .venv/bin/activate
  3. Install with the matching backend:

    Replace $BACKEND with cu128 for CUDA 12.x drivers or cu130 for CUDA 13.0:

    uv pip install --torch-backend=$BACKEND \
        "diffusers @ git+https://github.com/huggingface/diffusers.git" \
        accelerate av cosmos_guardrail huggingface_hub \
        imageio imageio-ffmpeg torch torchvision transformers

    As shown in the Cosmos 3 README.md, this pattern ensures uv fetches a wheel compatible with your driver.

  4. Pin the backend for future syncs (optional):

    export COSMOS3_TORCH_BACKEND=cu128

    When set, uv sync operations will automatically use this backend selection.

Verifying the Fix

After reinstallation, confirm GPU availability:

import torch

print(f"torch version: {torch.__version__}")
print(f"torch CUDA: {torch.version.cuda}")
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"Device count: {torch.cuda.device_count()}")

You should now see torch.cuda.is_available() return True and a device count ≥ 1, indicating Cosmos 3 can access the GPU.

Running Cosmos 3 After Resolution

With the driver mismatch resolved, you can now run Cosmos 3 pipelines without CPU fallback:

import torch
from diffusers import Cosmos3OmniPipeline

pipeline = Cosmos3OmniPipeline.from_pretrained(
    "nvidia/Cosmos3-Nano",
    torch_dtype=torch.bfloat16,
    device_map="cuda",
)

output = pipeline(
    prompt="A robot walks through a warehouse.",
    num_frames=64,
    height=720,
    width=1280,
    guidance_scale=6.0,
    seed=42,
)

pipeline.save_video(**output, filename="robot_warehouse.mp4")

Summary

  • CUDA driver mismatch occurs when PyTorch's CUDA wheel (e.g., cu130) exceeds your driver's supported CUDA version.
  • Diagnose by comparing torch.version.cuda against your driver capabilities using nvidia-smi.
  • Fix by reinstalling with uv pip install --torch-backend=cu128 (or cu130) to match your driver.
  • Verify with torch.cuda.is_available() returning True before running Cosmos 3 workloads.
  • Reference the Cosmos 3 README.md and cookbooks/cosmos3/reasoner/README.md for backend-specific guidance.

Frequently Asked Questions

Why does torch.cuda.is_available() return False even after installing Cosmos 3?

This happens because uv installed a PyTorch wheel compiled for a newer CUDA version than your driver supports. For example, cu130 wheels require CUDA 13.0 drivers, but many systems run CUDA 12.8. You must explicitly specify --torch-backend=cu128 during installation to match your driver version.

What is the difference between cu128 and cu130 backends in Cosmos 3?

The cu128 backend installs PyTorch compiled against CUDA 12.8, while cu130 uses CUDA 13.0. According to the Cosmos 3 source code, cu130 requires a CUDA 13 driver; attempting to run it on CUDA 12.x drivers results in silent CPU fallback and torch.cuda.is_available() returning False.

Can I use --torch-backend=auto to fix the driver mismatch?

While --torch-backend=auto attempts to detect your driver version, the Cosmos 3 documentation warns that this only works reliably on recent driver versions. On many machines, it still resolves to cu130, causing the mismatch. Explicitly specifying cu128 or cu130 is the most reliable solution.

Where does Cosmos 3 document these CUDA requirements?

The primary documentation resides in the repository's README.md, which explains the --torch-backend flag and warns that "without it, uv pulls the newest CUDA wheel (currently cu130), which fails on pre-CUDA-13 drivers." Additional details appear in cookbooks/cosmos3/reasoner/README.md regarding the cu130 vs cu128 choice for the Reasoner notebooks.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →