Skip to main content

ML Environment Doctor

Python 3.8+ License: MIT PyPI CI

Diagnose ML environment issues, export shareable reports, and generate safe starting fixes.

ML Environment Doctor is a Python CLI for inspecting machine learning environments used for local development, CI jobs, and GPU containers. It focuses on practical readiness checks for PyTorch, TensorFlow/Keras, and JAX/Flax workflows, then turns those results into readable reports and automatable outputs.

Repository: https://github.com/Dheena731/Ml-env-doctor

What It Does Today

  • Diagnoses Python runtime compatibility
  • Checks NVIDIA driver visibility with nvidia-smi
  • Validates PyTorch version, CUDA visibility, and a basic CUDA tensor execution path
  • Validates TensorFlow import, GPU enumeration, and a small tensor execution path
  • Validates JAX backend visibility, Flax presence, and a small JAX array execution path
  • Checks common ML training libraries like transformers, peft, trl, datasets, and accelerate
  • Optionally checks GPU memory, disk space, Docker GPU support, and Hugging Face connectivity
  • Exports JSON, CSV, and HTML reports
  • Generates requirements files, Conda environment files, and Dockerfiles
  • Provides a safe fix workflow with planning, dry-run, apply, and verification modes

What It Does Not Claim Yet

  • It does not fully repair every environment problem automatically
  • It does not maintain a large model registry
  • It does not replace framework-native setup guides for CUDA, cuDNN, or TPU drivers
  • Its Docker generation is configurable, but still template-based rather than a full build system

Quick Start

pip install mlenvdoctor

mlenvdoctor diagnose
mlenvdoctor diagnose --full
mlenvdoctor diagnose --json -
mlenvdoctor doctor --json
mlenvdoctor report
mlenvdoctor fix --plan
mlenvdoctor fix --dry-run
mlenvdoctor fix --apply --yes
mlenvdoctor fix --verify
mlenvdoctor dockerize tinyllama --stack minimal

Main Commands

Diagnose

Detailed evidence and export command.

mlenvdoctor diagnose
mlenvdoctor diagnose --full
mlenvdoctor diagnose --json diagnostics.json
mlenvdoctor diagnose --json -
mlenvdoctor diagnose --csv diagnostics.csv --html diagnostics.html

diagnose returns stable exit codes:

  • 0: no warnings or critical issues
  • 1: warnings present
  • 2: critical issues present

Doctor

Action-oriented triage command. It is intentionally different from diagnose:

  • doctor tells you what failed, the likely cause, the best next fix, and how to verify it
  • diagnose shows the full evidence and supports exports

Compact CI-friendly output:

mlenvdoctor doctor --ci
mlenvdoctor doctor --ci --full
mlenvdoctor doctor --guided
mlenvdoctor doctor --json

Report

Save a shareable JSON and HTML bundle:

mlenvdoctor report
mlenvdoctor report --quick --output-dir artifacts/mlenvdoctor

Fix

The fix workflow is intentionally explicit:

mlenvdoctor fix --plan
mlenvdoctor fix --dry-run
mlenvdoctor fix --apply
mlenvdoctor fix --apply --yes
mlenvdoctor fix --verify
mlenvdoctor fix --rollback
mlenvdoctor fix --venv --apply --yes
mlenvdoctor fix --conda
mlenvdoctor fix --stack llm-training --dry-run

Current fix behavior:

  • Plans file-generation and environment actions from detected issues
  • Labels each planned action by risk level
  • Supports dry-run mode before changes
  • Can create a virtual environment
  • Can generate either requirements-mlenvdoctor.txt or environment-mlenvdoctor.yml
  • Can install requirements when --apply is used
  • Supports explicit verification via mlenvdoctor fix --verify
  • Re-runs diagnostics for verification after a successful apply

Stack

mlenvdoctor stack llm-training
mlenvdoctor stack llm-training --output requirements-llm-training.txt

Dockerize

