env-doctor is a local-first runtime compatibility intelligence and VRAM analysis tool for the HuggingFace + Torch + CUDA ecosystem.
The system acts as:
A user-managed dependency intelligence repository
+
A powerful local compatibility analysis CLIIt is NOT:
- a package manager
- a dependency resolver
- a pip replacement
- a uv replacement
Instead, it solves:
- undocumented runtime incompatibilities
- CUDA/toolchain mismatches
- unstable package combinations
- torch ABI breakages
- wheel availability problems
- VRAM estimation inaccuracies
- OOM debugging
- environment instability
Core philosophy:
"Will this setup ACTUALLY work?"instead of:
"Can pip install this?"The product consists of:
A GitHub-hosted database repository containing:
- compatibility rules
- stable stacks
- wheel availability
- runtime profiles
- package metadata
- curated ecosystem intelligence
Think of this as:
APT repository metadata
+
community-maintained runtime compatibility intelligenceThe CLI:
- downloads latest DB snapshot
- caches locally
- performs ALL compatibility analysis locally
- performs ALL recommendations locally
- performs ALL VRAM analysis locally
No always-online backend required.
This is NOT:
a dependency resolverThis IS:
a dependency intelligence systemThe system focuses on:
- operational compatibility
- runtime stability
- CUDA compatibility
- ecosystem sanity
- stable stack discovery
The tool should help users:
1. Discover stable package combinations
2. Avoid ecosystem breakage
3. Understand VRAM requirements
4. Detect runtime risks
5. Patch unstable environments
6. Share compatibility knowledgeSupported:
- Linux
- NVIDIA CUDA
- cloud notebook environments
- Linux desktop environments
Supported ecosystem:
- torch
- transformers
- accelerate
- peft
- trl
- unsloth
- flash-attn
- bitsandbytes
- datasets
- sentence-transformers
- vllm
- llama-index
- langchain
- chromadb
- faiss
Not supported initially:
- Windows
- ROCm
- Apple Metal
- TensorFlow
- TPU
- Kubernetes
- distributed training
┌───────────────────────┐
│ GitHub DB Repository │
└──────────┬────────────┘
│
▼
┌───────────────────────┐
│ Local Database Cache │
└──────────┬────────────┘
│
┌──────────────────────┼──────────────────────┐
│ │ │
▼ ▼ ▼
┌────────────────┐ ┌────────────────┐ ┌────────────────┐
│ Compatibility │ │ Recommendation │ │ VRAM Engine │
│ Engine │ │ Engine │ │ │
└────────────────┘ └────────────────┘ └────────────────┘
│
▼
┌───────────────────────┐
│ CLI Interface │
└───────────────────────┘The CLI is:
- an execution engine
- a recommendation engine
- a compatibility intelligence engine
But the accumulated:
- compatibility data
- stability rules
- ecosystem knowledge
becomes the real moat.
The database repository is:
- GitHub-based
- versioned
- transparent
- user-managed
- PR-driven
Users can:
- submit compatibility rules
- add stable stacks
- improve runtime profiles
- update wheel metadata
- add package intelligence
The upstream repository uses a partitioned YAML system for easy Git-based contributions and clear version tracking.
env-doctor-db/
├── compatibility/
│ ├── t/
│ │ └── torch/
│ │ ├── 2.1.yaml
│ │ ├── 2.2.yaml
│ │ └── 2.3.yaml
│ └── t/
│ └── transformers/
│ └── 4.38.yaml
├── stable-stacks/
├── wheel-index/
├── runtimes/
└── metadata.jsonKey Rules:
- Deterministic UIDs: Every entry uses a deterministic hash (e.g., SHA-256 of package+version+platform) as its UID, allowing decentralized generation.
- Full History: The local database retains the entire history of all package versions and compatibility rules to ensure historical context.
- Granularity: Files are partitioned alphabetically (e.g.,
t/torch/) to manage directory size. - Data Integrity: Compatibility data is strictly unique to specific package version combinations.
Tracks:
- DB schema version
- release timestamp
- compatibility snapshot version
Example:
{
"db_version": "1.0.0",
"generated_at": "2026-05-15T12:00:00Z",
"schema_version": 1
}The system should automatically bootstrap itself by parsing:
- PyPI package metadata
- dependency constraints
- wheel metadata
- Python version requirements
This is CRITICAL.
The manually curated compatibility rules should augment:
- real dependency metadata
- real version constraints
NOT replace them.
Automatically build:
- package dependency graphs
- version compatibility maps
- wheel availability indexes
from PyPI metadata.
- PyPI JSON API
- package metadata
- wheel metadata
- GitHub releases
Endpoint:
GET https://pypi.org/pypi/{package}/jsonExample:
GET https://pypi.org/pypi/transformers/json{
"info": {
"requires_python": ">=3.9",
"requires_dist": [
"torch>=2.1",
"accelerate>=0.26"
]
},
"releases": {
"4.52.0": [
...
]
}
}The system should parse:
- requires_dist
- requires_python
- wheel metadata
- extras_require
Use:
- packaging
- importlib.metadata
- semantic_version
from packaging.requirements import Requirement
req = Requirement("torch>=2.1")
print(req.name)
print(req.specifier)Package List
↓
Fetch PyPI Metadata
↓
Extract Dependency Constraints
↓
Extract Python Requirements
↓
Extract Wheel Metadata
↓
Populate Base Compatibility Graph
↓
Apply Curated Compatibility RulesPyPI metadata ONLY provides:
declared compatibilityBut NOT:
- runtime stability
- CUDA ABI compatibility
- ecosystem sanity
- operational compatibility
That is why:
- community intelligence
- curated rules
- stable stack recommendations
are still required.
The database should contain TWO layers:
Automatically generated from:
- PyPI
- wheel metadata
- package requirements
Provides:
- dependency graph
- version constraints
- Python requirements
- wheel availability
User-managed compatibility intelligence.
Provides:
- runtime instability warnings
- known broken combinations
- stable stack recommendations
- ecosystem-specific rules
- CUDA/runtime guidance
PyPI metadata may say:
flash-attn >= torch 2.6But curated intelligence may say:
flash-attn 2.8 unstable with torch 2.7 on CUDA 12.6This distinction is ESSENTIAL.
The CLI:
- downloads DB snapshots
- caches locally
- performs all analysis locally
No mandatory cloud dependency.
- Fetch: CLI downloads the latest YAML snapshots from the GitHub repository.
- Compile: Local engine converts and indexes YAML files into a high-performance SQLite database.
- Deterministic Logic: Consistency is ensured by the deterministic nature of the compiler; the codebase guarantees that the same input YAML files always produce an identical SQLite structure across all platforms.
- History Retention: The compiler ensures all historical records are preserved during the update process.
- Cache: The SQLite database is stored locally (e.g.,
~/.cache/env-doctor/intelligence.db).
env-doctor update-dbDownloads YAML files and compiles the local SQLite intelligence cache.
env-doctor inspectenv-doctor check requirements.txtenv-doctor recommendenv-doctor vram \
--model Qwen/Qwen3-32B \
--runtime vllm \
--quant awqenv-doctor patch pyproject.tomlenv-doctor report-incompatibility <script_or_notebook>Runs the provided Python script or Jupyter notebook locally, captures the output, and submits it for compatibility analysis.
env-doctor/
├── pyproject.toml # uv-managed project metadata
├── README.md
├── src/
│ └── env-doctor/ # Main package
│ ├── __init__.py
│ ├── main.py # CLI Entry point (Typer)
│ ├── cli/ # CLI command definitions
│ ├── core/ # Logic (compatibility, recommendations)
│ ├── database/ # SQLite/DB management & YAML-to-SQLite compiler
│ ├── scanner/ # Local environment scanning
│ ├── vram/ # VRAM estimation engine
│ ├── reporting/ # Incompatibility reporting logic
│ └── utils/ # Shared helpers
├── tests/ # Pytest suite
└── .python-version # uv-managed python version (3.10+)The project uses uv for lightning-fast dependency management and environment isolation.
- uv: Project management and fast installs.
- Python: 3.10+ (Required for modern type hints and pattern matching).
- ruff: Linting and formatting.
- pytest: Testing framework.
- typer: CLI framework with type hints.
- rich: Terminal UI and progress bars.
pydantic: Data validation for schema.httpx: Async HTTP client for DB updates/reporting.packaging: Requirement parsing.nbconvert/nbformat: For notebook execution inreport_incompatibility.sqlmodel: For local intelligence cache.
- Local Execution: The CLI runs the input script/notebook in the user's current environment.
- Environment Capture:
- Captures exact versions of all installed packages (
pip list). - Identifies related system info (Python, CUDA, OS).
- Captures package-specific metadata for used dependencies.
- Captures exact versions of all installed packages (
- Data Submission: The script/notebook, output trace, and environment snapshot are sent to the serverless endpoint.
- Authentication: The serverless function authenticates the user using GitHub credentials.
- // TODO: Implement GitHub Auth for MVP stage
- AI Analysis: The function calls a custom agent on the watsonx platform.
- Verification: The watsonx agent confirms if the error is a dependency compatibility issue.
- DB Update: If verified, the agent proposes a unique YAML entry (with a stable ID) to the upstream repository.
All tables use a Global Unique ID (uid) system to ensure consistency and avoid repeated entries.
CREATE TABLE packages (
uid TEXT PRIMARY KEY,
name TEXT UNIQUE NOT NULL,
platform_info TEXT
);CREATE TABLE package_versions (
uid TEXT PRIMARY KEY,
package_uid TEXT NOT NULL,
version TEXT NOT NULL,
release_date TEXT,
yanked BOOLEAN DEFAULT FALSE,
platform_info TEXT,
FOREIGN KEY(package_uid)
REFERENCES packages(uid),
UNIQUE(package_uid, version) -- Version uniqueness
);AUTOMATICALLY generated from PyPI metadata.
CREATE TABLE package_dependencies (
uid TEXT PRIMARY KEY,
package_name TEXT,
package_version TEXT,
dependency_name TEXT,
dependency_specifier TEXT,
optional BOOLEAN,
source TEXT,
platform_info TEXT,
UNIQUE(package_name, package_version, dependency_name)
);Curated intelligence layer.
CREATE TABLE compatibility_rules (
uid TEXT PRIMARY KEY,
package_name TEXT NOT NULL,
package_version_range TEXT NOT NULL,
dependency_name TEXT NOT NULL,
dependency_version_range TEXT NOT NULL,
compatibility_type TEXT NOT NULL, -- compatible, incompatible, etc.
severity TEXT NOT NULL,
confidence_level TEXT NOT NULL, -- experimental, stable, etc.
reason TEXT,
source_type TEXT,
source_url TEXT,
created_at TEXT,
platform_info TEXT,
UNIQUE(package_name, package_version_range, dependency_name, dependency_version_range)
);compatible
incompatible
partial
runtime-risk
untestedexperimental
community-tested
stable
production-testedCREATE TABLE stable_stacks (
uid TEXT PRIMARY KEY,
stack_name TEXT,
cuda_version TEXT,
confidence_level TEXT,
notes TEXT,
platform_info TEXT,
UNIQUE(stack_name, cuda_version)
);
CREATE TABLE stable_stack_packages (
uid TEXT PRIMARY KEY,
stable_stack_uid TEXT NOT NULL,
package_uid TEXT NOT NULL,
version_string TEXT NOT NULL,
platform_info TEXT,
FOREIGN KEY (stable_stack_uid) REFERENCES stable_stacks(uid) ON DELETE CASCADE,
FOREIGN KEY (package_uid) REFERENCES packages(uid),
UNIQUE(stable_stack_uid, package_uid)
);CREATE TABLE wheel_availability (
uid TEXT PRIMARY KEY,
package_name TEXT,
package_version TEXT,
python_tag TEXT,
platform_tag TEXT,
cuda_variant TEXT,
available BOOLEAN,
platform_info TEXT,
UNIQUE(package_name, package_version, python_tag, platform_tag, cuda_variant)
);CREATE TABLE runtime_profiles (
uid TEXT PRIMARY KEY,
runtime_name TEXT,
kv_overhead_multiplier REAL,
fragmentation_multiplier REAL,
notes TEXT,
platform_info TEXT,
UNIQUE(runtime_name)
);Recommend:
- stable environments
- production-tested combinations
- ecosystem-safe stacks
- installed packages
- Python version
- CUDA version
- GPU architecture
Load Local DB
↓
Resolve Current Environment
↓
Detect Risky Packages
↓
Find Matching Stable Stacks
↓
Score Candidate Stacks
↓
Recommend Best Stable StackPrefer:
- production-tested
- stable
- community-tested
- experimental
Auto-fix:
- unstable combinations
- unsupported versions
- incompatible constraints
- pyproject.toml
- requirements.txt
Use:
- tomlkit
- tomllib
Not:
How much VRAM theoretically?Instead:
Why will this likely OOM?Estimate:
- weights
- KV cache
- activations
- optimizer states
- fragmentation
- quantization buffers
Use:
- huggingface_hub
from huggingface_hub import model_info
info = model_info("meta-llama/Llama-3-70B")weight_memory = (embedding_params + total_attention_params + total_ffn_params) * bytes_per_param- MoE Support: Includes all experts in VRAM (routed + shared).
- GQA Support: Accounts for reduced Key/Value head parameters.
kv_cache = 2 * batch * seq_len * num_layers * num_kv_heads * head_dim * bytes_per_elementtotal_vram = (weight_memory + kv_cache) * fragmentation_multiplier + activation_memory + framework_overheadNeed profiles for:
- transformers
- vllm
- llama.cpp
{
"runtime": "vllm",
"kv_overhead_multiplier": 1.2,
"fragmentation_multiplier": 1.15
}Future versions MAY include:
- Docker sandbox verification
- runtime reproduction
- crowd-sourced incompatibility confirmation
- automatic runtime validation
However:
The MVP should work entirely from:
- static metadata
- curated intelligence
- community-managed compatibility rules
- stable stack recommendations
The real moat is NOT:
- dependency resolution
The real moat IS:
- accumulated ecosystem intelligence
- operational compatibility knowledge
- stable stack recommendations
- runtime compatibility understanding
The database becomes:
the memory of the ecosystem