mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-15 20:43:31 +08:00
Added an install.bat file and a run.bat file, as well.
This commit is contained in:
parent
0f2b8525bc
commit
8434c718bf
67
0_RUN.bat
Normal file
67
0_RUN.bat
Normal file
@ -0,0 +1,67 @@
|
||||
@echo off
|
||||
setlocal
|
||||
cd /d "%~dp0"
|
||||
|
||||
REM Ensure venv exists
|
||||
if not exist "venv\Scripts\activate.bat" (
|
||||
echo ERROR: Virtual environment not found. Run 1_INSTALL.bat first.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Activate venv
|
||||
call "venv\Scripts\activate.bat"
|
||||
|
||||
REM Ensure main.py exists
|
||||
if not exist "main.py" (
|
||||
echo ERROR: main.py not found in: %cd%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "LOG=%TEMP%\main_run_%RANDOM%.log"
|
||||
|
||||
REM Run and capture output
|
||||
python "main.py" > "%LOG%" 2>&1
|
||||
set "RC=%ERRORLEVEL%"
|
||||
|
||||
type "%LOG%"
|
||||
|
||||
REM If Torch is CPU-only, repair for CUDA 12.9
|
||||
findstr /I /C:"AssertionError: Torch not compiled with CUDA enabled" "%LOG%" >nul
|
||||
if %ERRORLEVEL%==0 (
|
||||
echo Torch is CPU-only; repairing for CUDA 12.9...
|
||||
|
||||
REM Check Torch-reported CUDA version
|
||||
set "TORCH_CUDA="
|
||||
for /f "delims=" %%V in ('python -c "import torch,sys; print(getattr(torch.version,'cuda',None) or '')" 2^>NUL') do set "TORCH_CUDA=%%V"
|
||||
echo Detected torch.version.cuda="%TORCH_CUDA%"
|
||||
|
||||
REM If not 12.9 (or blank), install CUDA 12.9 runtime via pip
|
||||
if /I not "%TORCH_CUDA%"=="12.9" (
|
||||
echo Installing NVIDIA CUDA 12.9 runtime via pip...
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install nvidia-pyindex
|
||||
python -m pip install -U nvidia-cuda-runtime-cu129
|
||||
)
|
||||
|
||||
REM Reinstall PyTorch for cu129
|
||||
echo Reinstalling PyTorch CUDA 12.9 wheels...
|
||||
python -m pip uninstall -y torch torchaudio
|
||||
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu129
|
||||
|
||||
echo Re-running main.py...
|
||||
python "main.py"
|
||||
set "RC=%ERRORLEVEL%"
|
||||
)
|
||||
|
||||
del "%LOG%" >nul 2>&1
|
||||
|
||||
if not "%RC%"=="0" (
|
||||
echo main.py exited with code %RC%.
|
||||
) else (
|
||||
echo Done.
|
||||
)
|
||||
|
||||
pause
|
||||
exit /b %RC%
|
||||
42
1_INSTALL.bat
Normal file
42
1_INSTALL.bat
Normal file
@ -0,0 +1,42 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
REM Run from this script's directory
|
||||
cd /d "%~dp0"
|
||||
|
||||
set "PYTHON_EXE=C:\Users\james\AppData\Local\Programs\Python\Python312\python.exe"
|
||||
|
||||
if not exist "%PYTHON_EXE%" (
|
||||
echo ERROR: Python not found at "%PYTHON_EXE%".
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Create venv if missing
|
||||
if exist venv (
|
||||
echo Found existing virtual environment.
|
||||
) else (
|
||||
echo Creating virtual environment...
|
||||
"%PYTHON_EXE%" -m venv venv
|
||||
if errorlevel 1 (
|
||||
echo ERROR: Failed to create virtual environment.
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
REM Activate venv
|
||||
call "venv\Scripts\activate.bat"
|
||||
|
||||
REM Install requirements
|
||||
if exist requirements.txt (
|
||||
echo Upgrading pip...
|
||||
python -m pip install --upgrade pip
|
||||
echo Installing packages from requirements.txt...
|
||||
python -m pip install -r requirements.txt
|
||||
) else (
|
||||
echo ERROR: requirements.txt not found.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Done.
|
||||
endlocal
|
||||
pause
|
||||
Loading…
x
Reference in New Issue
Block a user