Skip to content

mitulgarg/env-doctor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

58 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

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
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

Or from source:

git clone https://github.com/mitulgarg/env-doctor.git
cd env-doctor
pip install -e .

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
---------------------------------------------------

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 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

  • env_check - Full GPU/CUDA environment diagnostics
  • env_check_component - Check specific component (driver, CUDA, cuDNN, etc.)
  • 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

Example Usage

Ask Claude Desktop:

  • "Check my GPU environment"
  • "Can I run Llama 3 70B on my GPU?"
  • "Validate this Dockerfile for GPU issues"
  • "What CUDA version does my PyTorch require?"

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

About

One CLI to validate GPU, CUDA, and AI stacks across local, Docker, and CI

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •