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

Fix ramalama info to display NVIDIA and amd GPU information #848

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Feb 18, 2025

Fixes: #822

Summary by Sourcery

This pull request enhances GPU detection to provide more detailed information about NVIDIA GPUs and fixes an issue where AMD GPU detection was not returning any value. The NVIDIA GPU detection now retrieves and displays the GPU name, VRAM, and associated environment variable.

New Features:

  • The NVIDIA GPU detection now retrieves and displays detailed information about each GPU, including its name, VRAM, and the environment variable used to control its visibility.

Bug Fixes:

  • The AMD GPU detection logic was not returning any value, which has been fixed.

Enhancements:

  • The NVIDIA GPU detection logic now returns a list of dictionaries, each containing detailed information about a detected NVIDIA GPU.

Copy link
Contributor

sourcery-ai bot commented Feb 18, 2025

Reviewer's Guide by Sourcery

This pull request enhances GPU detection by adding support for NVIDIA GPUs and modifying the AMD GPU detection logic. The NVIDIA GPU detection uses nvidia-smi to retrieve GPU information, while the AMD GPU detection now returns the result of _read_gpu_memory.

Sequence diagram for NVIDIA GPU detection

sequenceDiagram
  participant P as Python Script
  participant NS as nvidia-smi
  P->>NS: Execute nvidia-smi to query GPU index and memory
  NS-->>P: Returns index and memory information
  P->>NS: Execute nvidia-smi -L to query GPU names
  NS-->>P: Returns GPU names
  P->>P: Parse output
  P->>P: Update best GPU
Loading

Updated class diagram for GPU detection

classDiagram
  class GPUDetector {
    +get_nvidia_gpu()
    +get_amd_gpu()
    -_read_gpu_memory(path_pattern, gpu_name, env_var)
    -_update_best_gpu(memory_mib, gpu_name, env_var)
  }
  note for GPUDetector "Modified get_nvidia_gpu to retrieve GPU names and return a list of GPU info dictionaries."
  note for GPUDetector "Modified get_amd_gpu to return the result of _read_gpu_memory."
Loading

File-Level Changes

Change Details Files
Added NVIDIA GPU detection and information retrieval.
  • Added logic to execute nvidia-smi commands to retrieve GPU index, memory, and name.
  • Added logic to parse the output of nvidia-smi to extract GPU information.
  • Added logic to store the extracted GPU information into a dictionary.
  • Added logic to return a list of dictionaries containing the GPU information.
ramalama/gpu_detector.py
Modified AMD GPU detection to return the result of _read_gpu_memory.
  • Modified get_amd_gpu to return the result of _read_gpu_memory.
ramalama/gpu_detector.py

Possibly linked issues


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

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 @rhatdan - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider returning a consistent data structure from get_nvidia_gpu even when no GPUs are found.
  • It looks like get_amd_gpu is only partially implemented - is it ready to be merged?
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.

@rhatdan rhatdan force-pushed the nvidia branch 2 times, most recently from 529a751 to 800aba7 Compare February 18, 2025 13:12
Copy link
Collaborator

@maxamillion maxamillion left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@rhatdan rhatdan merged commit 99cfd65 into containers:main Feb 18, 2025
16 checks passed
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.

AMD gpu detected as Intel
2 participants