Skip to main content

A CLI tool to verify and fix AI/ML environment compatibility (Driver <-> CUDA <-> Wheels) with platform-specific installation guides.

Project description

Env-Doctor Logo

Env-Doctor

The missing link between your GPU and Python AI libraries

Documentation PyPI Downloads Python License GitHub Stars


"Why does my PyTorch crash with CUDA errors when I just installed it?"

Because your driver supports CUDA 11.8, but pip install torch gave you CUDA 12.4 wheels.

Env-Doctor diagnoses and fixes the #1 frustration in GPU computing: mismatched CUDA versions between your NVIDIA driver, system toolkit, cuDNN, and Python libraries.

It takes 5 seconds to find out if your environment is broken - and exactly how to fix it.

Doctor "Check" (Diagnosis)

Env-Doctor Demo

Features

Feature What It Does
One-Command Diagnosis Check compatibility: GPU Driver → CUDA Toolkit → cuDNN → PyTorch/TensorFlow/JAX
CUDA Installation Guide Get platform-specific, copy-paste CUDA installation commands for your system
Safe Install Commands Get the exact pip install command that works with YOUR driver
Extension Library Support Install compilation packages (flash-attn, SageAttention, auto-gptq, apex, xformers) with CUDA version matching
AI Model Compatibility Check if LLMs, Diffusion, or Audio models fit on your GPU before downloading
WSL2 GPU Support Validate GPU forwarding, detect driver conflicts within WSL2 env for Windows users
Deep CUDA Analysis Find multiple installations, PATH issues, environment misconfigurations
Container Validation Catch GPU config errors in Dockerfiles before you build
MCP Server Expose diagnostics to AI assistants (Claude Desktop, Zed) via Model Context Protocol
CI/CD Ready JSON output and proper exit codes for automation

Installation

pip install env-doctor

Usage

Diagnose Your Environment

env-doctor check

Example output:

🩺 ENV-DOCTOR DIAGNOSIS
============================================================

🖥️  Environment: Native Linux

🎮 GPU Driver
   ✅ NVIDIA Driver: 535.146.02
   └─ Max CUDA: 12.2

🔧 CUDA Toolkit
   ✅ System CUDA: 12.1.1

📦 Python Libraries
   ✅ torch 2.1.0+cu121

✅ All checks passed!

Get Safe Install Command

env-doctor install torch
⬇️ Run this command to install the SAFE version:
---------------------------------------------------
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
---------------------------------------------------

Get CUDA Installation Instructions

env-doctor cuda-install
============================================================
CUDA TOOLKIT INSTALLATION GUIDE
============================================================

Detected Platform:
    Linux (ubuntu 22.04, x86_64)

Driver: 535.146.02 (supports up to CUDA 12.2)
Recommended CUDA Toolkit: 12.1

============================================================
Ubuntu 22.04 (x86_64) - Network Install
============================================================

Installation Steps:
------------------------------------------------------------
    1. wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
    2. sudo dpkg -i cuda-keyring_1.1-1_all.deb
    3. sudo apt-get update
    4. sudo apt-get -y install cuda-toolkit-12-1

Post-Installation Setup:
------------------------------------------------------------
    export PATH=/usr/local/cuda-12.1/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

    TIP: Add the above exports to ~/.bashrc or ~/.zshrc

Verify Installation:
------------------------------------------------------------
    nvcc --version

Official Download Page:
    https://developer.nvidia.com/cuda-12-1-0-download-archive

Supported Platforms:

  • Ubuntu 20.04, 22.04, 24.04
  • Debian 11, 12
  • RHEL 8, 9 / Rocky Linux / AlmaLinux
  • Fedora 39+
  • WSL2 (Ubuntu)
  • Windows 10/11
  • Conda (all platforms)

Install Compilation Packages (Extension Libraries)

For extension libraries like flash-attn, SageAttention, auto-gptq, apex, and xformers that require compilation from source, env-doctor provides special guidance to handle CUDA version mismatches:

env-doctor install flash-attn

Example output (with CUDA mismatch):

🩺  PRESCRIPTION FOR: flash-attn

⚠️   CUDA VERSION MISMATCH DETECTED
     System nvcc: 12.1.1
     PyTorch CUDA: 12.4.1

🔧  flash-attn requires EXACT CUDA version match for compilation.
    You have TWO options to fix this:

============================================================
📦  OPTION 1: Install PyTorch matching your nvcc (12.1)
============================================================

Trade-offs:
  ✅ No system changes needed
  ✅ Faster to implement
  ❌ Older PyTorch version (may lack new features)

Commands:
  # Uninstall current PyTorch
  pip uninstall torch torchvision torchaudio -y

  # Install PyTorch for CUDA 12.1
  pip install torch --index-url https://download.pytorch.org/whl/cu121

  # Install flash-attn
  pip install flash-attn --no-build-isolation

============================================================
⚙️   OPTION 2: Upgrade nvcc to match PyTorch (12.4)
============================================================

Trade-offs:
  ✅ Keep latest PyTorch
  ✅ Better long-term solution
  ❌ Requires system-level changes
  ❌ Verify driver supports CUDA 12.4

