Skip to content

GPU device selection#7

Open
Mark-Shun wants to merge 2 commits into
Kim2091:mainfrom
Mark-Shun:feature/GPU-device-selection
Open

GPU device selection#7
Mark-Shun wants to merge 2 commits into
Kim2091:mainfrom
Mark-Shun:feature/GPU-device-selection

Conversation

@Mark-Shun

@Mark-Shun Mark-Shun commented Jun 22, 2026

Copy link
Copy Markdown

The issue

As mentioned in the Discord server, a friend of mine ran into the problem that the wrong GPU device (integrated graphics card on presumably the CPU) was being used instead of the dedicated video card (0,5GB VRAM vs 6.0GB VRAM). Due to this inference/processing was extremely slow. Looking at the code base it seems like it automatically hardcoded selects the first available device.

Goal of this change

The goal of this PR was to create and intergrade a GPU device selection functionality into the settings, so that an user can manually adjust it if needed.

Having tested it with the user encountering the problem, it now works.

As can be seen in the screenshot, Vapourkit now uses the NVIDIA GPU instead of the AMD Radeon iGPU
image

The functionality is exposed in the settings panel in the inference backend.
image

Changes

Disclaimer: AI has been utilized to implement these changes

Backend

The NPM package systeminformation has been added and is being utilised to retrieve the available graphics devices.

  • utils.ts: Uses systeminformation (si.graphics()). Exported getCachedGpus() for downstream cache access.
  • preload.ts: Forwards deviceId parameter across all 4 IPC bridges (startUpscale, previewSegment, launchVsePreviewer, getOutputResolution).
  • videoHandlers.ts: Accepted deviceId in all 4 IPC handlers; threaded it through createScriptConfig() and the launch-vse-previewer inline config.
  • scriptGenerator.ts: Added deviceId to ScriptConfig. Injected device_id into both DirectML (ort.Model) and TensorRT (trt.Model) VapourSynth script calls. Includes CUDA index translation (counts only NVIDIA GPUs for TensorRT, preserving DXGI order for DirectML). Enumerate GPUs if cache is empty at script-generation time.

Frontend

  • hooks/useSettings.ts: Manages deviceId state with localStorage persistence. Validates the stored ID against enumerated GPUs after mount; falls back to primary GPU if stale.
  • components/SettingsModal.tsx: New GPU Device section with dropdown (name, VRAM, index) and a wrapped numeric override for edge cases.
  • hooks/useVideoProcessing.ts, hooks/useOutputResolution.ts: Accept and forward deviceId to all backend IPC calls.
  • App.tsx, AppModals.tsx: Wire deviceId state through the components.

Backwards compatibility:

Defaults to device_id=0 when no preference is saved. All existing IPC signatures maintain backward compatibility via optional deviceId parameters.

@Mark-Shun

Copy link
Copy Markdown
Author

Can I do anything on my end to make this PR acceptable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant