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

Conversation

cgruver
Copy link
Collaborator

@cgruver cgruver commented Feb 6, 2025

Add logic to detect an Intel GPU and set INTEL_VISIBLE_DEVICES if found.

Note: This is preliminary logic that narrowly detects the Intel ARC GPU in the Meteor Lake Core Ultra 7 chipset.

Summary by Sourcery

Detect Intel ARC GPUs and use them if available.

New Features:

  • Enable the use of Intel ARC GPUs on systems with Meteor Lake Core Ultra 7 chipsets.

Tests:

  • Update tests to support Intel ARC GPUs.

Copy link
Contributor

sourcery-ai bot commented Feb 6, 2025

Reviewer's Guide by Sourcery

This pull request adds preliminary support for Intel ARC GPUs on Meteor Lake chipsets. It implements GPU detection logic by scanning PCI device files for a specific Intel ARC identifier and sets the 'INTEL_VISIBLE_DEVICES' environment variable. Additionally, updates to configuration and image mapping in the model allow the system to properly utilize Intel GPUs.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Implemented detection logic for Intel ARC GPUs.
  • Added code in common.py to scan '/sys/bus/pci/drivers/i915/*/device' files for the Intel ARC GPU identifier.
  • Incremented the GPU count when the identifier is found and set the 'INTEL_VISIBLE_DEVICES' environment variable accordingly.
  • Updated the environment variable filter in get_env_vars() to include 'INTEL_' prefix.
ramalama/common.py
Integrated Intel GPU support into image selection and GPU arguments.
  • Added a mapping for 'INTEL_VISIBLE_DEVICES' in the GPU image selection within model.py.
  • Updated the gpu_args() function to check for the 'INTEL_VISIBLE_DEVICES' environment variable.
ramalama/model.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cgruver
Copy link
Collaborator Author

cgruver commented Feb 6, 2025

@ericcurtin @rhatdan

WDYT?

This is an attempt at Intel GPU detection. It's very narrow at this point, but we can iterate on it to make it capable of broader detection.

# 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?

@cgruver
Copy link
Collaborator Author

cgruver commented Feb 7, 2025

There are other iGPU types from Intel which will work in theory. Right now the test is for a very specific chip.

As we identify other iGPUs that provide a boost over CPU inference, we'll need to decide how to handle a table of supported iGPUs.

@cgruver
Copy link
Collaborator Author

cgruver commented Feb 7, 2025

I've got some 13th gen and 12 gen NUCs which I plan to test. They are currently part of OCP clusters in my lab, but I can tear them down this weekend. Anything older than that is probably not worth it. CPU will likely be better.

@cgruver cgruver requested review from rhatdan and dougsland February 7, 2025 20:54
@rhatdan
Copy link
Member

rhatdan commented Feb 7, 2025

LGTM
But you need to take draft flag off.

@cgruver cgruver marked this pull request as ready for review February 7, 2025 21:29
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @cgruver - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider wrapping file I/O in a try-except block to safely handle unreadable or transient files.
  • Refactor the Intel detection logic into its own function to improve clarity and testability.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@cgruver
Copy link
Collaborator Author

cgruver commented Feb 7, 2025

LGTM But you need to take draft flag off.

Done.

@ericcurtin ericcurtin merged commit d0f912f into containers:main Feb 7, 2025
16 checks passed
@cgruver cgruver deleted the detect-gpu branch February 7, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants