Skip to content

Commit

Permalink
修正gpu占用率读取
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Oct 24, 2023
1 parent e918bec commit 9051340
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
try:
LOG_LOCATION = "/tmp/PowerControl_py.log"
logging.basicConfig(
level = logging.DEBUG,
level = logging.INFO,
filename = LOG_LOCATION,
format="[%(asctime)s | %(filename)s:%(lineno)s:%(funcName)s] %(levelname)s: %(message)s",
filemode = 'w',
Expand Down
5 changes: 3 additions & 2 deletions backend/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def Check_gpuFreq(self, freqMin:int, freqMax:int):
global gpu_freqMax
global gpu_freqMin
try:
logging.debug(f"GPUFREQ_PATH = {GPUFREQ_PATH}")
# logging.debug(f"GPUFREQ_PATH = {GPUFREQ_PATH}")
#可查询gpu设置频率时,判断当前设置是否与系统相同
if os.path.exists(GPUFREQ_PATH):
lines = open(GPUFREQ_PATH,"r")
Expand All @@ -172,7 +172,8 @@ def Check_gpuFreq(self, freqMin:int, freqMax:int):
command="sudo sh {} set_clock_limits {} {}".format(SH_PATH,freqMin,freqMax)
os.system(command)
else:
logging.debug(f"{self.name}|检测到当前设置与系统相同 当前系统频率 qfreqMin={qfreqMin} qfreMax={qfreqMax}")
# logging.debug(f"{self.name}|检测到当前设置与系统相同 当前系统频率 qfreqMin={qfreqMin} qfreMax={qfreqMax}")
pass
#查不到gpu设置频率时,只要合法则进行设置
else:
logging.debug(f"{self.name}|无法查询当前系统GPU频率")
Expand Down
5 changes: 3 additions & 2 deletions backend/sysInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import asyncio
from ec import EC
from config import logging,SH_PATH,PRODUCT_NAME
from config import FAN_GPUTEMP_PATH,FAN_CPUTEMP_PATH
from config import FAN_GPUTEMP_PATH,FAN_CPUTEMP_PATH,GPU_DEVICE_PATH
from helpers import get_user

cpu_busyPercent = 0
Expand All @@ -18,8 +18,9 @@
has_gpuData = True

statPath="/proc/stat"
gpu_busy_percentPath="/sys/class/drm/card0/device/gpu_busy_percent"
gpu_busy_percentPath="{}/gpu_busy_percent".format(GPU_DEVICE_PATH)
hwmon_path="/sys/class/hwmon"

#GPU单次监控数据
class GPUData:
def __init__(self):
Expand Down

0 comments on commit 9051340

Please sign in to comment.