Updated to 0.4.0-1 ze-monitor to allow showing amount of memory on GPU

This commit is contained in:
James Ketr 2025-04-01 14:29:36 -07:00
parent 93f25bd919
commit 34edaa3fdc
2 changed files with 26 additions and 6 deletions

View File

@ -95,7 +95,7 @@ RUN apt-get install -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log}
RUN git clone --depth 1 --branch v0.3.0-1 https://github.com/jketreno/ze-monitor /opt/ze-monitor
RUN git clone --depth 1 --branch v0.4.0-1 https://github.com/jketreno/ze-monitor /opt/ze-monitor
WORKDIR /opt/ze-monitor/build
RUN cmake .. \
&& make \
@ -287,6 +287,7 @@ RUN usermod -aG ze-monitor root
# the source or follow on containers will always rebuild whenever
# the source changes.
#COPY /src/ /opt/airc/src/
COPY /src/requirements.txt /opt/airc/src/requirements.txt
SHELL [ "/bin/bash", "-c" ]

View File

@ -83,11 +83,30 @@ def get_graphics_cards():
# Clean up the output (remove leading/trailing whitespace and newlines)
output = result.stdout.strip()
for line in output.splitlines():
# Updated regex to handle GPU names containing parentheses
match = re.match(r'^[^(]*\((.*)\)', line)
if match:
gpus.append(match.group(1))
for index in range(len(output.splitlines())):
result = subprocess.run(['ze-monitor', f'--device {index+1} --info'], capture_output=True, text=True, check=True)
gpu_info = result.stdout.strip().splitlines()
gpu = {
"discrete": True, # Assume it's discrete initially
"name": None,
"memory": None
}
gpus.append(gpu)
for line in gpu_info:
match = re.match(r'^Device: [^(]*\((.*)\)', line)
if match:
gpu["name"] = match.group(1)
continue
match = re.match(r'^\s*Memory: (.*)', line)
if match:
gpu["memory"] = match.group(1)
continue
match = re.match(r'^\s*Is integrated with host: Yes"', line)
if match:
gpu["discrete"] = False
continue
return gpus
except Exception as e: