diff --git a/Dockerfile b/Dockerfile index f2def59..563dd56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] diff --git a/src/server.py b/src/server.py index c2b91e8..8548a86 100644 --- a/src/server.py +++ b/src/server.py @@ -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: