Skip to content

Commit

Permalink
Try to limit nvidia GPU queries to included GPUs (#5356)
Browse files Browse the repository at this point in the history
* Try to limit nvidia GPU queries to included GPUs

* ignore non digit GPU indexes

* formatting

* Formatting

* Remove trailing spaces

---------

Co-authored-by: Nicolas Mowen <[email protected]>
  • Loading branch information
jvrobert and NickM-27 authored Feb 4, 2023
1 parent db131d4 commit 7083a5c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frigate/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,17 @@ def get_nvidia_gpu_stats() -> dict[str, str]:
"--format=csv",
]

if (
"CUDA_VISIBLE_DEVICES" in os.environ
and os.environ["CUDA_VISIBLE_DEVICES"].isdigit()
):
nvidia_smi_command.extend(["--id", os.environ["CUDA_VISIBLE_DEVICES"]])
elif (
"NVIDIA_VISIBLE_DEVICES" in os.environ
and os.environ["NVIDIA_VISIBLE_DEVICES"].isdigit()
):
nvidia_smi_command.extend(["--id", os.environ["NVIDIA_VISIBLE_DEVICES"]])

p = sp.run(
nvidia_smi_command,
encoding="ascii",
Expand Down

0 comments on commit 7083a5c

Please sign in to comment.