diff --git a/ramalama/common.py b/ramalama/common.py index 240f38b4..cc3233e3 100644 --- a/ramalama/common.py +++ b/ramalama/common.py @@ -282,9 +282,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() diff --git a/ramalama/model.py b/ramalama/model.py index 48ca3750..2f2820e6 100644 --- a/ramalama/model.py +++ b/ramalama/model.py @@ -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) @@ -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"}