Skip to content

Commit

Permalink
Merge pull request #749 from cgruver/detect-gpu
Browse files Browse the repository at this point in the history
Detect Intel ARC GPU in Meteor Lake chipset
  • Loading branch information
ericcurtin authored Feb 7, 2025
2 parents 7e1b334 + df6e767 commit d0f912f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ramalama/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,19 @@ def get_gpu():
os.environ["HIP_VISIBLE_DEVICES"] = str(gpu_num)
return

# INTEL iGPU CASE (Look for ARC GPU)
igpu_num = 0
for fp in sorted(glob.glob('/sys/bus/pci/drivers/i915/*/device')):
with open(fp, 'rb') as file:
content = file.read()
if b"0x7d55" in content:
igpu_num += 1

if igpu_num:
os.environ["INTEL_VISIBLE_DEVICES"] = str(igpu_num)

def get_env_vars():
prefixes = ("ASAHI_", "CUDA_", "HIP_", "HSA_")
prefixes = ("ASAHI_", "CUDA_", "HIP_", "HSA_", "INTEL_")
env_vars = {k: v for k, v in os.environ.items() if k.startswith(prefixes)}

# gpu_type, gpu_num = get_gpu()
Expand Down
2 changes: 2 additions & 0 deletions ramalama/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def _image(self, args):
"HIP_VISIBLE_DEVICES": "quay.io/ramalama/rocm",
"CUDA_VISIBLE_DEVICES": "quay.io/ramalama/cuda",
"ASAHI_VISIBLE_DEVICES": "quay.io/ramalama/asahi",
"INTEL_VISIBLE_DEVICES": "quay.io/ramalama/intel-gpu",
}

image = images.get(gpu_type, args.image)
Expand Down Expand Up @@ -199,6 +200,7 @@ def gpu_args(self, args, runner=False):
or os.getenv("HIP_VISIBLE_DEVICES")
or os.getenv("ASAHI_VISIBLE_DEVICES")
or os.getenv("CUDA_VISIBLE_DEVICES")
or os.getenv("INTEL_VISIBLE_DEVICES")
or (
# linux and macOS report aarch64 differently
platform.machine() in {"aarch64", "arm64"}
Expand Down

0 comments on commit d0f912f

Please sign in to comment.