mlenvdoctor dockerize tinyllama
mlenvdoctor dockerize mistral-7b --stack llm-training
mlenvdoctor dockerize --service --base-image nvidia/cuda:12.4.0-runtime-ubuntu22.04
mlenvdoctor dockerize gpt2 --python-version 3.10 -o Dockerfile.gpt2

Current Docker generation supports:

  • model-aware defaults for tinyllama, gpt2, and mistral-7b
  • stack selection
  • base image override
  • Python version selection
  • training and FastAPI service profiles

MCP

mlenvdoctor mcp serve

MCP now exposes a JSON-lines interface over stdin/stdout.

Core integration tools:

  • diagnose
  • get_fixes
  • doctor_summary
  • report_bundle
  • diagnose_environment (v1 alias)
  • get_fix_plan (v1 alias)
  • verify_fix (v1 alias)
  • export_report (v1 alias)
  • list_tools
  • tool_schema
  • health

Request format:

{"tool":"list_tools","arguments":{}}
{"tool":"tool_schema","arguments":{"name":"report_bundle"}}

Compatibility policy:

  • MCP schemas evolve additively.
  • v1 alias names are kept for migration safety.
  • Use tool_schema to discover canonical tool names.

Output Schema

JSON exports include:

  • issue name, status, severity, and fix command
  • check ID and category
  • recommendation, likely cause, and verify steps
  • confidence
  • evidence and metadata blocks
  • runtime context (platform, detected backend, NVIDIA tooling visibility)
  • summary counts and exit code

That makes the tool more useful for CI parsing, dashboards, and future integrations.

Development

git clone https://github.com/Dheena731/Ml-env-doctor.git
cd Ml-env-doctor
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
python -m black src tests
python -m ruff check src tests
python -m pytest
python -m mypy src

CI/CD and Release Flow

  • CI runs formatting (black --check), lint (ruff), tests (pytest), and package build checks (python -m build, twine check) on every push/PR.
  • The matrix tests Linux (3.8-3.11), macOS (3.11), and Windows (3.11).
  • A tagged GitHub release triggers the publish job to upload built artifacts to PyPI.
  • If CI fails locally vs. GitHub, run these exact commands first:
python -m black src tests
python -m ruff check src tests
python -m pytest

Test Strategy

The repository uses two test layers:

  • direct Python and Typer CliRunner tests for most command behavior
  • a smaller set of module-level tests for exports, validators, diagnostics, and file generation

This keeps the main test suite independent from whether mlenvdoctor was installed as a shell command in the current environment.

Documentation

  • Documentation site: https://dheena731.github.io/Ml-env-doctor/
  • Local preview: python -m pip install -r requirements-docs.txt && mkdocs serve
  • GitHub Pages: set Settings -> Pages -> Source to GitHub Actions; .github/workflows/pages.yml publishes mkdocs build --strict.

Repository Notes

License

This project is licensed under the MIT License. See LICENSE.

Metadata

Release files for mlenvdoctor 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlenvdoctor 0.1.6
File Size Uploaded
mlenvdoctor-0.1.6.tar.gz 166.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mlenvdoctor 0.1.6
File Interpreter ABI Platform
mlenvdoctor-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 220.0 kB

Release files / mlenvdoctor-0.1.6.tar.gz

Download URL mlenvdoctor-0.1.6.tar.gz
Size 166.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e868e688f03979f11d414a1baf54f7ec31bb5080519f63528a85ad42ff5f6b6c
BLAKE2b-256 checksum
How to use checksums
8f77b83da893745c1a73c54612f3600f81f91df4cb38b858780e2fce6cb5f0e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / mlenvdoctor-0.1.6-py3-none-any.whl

Download URL mlenvdoctor-0.1.6-py3-none-any.whl
Size 53.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e34620dee38e5f034af5b8a2f79762e8f5bac49d87d7026210e4717a86fbdae
BLAKE2b-256 checksum
How to use checksums
09434015843b24cbf9a78ba0a9a511dccad59a2c458b4eafb5f0bc254daa0b84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page