mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-28 02:08:57 +03:00
Add support for SR-IOV GPU stats (#15796)
* Add option to treat GPU as SRIOV in order for stats to work correctly * Add to intel docs * fix tests
This commit is contained in:
committed by
Blake Blackshear
parent
6a83f40135
commit
458ca4a983
@@ -11,6 +11,9 @@ class StatsConfig(FrigateBaseModel):
|
||||
network_bandwidth: bool = Field(
|
||||
default=False, title="Enable network bandwidth for ffmpeg processes."
|
||||
)
|
||||
sriov: bool = Field(
|
||||
default=False, title="Treat device as SR-IOV to support GPU stats."
|
||||
)
|
||||
|
||||
|
||||
class TelemetryConfig(FrigateBaseModel):
|
||||
|
||||
@@ -195,7 +195,7 @@ async def set_gpu_stats(
|
||||
continue
|
||||
|
||||
# intel QSV GPU
|
||||
intel_usage = get_intel_gpu_stats()
|
||||
intel_usage = get_intel_gpu_stats(config.telemetry.stats.sriov)
|
||||
|
||||
if intel_usage is not None:
|
||||
stats["intel-qsv"] = intel_usage or {"gpu": "", "mem": ""}
|
||||
@@ -220,7 +220,7 @@ async def set_gpu_stats(
|
||||
continue
|
||||
|
||||
# intel VAAPI GPU
|
||||
intel_usage = get_intel_gpu_stats()
|
||||
intel_usage = get_intel_gpu_stats(config.telemetry.stats.sriov)
|
||||
|
||||
if intel_usage is not None:
|
||||
stats["intel-vaapi"] = intel_usage or {"gpu": "", "mem": ""}
|
||||
|
||||
@@ -38,7 +38,7 @@ class TestGpuStats(unittest.TestCase):
|
||||
process.returncode = 124
|
||||
process.stdout = self.intel_results
|
||||
sp.return_value = process
|
||||
intel_stats = get_intel_gpu_stats()
|
||||
intel_stats = get_intel_gpu_stats(False)
|
||||
print(f"the intel stats are {intel_stats}")
|
||||
assert intel_stats == {
|
||||
"gpu": "1.13%",
|
||||
|
||||
@@ -255,7 +255,7 @@ def get_amd_gpu_stats() -> dict[str, str]:
|
||||
return results
|
||||
|
||||
|
||||
def get_intel_gpu_stats() -> dict[str, str]:
|
||||
def get_intel_gpu_stats(sriov: bool) -> dict[str, str]:
|
||||
"""Get stats using intel_gpu_top."""
|
||||
|
||||
def get_stats_manually(output: str) -> dict[str, str]:
|
||||
@@ -302,6 +302,9 @@ def get_intel_gpu_stats() -> dict[str, str]:
|
||||
"1",
|
||||
]
|
||||
|
||||
if sriov:
|
||||
intel_gpu_top_command += ["-d", "drm:/dev/dri/card0"]
|
||||
|
||||
p = sp.run(
|
||||
intel_gpu_top_command,
|
||||
encoding="ascii",
|
||||
|
||||
Reference in New Issue
Block a user