-
Notifications
You must be signed in to change notification settings - Fork 5
[AIMIGRAPHX-1202] Add MIGraphX EP standalone build script #59
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
Open
TedThemistokleous
wants to merge
2
commits into
main
Choose a base branch
from
migx_ep_build_recipie
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| ulimit -c unlimited | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Configuration (override via env vars or CLI flags below) | ||
| # --------------------------------------------------------------------------- | ||
| # $HOME can be unset/empty in some docker/root shells. Bash's "~" expansion | ||
| # only falls back to the passwd entry when HOME is truly unset (not just | ||
| # empty), so unset it first before re-expanding. | ||
| if [ -z "$HOME" ]; then | ||
| unset HOME | ||
| HOME=~ | ||
| fi | ||
|
|
||
| ROCM_PATH="${ROCM_PATH:-/opt/rocm}" | ||
| AMDMIGRAPHX_SRC="${AMDMIGRAPHX_SRC:-/workspace/AMDMIGraphX}" | ||
| ONNXRUNTIME_SRC="${ONNXRUNTIME_SRC:-/onnxruntime}" | ||
| ONNXRUNTIME_EP_SRC="${ONNXRUNTIME_EP_SRC:-/workspace/onnxruntime-ep-amdgpu}" | ||
|
|
||
| AMDMIGRAPHX_INSTALL="${AMDMIGRAPHX_INSTALL:-$HOME/develop/AMDMIGraphX_install}" | ||
| ONNXRUNTIME_INSTALL="${ONNXRUNTIME_INSTALL:-$HOME/develop/onnxruntime_install}" | ||
|
|
||
| usage() { | ||
| cat <<EOF | ||
| Usage: $0 [options] | ||
|
|
||
| Options: | ||
| --rocm-path PATH Path to the ROCm install (default: $ROCM_PATH) | ||
| --migraphx-install PATH AMDMIGraphX install prefix (default: $AMDMIGRAPHX_INSTALL) | ||
| --onnxrt-install PATH ONNX Runtime install prefix (default: $ONNXRUNTIME_INSTALL) | ||
| -h, --help Show this help message | ||
|
|
||
| Environment variables ROCM_PATH, AMDMIGRAPHX_INSTALL, and ONNXRUNTIME_INSTALL | ||
| can also be used to set these values; CLI flags take precedence. | ||
| EOF | ||
| } | ||
|
|
||
| while [ $# -gt 0 ]; do | ||
| case "$1" in | ||
| --rocm-path) | ||
| ROCM_PATH="$2" | ||
| shift 2 | ||
| ;; | ||
| --migraphx-install) | ||
| AMDMIGRAPHX_INSTALL="$2" | ||
| shift 2 | ||
| ;; | ||
| --onnxrt-install) | ||
| ONNXRUNTIME_INSTALL="$2" | ||
| shift 2 | ||
| ;; | ||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo "Unknown option: $1" >&2 | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| echo "ROCM_PATH=$ROCM_PATH" | ||
| echo "AMDMIGRAPHX_INSTALL=$AMDMIGRAPHX_INSTALL" | ||
| echo "ONNXRUNTIME_INSTALL=$ONNXRUNTIME_INSTALL" | ||
|
|
||
| git config --global --add safe.directory "*" | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # 0. System + Python dependencies | ||
| # --------------------------------------------------------------------------- | ||
| apt-get update -y | ||
| apt-get install -y curl zip unzip tar | ||
|
|
||
| pip3 install --upgrade ninja "packaging>=24.2" cmake==4.2.3 | ||
| pip3 install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz | ||
|
|
||
| # Add newer cmake to the path | ||
| export PATH="/opt/cmake/bin:$PATH" | ||
| export CXXFLAGS="-D__HIP_PLATFORM_AMD__=1 -w" | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # 1. Build + install AMDMIGraphX (develop branch) | ||
| # --------------------------------------------------------------------------- | ||
| cd "$AMDMIGRAPHX_SRC" | ||
| git checkout develop | ||
|
|
||
| GPU_TARGETS="$("$ROCM_PATH/bin/rocminfo" | grep -o -m1 'gfx.*')" | ||
|
|
||
| rbuild build -d depend -B build \ | ||
| -DGPU_TARGETS="$GPU_TARGETS" \ | ||
| -DMIGRAPHX_USE_COMPOSABLEKERNEL=OFF | ||
|
|
||
| cd build | ||
| cmake --install . --prefix "$AMDMIGRAPHX_INSTALL" | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # 2. Build + install ROCm/onnxruntime (v1.24.2 tag) | ||
| # --------------------------------------------------------------------------- | ||
| cd "$ONNXRUNTIME_SRC" | ||
| git checkout v1.27.0 | ||
| #vendorID fix seen in OnnxRT core that breaks AMDGPUs needs to be upstreamed | ||
| git cherry-pick 38fc6102a2ac126c3a94a01039635a4d40740e76 | ||
|
|
||
| ./build.sh --config Release \ | ||
| --cmake_generator Ninja \ | ||
| --cmake_extra_defines HIP_PLATFORM="amd" onnxruntime_USE_COMPOSABLE_KERNEL=OFF \ | ||
| --skip_tests \ | ||
| --build_wheel \ | ||
| --build_shared_lib \ | ||
| --parallel \ | ||
| --use_binskim_compliant_compile_flags \ | ||
| --build_csharp \ | ||
| --use_vcpkg \ | ||
| --use_vcpkg_ms_internal_asset_cache \ | ||
| --client_package_build \ | ||
| --allow_running_as_root \ | ||
| --enable_pybind \ | ||
| --cmake_extra_defines CMAKE_IGNORE_PREFIX_PATH=/usr/local | ||
|
|
||
| cd build/Linux/Release | ||
| cmake --install . --prefix "$ONNXRUNTIME_INSTALL" | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # 3. Build onnxruntime-ep-amdgpu (main branch) | ||
| # --------------------------------------------------------------------------128- | ||
| cd "$ONNXRUNTIME_EP_SRC" | ||
| git checkout main | ||
|
|
||
| ./build.sh --config Release \ | ||
| --cmake_generator Ninja \ | ||
| --onnxrt_home "$ONNXRUNTIME_INSTALL" \ | ||
| --use_migraphx \ | ||
| --migraphx_home "$AMDMIGRAPHX_INSTALL" \ | ||
| --compile_no_warning_as_error \ | ||
| --parallel 16 \ | ||
| --build_dir build.EP.MGX \ | ||
| --hip_path "$ROCM_PATH" \ | ||
| --build_wheel | ||
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.