forked from Comfy-Org/pyisolate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_benchmarks_windows.bat
More file actions
454 lines (397 loc) · 16.5 KB
/
run_benchmarks_windows.bat
File metadata and controls
454 lines (397 loc) · 16.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
@echo off
setlocal enabledelayedexpansion
echo ================================================================
echo PyIsolate Benchmark Runner for Windows
echo ================================================================
echo.
echo This script will:
echo 1. Check for uv installation
echo 2. Create a virtual environment
echo 3. Install PyTorch with appropriate CUDA support
echo 4. Install remaining dependencies
echo 5. Run performance and memory benchmarks
echo 6. Collect all results in a single file
echo.
echo NOTE: If this script freezes during benchmarks, try the PowerShell
echo version instead: run_benchmarks_windows.ps1
echo To enable PowerShell scripts, run this command first:
echo powershell -Command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser"
echo.
echo ================================================================
echo.
REM Set up paths and filenames
set "SCRIPT_DIR=%~dp0"
set "TIMESTAMP=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
set "TIMESTAMP=%TIMESTAMP: =0%"
set "OUTPUT_FILE=benchmark_results_%COMPUTERNAME%_%TIMESTAMP%.txt"
set "VENV_DIR=.benchmark_venv"
set "ERROR_LOG=benchmark_errors.log"
set "TEMP_OUTPUT=temp_output.txt"
REM Clean up any previous error log
if exist "%ERROR_LOG%" del "%ERROR_LOG%"
if exist "%TEMP_OUTPUT%" del "%TEMP_OUTPUT%"
echo [%date% %time%] Starting benchmark process... > "%OUTPUT_FILE%"
echo ================================================================ >> "%OUTPUT_FILE%"
echo SYSTEM INFORMATION >> "%OUTPUT_FILE%"
echo ================================================================ >> "%OUTPUT_FILE%"
echo System: Windows >> "%OUTPUT_FILE%"
echo Computer Name: %COMPUTERNAME% >> "%OUTPUT_FILE%"
echo. >> "%OUTPUT_FILE%"
REM Get detailed Windows version
echo Windows Version Details: >> "%OUTPUT_FILE%"
ver >> "%OUTPUT_FILE%" 2>&1
wmic os get Caption,Version,BuildNumber,OSArchitecture,ServicePackMajorVersion /format:list 2>nul | findstr "=" >> "%OUTPUT_FILE%"
echo. >> "%OUTPUT_FILE%"
REM Get detailed CPU information
echo CPU Information: >> "%OUTPUT_FILE%"
wmic cpu get Name,NumberOfCores,NumberOfLogicalProcessors,MaxClockSpeed,Architecture /format:list 2>nul | findstr "=" >> "%OUTPUT_FILE%"
echo Legacy Processor Info: %PROCESSOR_IDENTIFIER% >> "%OUTPUT_FILE%"
echo Number of Processors: %NUMBER_OF_PROCESSORS% >> "%OUTPUT_FILE%"
echo. >> "%OUTPUT_FILE%"
REM Get detailed memory information
echo Memory Information: >> "%OUTPUT_FILE%"
wmic computersystem get TotalPhysicalMemory /format:list 2>nul | findstr "=" >> "%OUTPUT_FILE%"
wmic OS get TotalVisibleMemorySize,FreePhysicalMemory /format:list 2>nul | findstr "=" >> "%OUTPUT_FILE%"
for /f "tokens=2 delims==" %%a in ('wmic computersystem get TotalPhysicalMemory /format:list ^| findstr "="') do (
set /a "RAM_GB=%%a/1024/1024/1024" 2>nul
if not "!RAM_GB!"=="" echo Total RAM: !RAM_GB! GB >> "%OUTPUT_FILE%"
)
echo. >> "%OUTPUT_FILE%"
REM Get detailed video card information
echo Video Card Information: >> "%OUTPUT_FILE%"
wmic path win32_VideoController get Name,AdapterRAM,DriverVersion,DriverDate,VideoProcessor /format:list 2>nul | findstr "=" >> "%OUTPUT_FILE%"
for /f "tokens=2 delims==" %%a in ('wmic path win32_VideoController get AdapterRAM /format:list ^| findstr "AdapterRAM" ^| findstr -v "AdapterRAM=$"') do (
set /a "VRAM_GB=%%a/1024/1024/1024" 2>nul
if not "!VRAM_GB!"=="" echo Video RAM: !VRAM_GB! GB >> "%OUTPUT_FILE%"
)
echo. >> "%OUTPUT_FILE%"
REM Get motherboard and system information
echo System Hardware: >> "%OUTPUT_FILE%"
wmic baseboard get Manufacturer,Product,Version /format:list 2>nul | findstr "=" >> "%OUTPUT_FILE%"
wmic computersystem get Manufacturer,Model,SystemType /format:list 2>nul | findstr "=" >> "%OUTPUT_FILE%"
echo. >> "%OUTPUT_FILE%"
REM Step 1: Check for uv
echo Step 1: Checking for uv installation...
where uv >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo.
echo ERROR: uv is not installed or not in PATH
echo.
echo Please install uv using one of these methods:
echo.
echo Option 1: Using PowerShell ^(recommended^):
echo powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
echo.
echo Option 2: Using pip:
echo pip install uv
echo.
echo Option 3: Download from https://github.com/astral-sh/uv/releases
echo.
echo After installation, please restart this script.
echo.
echo [%date% %time%] ERROR: uv not found >> "%OUTPUT_FILE%"
pause
exit /b 1
)
echo uv found: OK
echo [%date% %time%] uv found >> "%OUTPUT_FILE%"
REM Step 2: Create virtual environment
echo.
echo Step 2: Creating virtual environment...
if exist "%VENV_DIR%" (
echo Removing existing virtual environment...
rmdir /s /q "%VENV_DIR%" 2>"%ERROR_LOG%"
if !ERRORLEVEL! NEQ 0 (
echo WARNING: Could not remove existing venv, continuing anyway...
type "%ERROR_LOG%" >> "%OUTPUT_FILE%"
)
)
uv venv "%VENV_DIR%" 2>"%ERROR_LOG%"
if %ERRORLEVEL% NEQ 0 (
echo ERROR: Failed to create virtual environment
echo Error details:
type "%ERROR_LOG%"
echo.
echo [%date% %time%] ERROR: Failed to create venv >> "%OUTPUT_FILE%"
type "%ERROR_LOG%" >> "%OUTPUT_FILE%"
pause
exit /b 1
)
echo Virtual environment created: OK
echo [%date% %time%] Virtual environment created >> "%OUTPUT_FILE%"
REM Step 3: Activate virtual environment
echo.
echo Step 3: Activating virtual environment...
call "%VENV_DIR%\Scripts\activate.bat" 2>"%ERROR_LOG%"
if %ERRORLEVEL% NEQ 0 (
echo ERROR: Failed to activate virtual environment
type "%ERROR_LOG%"
echo [%date% %time%] ERROR: Failed to activate venv >> "%OUTPUT_FILE%"
type "%ERROR_LOG%" >> "%OUTPUT_FILE%"
pause
exit /b 1
)
echo Virtual environment activated: OK
REM Set environment variables that might help with multiprocessing
set PYTHONUNBUFFERED=1
set CUDA_LAUNCH_BLOCKING=1
echo Set PYTHONUNBUFFERED=1 and CUDA_LAUNCH_BLOCKING=1 for better error handling
REM Step 4: Detect CUDA and install PyTorch appropriately
echo.
echo Step 4: Detecting GPU and installing PyTorch...
echo.
REM Check for CUDA availability
set "CUDA_AVAILABLE=0"
set "CUDA_VERSION="
where nvidia-smi >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo NVIDIA GPU detected. Checking CUDA version...
REM Get CUDA version from nvidia-smi
for /f "tokens=*" %%i in ('nvidia-smi 2^>nul ^| findstr "CUDA Version"') do (
set "CUDA_LINE=%%i"
)
REM Extract CUDA version number
if defined CUDA_LINE (
for /f "tokens=4" %%a in ("!CUDA_LINE!") do (
set "CUDA_VERSION=%%a"
set "CUDA_AVAILABLE=1"
)
)
if !CUDA_AVAILABLE! EQU 1 (
echo Detected CUDA version: !CUDA_VERSION!
echo [%date% %time%] CUDA detected: !CUDA_VERSION! >> "%OUTPUT_FILE%"
REM Determine PyTorch CUDA version based on detected CUDA
REM Extract major version
for /f "tokens=1 delims=." %%a in ("!CUDA_VERSION!") do set "CUDA_MAJOR=%%a"
REM Map CUDA version to PyTorch index
if !CUDA_MAJOR! GEQ 12 (
set "TORCH_INDEX=https://download.pytorch.org/whl/cu121"
echo Installing PyTorch with CUDA 12.1 support...
) else if !CUDA_MAJOR! EQU 11 (
set "TORCH_INDEX=https://download.pytorch.org/whl/cu118"
echo Installing PyTorch with CUDA 11.8 support...
) else (
set "TORCH_INDEX=https://download.pytorch.org/whl/cpu"
echo CUDA version too old, installing CPU-only PyTorch...
)
) else (
echo Could not determine CUDA version, installing CPU-only PyTorch...
set "TORCH_INDEX=https://download.pytorch.org/whl/cpu"
)
) else (
echo No NVIDIA GPU detected. Installing CPU-only PyTorch...
set "TORCH_INDEX=https://download.pytorch.org/whl/cpu"
echo [%date% %time%] No CUDA detected, using CPU PyTorch >> "%OUTPUT_FILE%"
)
REM Install PyTorch with appropriate index
echo.
echo Installing PyTorch from: !TORCH_INDEX!
uv pip install torch torchvision torchaudio --index-url !TORCH_INDEX! > "%TEMP_OUTPUT%" 2>&1
set TORCH_INSTALL_RESULT=%ERRORLEVEL%
type "%TEMP_OUTPUT%"
type "%TEMP_OUTPUT%" >> "%OUTPUT_FILE%"
if %TORCH_INSTALL_RESULT% NEQ 0 (
echo.
echo ERROR: Failed to install PyTorch.
echo [%date% %time%] ERROR: Failed to install PyTorch >> "%OUTPUT_FILE%"
echo.
echo Continuing without PyTorch - some benchmarks will be skipped
echo.
) else (
echo PyTorch installed successfully!
echo [%date% %time%] PyTorch installed successfully >> "%OUTPUT_FILE%"
)
REM Step 5: Install remaining dependencies
echo.
echo Step 5: Installing remaining dependencies...
REM Install benchmark dependencies
uv pip install numpy psutil tabulate nvidia-ml-py3 pytest pytest-asyncio pyyaml > "%TEMP_OUTPUT%" 2>&1
type "%TEMP_OUTPUT%"
type "%TEMP_OUTPUT%" >> "%OUTPUT_FILE%"
REM Install pyisolate in editable mode
uv pip install -e . > "%TEMP_OUTPUT%" 2>&1
set PYISOLATE_RESULT=%ERRORLEVEL%
type "%TEMP_OUTPUT%"
type "%TEMP_OUTPUT%" >> "%OUTPUT_FILE%"
if %PYISOLATE_RESULT% NEQ 0 (
echo ERROR: Failed to install pyisolate
echo [%date% %time%] ERROR: Failed to install pyisolate >> "%OUTPUT_FILE%"
pause
exit /b 1
)
echo pyisolate installed: OK
echo [%date% %time%] pyisolate installed >> "%OUTPUT_FILE%"
REM Step 6: Verify installation
echo.
echo Step 6: Verifying installation...
echo. >> "%OUTPUT_FILE%"
echo Package Versions: >> "%OUTPUT_FILE%"
python --version >> "%OUTPUT_FILE%" 2>&1
python -c "import pyisolate; print(f'pyisolate: {pyisolate.__version__}')" >> "%OUTPUT_FILE%" 2>&1
python -c "import numpy; print(f'numpy: {numpy.__version__}')" >> "%OUTPUT_FILE%" 2>&1
python -c "import torch; print(f'torch: {torch.__version__}')" >> "%OUTPUT_FILE%" 2>&1
python -c "import torch; print(f'CUDA available: {torch.cuda.is_available()}')" >> "%OUTPUT_FILE%" 2>&1
python -c "import psutil; print(f'psutil: {psutil.__version__}')" >> "%OUTPUT_FILE%" 2>&1
echo. >> "%OUTPUT_FILE%"
REM Step 7: Run performance benchmarks
echo.
echo Step 7: Running performance benchmarks...
echo ================================================================ >> "%OUTPUT_FILE%"
echo PERFORMANCE BENCHMARKS >> "%OUTPUT_FILE%"
echo ================================================================ >> "%OUTPUT_FILE%"
echo. >> "%OUTPUT_FILE%"
cd benchmarks 2>nul
if %ERRORLEVEL% NEQ 0 (
echo ERROR: benchmarks directory not found
echo Make sure you're running this script from the pyisolate root directory
pause
exit /b 1
)
echo Running benchmark.py (this may take several minutes)...
echo Output is being saved to the results file...
REM Run benchmark directly without start command
echo Starting performance benchmark...
python benchmark.py --quick > "%TEMP_OUTPUT%" 2> "%ERROR_LOG%"
set BENCHMARK_RESULT=!ERRORLEVEL!
REM Combine stdout and stderr
if exist "%ERROR_LOG%" (
type "%ERROR_LOG%" >> "%TEMP_OUTPUT%"
)
REM Display and save the output
if exist "%TEMP_OUTPUT%" (
type "%TEMP_OUTPUT%"
type "%TEMP_OUTPUT%" >> "..\%OUTPUT_FILE%"
)
if %BENCHMARK_RESULT% EQU -1 (
echo.
echo WARNING: Performance benchmark timed out after 10 minutes
echo This may indicate CUDA multiprocessing issues on Windows
echo Partial results have been saved
echo.
) else if %BENCHMARK_RESULT% NEQ 0 (
echo.
echo WARNING: Performance benchmark failed or was interrupted
echo [%date% %time%] WARNING: Performance benchmark failed >> "..\%OUTPUT_FILE%"
echo Error code: %BENCHMARK_RESULT% >> "..\%OUTPUT_FILE%"
echo. >> "..\%OUTPUT_FILE%"
)
echo Continuing with memory benchmarks...
REM Step 8: Run memory benchmarks
echo.
echo Step 8: Running memory benchmarks...
echo. >> "..\%OUTPUT_FILE%"
echo ================================================================ >> "..\%OUTPUT_FILE%"
echo MEMORY BENCHMARKS >> "..\%OUTPUT_FILE%"
echo ================================================================ >> "..\%OUTPUT_FILE%"
echo. >> "..\%OUTPUT_FILE%"
echo Running memory_benchmark.py (this may take several minutes)...
echo Output is being saved to the results file...
echo NOTE: This test intentionally pushes VRAM limits to find maximum capacity
REM Run memory benchmark
REM Memory benchmarks take longer due to multiple extension creation
REM First, let's make sure we're in the benchmarks directory before running
REM and calculate the timeout time right before we need it
echo Starting memory benchmark preparation...
REM Run the memory benchmark with real-time output
echo.
echo ================================================================
echo STARTING MEMORY BENCHMARK
echo ================================================================
echo Starting at: !time!
echo If nothing has changed after 90 minutes, press Ctrl+C
echo.
echo The test intentionally pushes VRAM limits to find maximum capacity.
echo CUDA out-of-memory errors are EXPECTED and part of the testing.
echo.
REM Also log to file
echo. >> "..\%OUTPUT_FILE%"
echo ================================================================ >> "..\%OUTPUT_FILE%"
echo STARTING MEMORY BENCHMARK >> "..\%OUTPUT_FILE%"
echo ================================================================ >> "..\%OUTPUT_FILE%"
echo Starting at: !time! >> "..\%OUTPUT_FILE%"
echo. >> "..\%OUTPUT_FILE%"
REM Now run the actual benchmark and capture output
echo Running: python memory_benchmark.py --counts 1,2,5,10,25,50,100
echo.
REM Run the benchmark and capture output to a temporary file
python memory_benchmark.py --counts 1,2,5,10,25,50,100 > memory_output.tmp 2> memory_errors.tmp
set MEMORY_RESULT=!ERRORLEVEL!
REM Combine stdout and stderr
if exist memory_errors.tmp (
type memory_errors.tmp >> memory_output.tmp
del memory_errors.tmp
)
REM Display the output to console
if exist memory_output.tmp (
type memory_output.tmp
REM Also append to the main output file
type memory_output.tmp >> "..\%OUTPUT_FILE%"
del memory_output.tmp
)
if %MEMORY_RESULT% NEQ 0 (
echo.
echo WARNING: Memory benchmark failed or was interrupted
echo [%date% %time%] WARNING: Memory benchmark failed >> "..\%OUTPUT_FILE%"
echo Error code: %MEMORY_RESULT% >> "..\%OUTPUT_FILE%"
echo.
echo NOTE: Check the output above for details.
echo If the test appeared stuck, it may be due to Windows CUDA multiprocessing issues.
)
cd ..
REM Step 9: Collect additional runtime information
echo.
echo Step 9: Collecting additional runtime information...
echo. >> "%OUTPUT_FILE%"
echo ================================================================ >> "%OUTPUT_FILE%"
echo RUNTIME INFORMATION >> "%OUTPUT_FILE%"
echo ================================================================ >> "%OUTPUT_FILE%"
REM Get current memory usage
echo. >> "%OUTPUT_FILE%"
echo Current Memory Usage: >> "%OUTPUT_FILE%"
wmic OS get FreePhysicalMemory,TotalVisibleMemorySize /format:list 2>nul | findstr "=" >> "%OUTPUT_FILE%"
REM Try nvidia-smi if available for current GPU status
where nvidia-smi >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo. >> "%OUTPUT_FILE%"
echo Current NVIDIA GPU Status: >> "%OUTPUT_FILE%"
nvidia-smi --query-gpu=name,memory.total,memory.used,memory.free,temperature.gpu,utilization.gpu --format=csv >> "%OUTPUT_FILE%" 2>&1
echo. >> "%OUTPUT_FILE%"
echo Full nvidia-smi output: >> "%OUTPUT_FILE%"
nvidia-smi >> "%OUTPUT_FILE%" 2>&1
)
REM Get disk space information
echo. >> "%OUTPUT_FILE%"
echo Disk Space Information: >> "%OUTPUT_FILE%"
wmic logicaldisk get size,freespace,caption /format:list 2>nul | findstr "=" >> "%OUTPUT_FILE%"
REM Final summary
echo. >> "%OUTPUT_FILE%"
echo ================================================================ >> "%OUTPUT_FILE%"
echo [%date% %time%] Benchmark collection completed >> "%OUTPUT_FILE%"
echo ================================================================ >> "%OUTPUT_FILE%"
REM Cleanup temporary files
if exist "%TEMP_OUTPUT%" del "%TEMP_OUTPUT%"
if exist "%ERROR_LOG%" del "%ERROR_LOG%"
REM Deactivate virtual environment
call deactivate 2>nul
REM Display completion message
echo.
echo ================================================================
echo BENCHMARK COLLECTION COMPLETED!
echo ================================================================
echo.
echo Results have been saved to: %OUTPUT_FILE%
echo.
echo Please send the file '%OUTPUT_FILE%' back for analysis.
echo.
echo IMPORTANT NOTES:
echo - The benchmarks intentionally push VRAM limits to find maximum capacity
echo - CUDA out-of-memory errors are EXPECTED and part of the testing
echo - If tests timeout, it may indicate Windows CUDA multiprocessing limitations
echo - Partial results are still valuable and have been saved
echo.
echo If you encountered any errors, please also include any error
echo messages shown above.
echo.
echo Thank you for running the benchmarks!
echo.
pause