-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for nVidia GPU temp sensor
- Loading branch information
1 parent
4d9f8e9
commit 240185a
Showing
7 changed files
with
92 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "1.1.7" | ||
__version__ = "1.1.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import subprocess | ||
from subprocess import CompletedProcess, CalledProcessError | ||
from typing import List, Dict | ||
|
||
from .sensor import Sensor | ||
from .log import LogManager | ||
|
||
SMI_DETECT_COMMAND: List[str] = ['sh', '-c', 'nvidia-smi --query-gpu=index,gpu_name --format=csv,noheader,nounits'] | ||
SMI_SATUS_COMMAND: List[str] = ['sh', '-c', 'nvidia-smi --query-gpu=index,gpu_name,temperature.gpu,utilization.gpu,fan.speed --format=csv,noheader,nounits'] | ||
|
||
|
||
class NvidiaSensor(Sensor): | ||
|
||
def __init__(self, index: int, device_name: str): | ||
super().__init__() | ||
self.index = index | ||
self.device_name = device_name | ||
self.device_description = device_name | ||
self.sensor_name = "nVidia GPU" | ||
self.current_temp = 0.0 | ||
|
||
def get_temperature(self) -> float: | ||
LogManager.logger.debug(f"Reading temperature from {self.sensor_name}") | ||
self.current_temp = 0.0 | ||
try: | ||
command_result: CompletedProcess = subprocess.run(SMI_SATUS_COMMAND, capture_output=True, check=True, text=True) | ||
result_lines = str(command_result.stdout).splitlines() | ||
for line in result_lines: | ||
if not line.strip(): | ||
continue | ||
values = line.split(', ') | ||
if int(values[0]) == self.index: | ||
LogManager.logger.debug(f"{self.sensor_name} read-out: {line}") | ||
temp = int(values[2]) | ||
if 0 <= temp <= 100: | ||
self.current_temp = float(temp) | ||
else: | ||
LogManager.logger.warning(f"Invalid sensor data from {self.sensor_name}: {temp}") | ||
except CalledProcessError: | ||
LogManager.logger.warning(f"Problem getting status from nVidia GPU '{self.device_name}'") | ||
return self.current_temp | ||
|
||
def get_signature(self) -> list: | ||
return [__class__.__name__, self.device_description, self.index, self.sensor_name] | ||
|
||
@staticmethod | ||
def detect_gpus() -> List['NvidiaSensor']: | ||
detected_gpus = [] | ||
try: | ||
command_result: CompletedProcess = subprocess.run(SMI_DETECT_COMMAND, capture_output=True, check=True, text=True) | ||
result_lines = str(command_result.stdout).splitlines() | ||
LogManager.logger.debug(f"Result of nVidia GPU detection: {result_lines}") | ||
for line in result_lines: | ||
if not line.strip(): | ||
continue | ||
values = line.split(', ') | ||
detected_gpus.append(NvidiaSensor(int(values[0]), values[1])) | ||
except CalledProcessError: | ||
LogManager.logger.debug(f"No nVidia GPU found") | ||
return detected_gpus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
setuptools~=45.2.0 | ||
pyqtgraph~=0.12.4 | ||
liquidctl~=1.6.1 | ||
numpy~=1.17.4 | ||
PyYAML~=5.3.1 | ||
PySensors~=0.0.4 | ||
pid~=3.0.4 | ||
PyQt5~=5.14.1 | ||
pyxdg~=0.28 | ||
setuptools | ||
pyqtgraph | ||
liquidctl | ||
numpy | ||
PyYAML | ||
PySensors | ||
pid | ||
PyQt5 | ||
pyxdg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters