Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Intel ARC GPU in Meteor Lake chipset #749

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion ramalama/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,19 @@ def get_gpu():
os.environ["HIP_VISIBLE_DEVICES"] = str(gpu_num)
return

# INTEL iGPU CASE (Look for ARC GPU)
if os.path.exists('/sys/bus/pci/drivers/i915/0000:00:02.0/device'):
try:
with open('/sys/bus/pci/drivers/i915/0000:00:02.0/device', 'rb') as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use a glob for this?

glob.glob(/sys/bus/pci/drivers/i915/*/device)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so +1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try that.

Learning Python on the Go as it were... ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified to use glob.

WDYT?

content = f.read()
if b"0x7d55" in content:
os.environ["INTEL_VISIBLE_DEVICES"] = "1"
except OSError:
# Handle the case where the file does not exist
pass

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
Loading