Steps:
  1. Check driver compatibility:
     env-doctor check

  2. Download CUDA Toolkit 12.4:
     https://developer.nvidia.com/cuda-12-4-0-download-archive

  3. Install CUDA Toolkit (follow NVIDIA's platform-specific guide)

  4. Verify installation:
     nvcc --version

  5. Install flash-attn:
     pip install flash-attn --no-build-isolation

============================================================

Check Model Compatibility

env-doctor model llama-3-8b
🤖  Checking: LLAMA-3-8B (8.0B params)

🖥️   Your Hardware: RTX 3090 (24GB)

💾  VRAM Requirements:
  ✅  FP16: 19.2GB - fits with 4.8GB free
  ✅  INT4:  4.8GB - fits with 19.2GB free

✅  This model WILL FIT on your GPU!

List all models: env-doctor model --list

Automatic HuggingFace Support (New ✨) If a model isn't found locally, env-doctor automatically checks the HuggingFace Hub, fetches its parameter metadata, and caches it locally for future runs — no manual setup required.

# Fetches from HuggingFace on first run, cached afterward
env-doctor model bert-base-uncased
env-doctor model sentence-transformers/all-MiniLM-L6-v2

Output:

🤖  Checking: BERT-BASE-UNCASED
    (Fetched from HuggingFace API - cached for future use)
    Parameters: 0.11B
    HuggingFace: bert-base-uncased

🖥️   Your Hardware:
    RTX 3090 (24GB VRAM)

💾  VRAM Requirements & Compatibility
  ✅  FP16:  264 MB - Fits easily!

💡  Recommendations:
1. Use fp16 for best quality on your GPU

Validate Dockerfiles

env-doctor dockerfile
🐳  DOCKERFILE VALIDATION

❌  Line 1: CPU-only base image: python:3.10
    Fix: FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04

❌  Line 8: PyTorch missing --index-url
    Fix: pip install torch --index-url https://download.pytorch.org/whl/cu121

More Commands

Command Purpose
env-doctor check Full environment diagnosis
env-doctor cuda-install Step-by-step CUDA Toolkit installation guide
env-doctor install <lib> Safe install command for PyTorch/TensorFlow/JAX, extension libraries (flash-attn, auto-gptq, apex, xformers, SageAttention, etc.)
env-doctor model <name> Check model VRAM requirements
env-doctor cuda-info Detailed CUDA toolkit analysis
env-doctor cudnn-info cuDNN library analysis
env-doctor dockerfile Validate Dockerfile
env-doctor docker-compose Validate docker-compose.yml
env-doctor scan Scan for deprecated imports
env-doctor debug Verbose detector output

CI/CD Integration

# JSON output for scripting
env-doctor check --json

# CI mode with exit codes (0=pass, 1=warn, 2=error)
env-doctor check --ci

GitHub Actions example:

- run: pip install env-doctor
- run: env-doctor check --ci

MCP Server (AI Assistant Integration)

Env-Doctor includes a built-in Model Context Protocol (MCP) server that exposes diagnostic tools to AI assistants like Claude Desktop.

Quick Setup for Claude Desktop

  1. Install env-doctor:

    pip install env-doctor
    
  2. Add to Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

    {
      "mcpServers": {
        "env-doctor": {
          "command": "env-doctor-mcp"
        }
      }
    }
    
  3. Restart Claude Desktop - the tools will be available automatically.

Available Tools (10 Total)

  • env_check - Full GPU/CUDA environment diagnostics
  • env_check_component - Check specific component (driver, CUDA, cuDNN, etc.)
  • cuda_info - Detailed CUDA toolkit information
  • cudnn_info - Detailed cuDNN library information
  • cuda_install - Step-by-step CUDA installation instructions
  • install_command - Get safe pip install commands for AI libraries
  • model_check - Analyze if AI models fit on your GPU
  • model_list - List all available models in database
  • dockerfile_validate - Validate Dockerfiles for GPU issues
  • docker_compose_validate - Validate docker-compose.yml for GPU configuration

Example Usage

Ask Claude Desktop:

  • "Check my GPU environment"
  • "How do I install CUDA Toolkit on Ubuntu?"
  • "Get me the pip install command for PyTorch"
  • "Can I run Llama 3 70B on my GPU?"
  • "Validate this Dockerfile for GPU issues"
  • "What CUDA version does my PyTorch require?"
  • "Show me detailed CUDA toolkit information"

Learn more: MCP Integration Guide

Documentation

Full documentation: https://mitulgarg.github.io/env-doctor/

Contributing

Contributions welcome! See CONTRIBUTING.md for details.

License

MIT License - see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

env_doctor-0.2.1.tar.gz (79.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

env_doctor-0.2.1-py3-none-any.whl (82.8 kB view details)

Uploaded Python 3

File details

Details for the file env_doctor-0.2.1.tar.gz.

File metadata

  • Download URL: env_doctor-0.2.1.tar.gz
  • Upload date:
  • Size: 79.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for env_doctor-0.2.1.tar.gz
Algorithm Hash digest
SHA256 367e17258f8e763f5a8fbcb9aa06eb5978c3f1cbcdb3e0e0844eb92b471741d2
MD5 1ae32a61ec81e64a900d25ce18e5045c
BLAKE2b-256 739c4b18e8c8f013b0e969865006cc09b912fad84247fab969544140c99a777c

See more details on using hashes here.

Provenance

The following attestation bundles were made for env_doctor-0.2.1.tar.gz:

Publisher: publish-pypi.yml on mitulgarg/env-doctor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file env_doctor-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: env_doctor-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 82.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for env_doctor-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd67f377fb4923a8a2001b4acac71600fc7999899aa484cf2088102ad06dd4ae
MD5 4d891a9dae34cfd3b94ee0916c0e4f57
BLAKE2b-256 2ebe4318f9e1ce37c0b5cfd6433b6dbe21c0521a5c004cfb51354845b87ee56c

See more details on using hashes here.

Provenance

The following attestation bundles were made for env_doctor-0.2.1-py3-none-any.whl:

Publisher: publish-pypi.yml on mitulgarg/env-doctor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page