mirror of
https://github.com/SillyTavern/SillyTavern-Launcher.git
synced 2026-05-01 03:31:31 +00:00
updated VRAM/GPU retrieval to be more compatible with multi-GPU & integrated systems
This commit is contained in:
@@ -1,36 +1,57 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
REM Initialize variables
|
REM Initialize variables
|
||||||
set "GPU_name=Unknown"
|
set "GPU_names="
|
||||||
set "VRAM=Unknown"
|
set "VRAMs="
|
||||||
set "GPU_TYPE=Unknown"
|
set "TotalVRAM=0"
|
||||||
set "primary_gpu_found=false"
|
|
||||||
set "gpuDetected=false"
|
set "gpuDetected=false"
|
||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
REM Detect GPU name using wmic based on AdapterRAM size
|
REM Detect GPU names using wmic and store them in GPU_names
|
||||||
for /f "tokens=2 delims==" %%f in ('wmic path Win32_VideoController where "AdapterRAM > 0" get name /value ^| find "="') do (
|
for /f "tokens=2 delims==" %%f in ('wmic path Win32_VideoController where "AdapterRAM > 0" get name /value ^| find "="') do (
|
||||||
set "current_gpu=%%f"
|
set "current_gpu=%%f"
|
||||||
if /i "!current_gpu!" neq "Microsoft Basic Display Adapter" (
|
if /i "!current_gpu!" neq "Microsoft Basic Display Adapter" (
|
||||||
set "GPU_name=!current_gpu!"
|
if /i "!current_gpu!" neq "Intel(R) UHD Graphics" (
|
||||||
set "primary_gpu_found=true"
|
if defined GPU_names (
|
||||||
goto :vram_check
|
set "GPU_names=!GPU_names!, !current_gpu!"
|
||||||
) else if "!primary_gpu_found!" equ "false" (
|
) else (
|
||||||
set "GPU_name=!current_gpu!"
|
set "GPU_names=!current_gpu!"
|
||||||
goto :vram_check
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
:vram_check
|
REM Detect VRAM for each GPU found
|
||||||
REM Run PowerShell command to retrieve VRAM size and divide by 1GB
|
set "GPU_index=0"
|
||||||
for /f "usebackq tokens=*" %%i in (`powershell -Command "$qwMemorySize = (Get-ItemProperty -Path 'HKLM:\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0*' -Name HardwareInformation.qwMemorySize -ErrorAction SilentlyContinue).'HardwareInformation.qwMemorySize'; if ($null -ne $qwMemorySize -and $qwMemorySize -is [array]) { $qwMemorySize = [double]$qwMemorySize[0] } else { $qwMemorySize = [double]$qwMemorySize }; if ($null -ne $qwMemorySize) { [math]::Round($qwMemorySize/1GB) } else { 'Property not found' }"`) do (
|
for %%G in (%GPU_names%) do (
|
||||||
set "VRAM=%%i"
|
set /a "GPU_index+=1"
|
||||||
|
for /f "usebackq tokens=*" %%i in (`powershell -Command "$qwMemorySize = (Get-ItemProperty -Path 'HKLM:\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0*' -Name HardwareInformation.qwMemorySize -ErrorAction SilentlyContinue).'HardwareInformation.qwMemorySize'; if ($null -ne $qwMemorySize -and $qwMemorySize -is [array]) { $qwMemorySize = [double]$qwMemorySize[0] } else { $qwMemorySize = [double]$qwMemorySize }; if ($null -ne $qwMemorySize) { [math]::Round($qwMemorySize/1GB) } else { 'Property not found' }"`) do (
|
||||||
|
set /a "TotalVRAM+=%%i"
|
||||||
|
if defined VRAMs (
|
||||||
|
set "VRAMs=!VRAMs!, %%i GB"
|
||||||
|
) else (
|
||||||
|
set "VRAMs=%%i GB"
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
set "gpuDetected=true"
|
|
||||||
|
|
||||||
:gpu_found
|
REM Combine GPU and VRAM information into a single output
|
||||||
|
set "gpuDetected=true"
|
||||||
|
set "OutputLine="
|
||||||
if "%gpuDetected%"=="true" (
|
if "%gpuDetected%"=="true" (
|
||||||
echo GPU: %cyan_fg_strong%%GPU_name%%reset% - VRAM: %cyan_fg_strong%%VRAM%%reset% GB
|
set "GPU_index=0"
|
||||||
|
for %%G in (%GPU_names%) do (
|
||||||
|
set /a "GPU_index+=1"
|
||||||
|
for /f "tokens=1 delims=," %%V in ("!VRAMs!") do (
|
||||||
|
if defined OutputLine (
|
||||||
|
set "OutputLine=!OutputLine! | GPU%%GPU_index%%: %%G - VRAM: %%V"
|
||||||
|
) else (
|
||||||
|
set "OutputLine=GPU%%GPU_index%%: %%G - VRAM: %%V"
|
||||||
|
)
|
||||||
|
set "VRAMs=!VRAMs:%%V=!"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
echo !OutputLine! | Total VRAM: %TotalVRAM% GB
|
||||||
) else (
|
) else (
|
||||||
echo GPU Info not found
|
echo GPU Info not found
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user