@echo off
setlocal enabledelayedexpansion

:: 1. SET PYTHON PATH AND VERIFY VERSION
set PYTHON_BIN=python

echo [INFO] Checking Python Version...
:: Checks if Python is in PATH and specifically version 3.10.11
%PYTHON_BIN% -c "import sys; exit(0) if sys.version_info[:3] == (3, 10, 11) else exit(1)" >nul 2>&1

if %errorlevel% neq 0 (
    echo [ERROR] Python 3.10.11 not detected!
    echo.
    echo This script REQUIRES Python 3.10.11 specifically for DirectML compatibility.
    echo Download it here: https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe
    echo.
    echo If already installed, make sure you checked "Add Python to PATH" during setup or add it manually.
    pause
    exit /b
) else (
    echo [INFO] Python 3.10.11 confirmed.
)

:: 2. DEPENDENCY PROTECTION (Anti-Overwrite)
echo [INFO] Checking package integrity...
%PYTHON_BIN% -m pip install -r requirements.txt --quiet

:: FORCED OVERWRITE: Ensures torch-directml remains the default backend
:: This repairs the environment if an extension tried to install CUDA versions
echo [INFO] Shielding Torch-DirectML against extension interference...
%PYTHON_BIN% -m pip install torch-directml torchvision torchaudio sqlalchemy --upgrade --quiet

:: 3. COMFYUI-MANAGER
if not exist custom_nodes\ComfyUI-Manager (
    echo [INFO] Installing ComfyUI-Manager for the first time...
    git clone https://github.com/ltdrdata/ComfyUI-Manager custom_nodes/ComfyUI-Manager
)

:: 4. LAUNCH COMFYUI
echo.
echo ========================================================
echo   INITIALIZING: DirectML
echo   VERSION: Python 3.10.11
echo   MODE: --lowvram (Memory Optimized)
echo ========================================================
echo.

:: Arguments optimized for stability
:: --use-quad-cross-attention can be used instead of --use-split-cross-attention, it saves memory but it's slower

%PYTHON_BIN% main.py --directml --force-fp16 --lowvram --preview-method auto --use-split-cross-attention --auto-launch

if %errorlevel% neq 0 (
    echo.
    echo [CRASH] An error occurred. Check the logs above.
    pause
)
Edit

Pub: 05 Mar 2026 13:51 UTC

Views: 7