From 9d16d3c6afd321563801b2064824e453c30fb591 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sat, 7 Feb 2026 00:25:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(gpu):=20=E6=B7=BB=E5=8A=A0=20QSV=20?= =?UTF-8?q?=E7=A1=AC=E4=BB=B6=E5=8A=A0=E9=80=9F=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 实现 QSV 设备初始化逻辑,支持 Intel 核显 - 区分 QSV 和 CUDA 设备初始化流程 - 添加 QSV 设备验证和配置处理 - 更新设备检测逻辑以支持不同硬件加速类型 - 实现 QSV 设备名称格式化和可用性设置 --- services/gpu_scheduler.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/services/gpu_scheduler.py b/services/gpu_scheduler.py index 805bbdd..0a0c99a 100644 --- a/services/gpu_scheduler.py +++ b/services/gpu_scheduler.py @@ -61,11 +61,14 @@ class GPUScheduler: configured_devices = self._config.gpu_devices - if configured_devices: - # 使用配置指定的设备 + if self._config.hw_accel == HW_ACCEL_QSV: + # QSV 使用 Intel 核显,无 nvidia-smi,直接按配置或默认设备初始化 + self._devices = self._init_qsv_devices(configured_devices) + elif configured_devices: + # CUDA:使用配置指定的设备并通过 nvidia-smi 验证 self._devices = self._validate_configured_devices(configured_devices) else: - # 自动检测所有设备 + # CUDA:自动检测所有 NVIDIA 设备 self._devices = self._auto_detect_devices() if self._devices: @@ -75,6 +78,25 @@ class GPUScheduler: else: logger.warning("No GPU devices available, scheduler disabled") + def _init_qsv_devices(self, configured_indices: List[int]) -> List[GPUDevice]: + """ + 初始化 QSV 设备列表 + + QSV 使用 Intel 核显,没有 nvidia-smi 可用于检测。 + 若配置了 GPU_DEVICES 则直接信任配置,否则使用默认设备 0。 + + Args: + configured_indices: 配置的设备索引列表(可为空) + + Returns: + QSV 设备列表 + """ + indices = configured_indices if configured_indices else [0] + return [ + GPUDevice(index=idx, name=f"QSV-{idx}", available=True) + for idx in indices + ] + def _validate_configured_devices(self, indices: List[int]) -> List[GPUDevice]: """ 验证配置的设备列表