Comfy AIMDO (AI Model Dynamic Offloader) is a core utility for ComfyUI, acting as a PyTorch VRAM allocator. It implements on-demand offloading of model weights when the primary PyTorch VRAM allocator comes under pressure, aiming to prevent out-of-memory errors and optimize GPU memory usage for AI models. It is currently at version 0.2.12 and is actively maintained as an integral part of the ComfyUI ecosystem.
Install & Compatibility
Where this runs
tested against v0.4.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.925 runs
installs and imports cleanly · install 0.0s · import 0.049s · 17.9MB
glibcpy 3.10–3.925 runs
installs and imports cleanly · install 1.6s · import 0.060s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
The primary public API is within the 'control' submodule, not the top-level package.
import comfy_aimdo.control
Comfy AIMDO is a backend VRAM management solution, not typically used directly by end-user Python scripts. Its functionality is integrated into ComfyUI and activated upon launching ComfyUI, often via the `--enable-dynamic-vram` flag. This quickstart demonstrates how to launch ComfyUI to utilize Comfy AIMDO's features. Replace `COMFYUI_PATH` with your actual ComfyUI installation directory.
# 1. Ensure Comfy AIMDO is installed (it's often a dependency of ComfyUI).
# pip install comfy-aimdo
# 2. Launch ComfyUI with dynamic VRAM management enabled.
# Comfy AIMDO operates as a backend, and its functionality is typically activated
# by launching ComfyUI with specific flags, rather than direct Python API calls.
# This example assumes you have ComfyUI installed and its 'main.py' is runnable.
import subprocess
import os
# Path to your ComfyUI directory
comfyui_path = os.environ.get('COMFYUI_PATH', './ComfyUI')
# Command to launch ComfyUI with dynamic VRAM (AIMDO) enabled
# The --enable-dynamic-vram flag tells ComfyUI to utilize comfy-aimdo if detected
command = [
os.path.join(comfyui_path, 'python_env/python.exe') if os.name == 'nt' else os.path.join(comfyui_path, 'venv/bin/python'),
os.path.join(comfyui_path, 'main.py'),
'--enable-dynamic-vram',
'--listen' # Optional: listen on all interfaces
]
print(f"Launching ComfyUI with AIMDO: {' '.join(command)}")
try:
# This will block until ComfyUI exits. For non-blocking, use Popen without .wait()
process = subprocess.run(command, check=True, text=True, capture_output=True)
print("ComfyUI output:")
print(process.stdout)
if process.stderr:
print("ComfyUI errors (if any):")
print(process.stderr)
except FileNotFoundError:
print(f"Error: ComfyUI or its Python environment not found at {comfyui_path}.")
print("Please ensure COMFYUI_PATH environment variable is set correctly or adjust the 'comfyui_path' variable.")
except subprocess.CalledProcessError as e:
print(f"Error launching ComfyUI: {e}")
print("Stderr:")
print(e.stderr)
print("Stdout:")
print(e.stdout)
except Exception as e:
print(f"An unexpected error occurred: {e}")
print("ComfyUI launched (or attempted to launch). Check your browser at http://127.0.0.1:8188 (or specified --listen address).")
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.