Repository navigation
fix(ck-tile): Prefer using amd-smi over rocm-smi #9731
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c6442c8
Add a bash test
geyyer 3ca4f6c
Add a python test
geyyer fa5c47a
Add wrappers
geyyer 48304e6
Update usage
geyyer 3779aed
Minor fix
geyyer 318ab48
Clean up
geyyer 78722a1
Minor fix
geyyer 09e8fd8
Merge branch 'develop' into users/rogeyyer/ck/aick-1649
geyyer 60fd346
Minor fix
geyyer ef21df1
Potential fix for pull request finding
geyyer b8df3ae
Potential fix for pull request finding
geyyer de1b355
Fix the fallback scenario
geyyer 999dd38
Fix scripts
geyyer 00917eb
Merge branch 'develop' into users/rogeyyer/ck/aick-1649
geyyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
projects/composablekernel/script/tools/test_ck_smi_helpers.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| #!/bin/bash | ||
| # Copyright (c) Advanced Micro Devices, Inc., or its affiliates. | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # Live test (pure bash): rocm-smi vs amd-smi normalized output must agree. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| failures=0 | ||
|
|
||
| require_tools() { | ||
| local missing=0 | ||
| for tool in rocm-smi amd-smi; do | ||
| if ! command -v "${tool}" &>/dev/null; then | ||
| echo "ERROR: ${tool} not found on PATH" | ||
| missing=1 | ||
| fi | ||
| done | ||
| if [ "${missing}" -ne 0 ]; then | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| run_smi() { | ||
| local tool=$1 | ||
| shift | ||
| "${tool}" "$@" 2>/dev/null | ||
| } | ||
|
|
||
| # Parse GPU ids from rocm-smi --showid (GPU[0], GPU[1], ...) | ||
| parse_rocm_gpu_ids() { | ||
| run_smi rocm-smi --showid \ | ||
| | grep -oE 'GPU\[[0-9]+\]' \ | ||
| | sed 's/GPU\[//;s/\]//' \ | ||
| | sort -nu \ | ||
| | paste -sd, - | ||
| } | ||
|
|
||
| # Parse GPU ids from amd-smi list (GPU: 0, GPU: 1, ...) | ||
| parse_amd_gpu_ids() { | ||
| run_smi amd-smi list \ | ||
| | grep '^GPU:' \ | ||
| | sed 's/^GPU:[[:space:]]*//' \ | ||
| | sort -nu \ | ||
| | paste -sd, - | ||
| } | ||
|
|
||
| parse_rocm_product() { | ||
| run_smi rocm-smi --showproductname \ | ||
| | sed -n 's/.*Card Series:[[:space:]]*\(.*\)/\1/p' \ | ||
| | head -1 | ||
| } | ||
|
|
||
| parse_amd_product() { | ||
| run_smi amd-smi static \ | ||
| | sed -n 's/.*MARKET_NAME:[[:space:]]*\(.*\)/\1/p' \ | ||
| | head -1 | ||
| } | ||
|
|
||
| parse_rocm_gfx() { | ||
| run_smi rocm-smi --showproductname \ | ||
| | sed -n 's/.*GFX Version:[[:space:]]*\([^[:space:]]*\).*/\1/p' \ | ||
| | head -1 | ||
| } | ||
|
|
||
| parse_amd_gfx() { | ||
| run_smi amd-smi static \ | ||
| | sed -n 's/.*TARGET_GRAPHICS_VERSION:[[:space:]]*\([^[:space:]]*\).*/\1/p' \ | ||
| | head -1 | ||
| } | ||
|
|
||
| parse_rocm_driver() { | ||
| run_smi rocm-smi --showdriverversion \ | ||
| | sed -n 's/.*Driver version:[[:space:]]*\([^[:space:]]*\).*/\1/p' \ | ||
| | head -1 | ||
| } | ||
|
|
||
| parse_amd_driver() { | ||
| local ver | ||
| ver=$(run_smi amd-smi version \ | ||
| | sed -n 's/.*amdgpu version:[[:space:]]*\([^[:space:]|]*\).*/\1/p' \ | ||
| | head -1) | ||
| if [ -n "${ver}" ]; then | ||
| echo "${ver}" | ||
| return | ||
| fi | ||
| run_smi amd-smi static -d \ | ||
| | sed -n 's/.*VERSION:[[:space:]]*\([^[:space:]]*\).*/\1/p' \ | ||
| | head -1 | ||
| } | ||
|
|
||
| compare_field() { | ||
| local name=$1 | ||
| local rocm_val=$2 | ||
| local amd_val=$3 | ||
| if [ "${rocm_val}" = "${amd_val}" ]; then | ||
| printf ' %-8s rocm-smi=%s amd-smi=%s OK\n' "${name}" "${rocm_val}" "${amd_val}" | ||
| else | ||
| printf ' %-8s rocm-smi=%s amd-smi=%s FAIL\n' "${name}" "${rocm_val}" "${amd_val}" | ||
| failures=$((failures + 1)) | ||
| fi | ||
| } | ||
|
|
||
| require_tools | ||
|
|
||
| echo "rocm-smi vs amd-smi (live comparison, pure bash):" | ||
| echo "---------------------------------------------------" | ||
|
|
||
| compare_field "gpu_ids" "$(parse_rocm_gpu_ids)" "$(parse_amd_gpu_ids)" | ||
| compare_field "product" "$(parse_rocm_product)" "$(parse_amd_product)" | ||
| compare_field "gfx" "$(parse_rocm_gfx)" "$(parse_amd_gfx)" | ||
| compare_field "driver" "$(parse_rocm_driver)" "$(parse_amd_driver)" | ||
|
|
||
| echo "" | ||
| if [ "${failures}" -ne 0 ]; then | ||
| echo "${failures} field(s) mismatched." | ||
| exit 1 | ||
| fi | ||
| echo "All fields match." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
projects/composablekernel/tile_engine/ops/common/smi_cli.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #!/usr/bin/env python3 | ||
| # Copyright (c) Advanced Micro Devices, Inc., or its affiliates. | ||
| # SPDX-License-Identifier: MIT | ||
| """CLI entry point for shell ck_smi_* delegates.""" | ||
|
|
||
| import argparse | ||
| import sys | ||
|
|
||
| from smi_utils import ( | ||
| check_gpu_available, | ||
| count_gpus, | ||
| detect_gpu_ids, | ||
| show_gpu_info, | ||
| show_version, | ||
| ) | ||
|
|
||
|
|
||
| def main() -> int: | ||
| parser = argparse.ArgumentParser(description="CK GPU SMI wrapper CLI") | ||
| sub = parser.add_subparsers(dest="command", required=True) | ||
|
|
||
| sub.add_parser("list-ids", help="Print GPU ids one per line") | ||
|
|
||
| sub.add_parser("count", help="Print GPU count") | ||
|
|
||
| show_info = sub.add_parser("show-info", help="Print GPU product/static info") | ||
| show_info.add_argument( | ||
| "--head", | ||
| type=int, | ||
| default=10, | ||
| help="Max lines to print (0 for full output)", | ||
| ) | ||
|
|
||
| sub.add_parser("check", help="Exit 0 if GPU is accessible via SMI") | ||
|
|
||
| sub.add_parser("show-version", help="Print driver version info") | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| if args.command == "list-ids": | ||
| for gpu_id in detect_gpu_ids(): | ||
| print(gpu_id) | ||
| return 0 | ||
|
|
||
| if args.command == "count": | ||
| print(count_gpus()) | ||
| return 0 | ||
|
|
||
| if args.command == "show-info": | ||
| head = None if args.head == 0 else args.head | ||
| print(show_gpu_info(head=head)) | ||
| return 0 | ||
|
|
||
| if args.command == "check": | ||
| return 0 if check_gpu_available() else 1 | ||
|
|
||
| if args.command == "show-version": | ||
| print(show_version()) | ||
| return 0 | ||
|
|
||
| parser.error(f"unknown command: {args.command}") | ||
| return 2 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.