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

code crashes for rocm added proper type cast for env var #602

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

bmahabirbu
Copy link
Collaborator

@bmahabirbu bmahabirbu commented Jan 20, 2025

Hey @ericcurtin while checking into rocm detection I realized this can break the code so here is a quick fix!

Summary by Sourcery

Bug Fixes:

  • Fix crash when setting HIP_VISIBLE_DEVICES environment variable.

Copy link
Contributor

sourcery-ai bot commented Jan 20, 2025

Reviewer's Guide by Sourcery

The pull request addresses a potential code crash by ensuring that the environment variable 'HIP_VISIBLE_DEVICES' is set to a string value. This is achieved by explicitly casting the 'gpu_num' variable to a string before assigning it to the environment variable.

Sequence diagram for ROCm GPU device selection

sequenceDiagram
    participant Code as Application Code
    participant GPU as get_gpu() Function
    participant Env as Environment Variables

Code->>GPU: Call get_gpu()
GPU->>GPU: Process GPU bytes
Note over GPU: Convert gpu_num to string
GPU->>Env: Set HIP_VISIBLE_DEVICES=str(gpu_num)
GPU-->>Code: Return
Loading

Flow diagram for GPU device selection with type casting

flowchart TD
    A[Start] --> B{GPU bytes available?}
    B -->|Yes| C[Convert gpu_num to string]
    C --> D[Set HIP_VISIBLE_DEVICES environment variable]
    D --> E[Return]
    B -->|No| E
    E[Return]
Loading

File-Level Changes

Change Details Files
Ensured that the environment variable 'HIP_VISIBLE_DEVICES' is set to a string value.
  • Casted the 'gpu_num' variable to a string before assigning it to the 'HIP_VISIBLE_DEVICES' environment variable.
ramalama/common.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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

Overall Comments:

  • While the fix is correct, please consider using a more descriptive commit message that explains the specific issue (type mismatch when setting HIP_VISIBLE_DEVICES environment variable) and why the fix was needed.
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.

Copy link
Collaborator

@ericcurtin ericcurtin left a comment

Choose a reason for hiding this comment

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

Sometimes when writing python I really miss having a compiler, it would catch issues like this!

@ericcurtin
Copy link
Collaborator

@maxamillion and @bmahabirbu ye both have maintainer permissions, feel free to merge green PRs that don't have issues etc. I'm gonna sleep.

@bmahabirbu
Copy link
Collaborator Author

Agreed! My fault initally, I should have tested this on my amd machine. Was too caught up with cuda

@bmahabirbu
Copy link
Collaborator Author

@maxamillion and @bmahabirbu ye both have maintainer permissions, feel free to merge green PRs that don't have issues etc. I'm gonna sleep.

Awesome!

@ericcurtin
Copy link
Collaborator

ericcurtin commented Jan 20, 2025

If we can find static analysis tools that are capable of detecting things like this it would be great if we added, many humans would miss this in review. Or some extra tests that execute these code bits. Or a unit test would be perfect.

I actually noticed quay.io rocm pull stats dipped a little, makes sense now.

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!

@ericcurtin ericcurtin merged commit e08af09 into main Jan 21, 2025
11 checks passed
@bmahabirbu bmahabirbu deleted the rocm-hotfix branch January 21, 2025 15:37
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.

3 participants