Metadata-Version: 2.4
Name: stxh-setup-amd
Version: 1.0.0
Summary: Automated setup for AMD Strix Halo APU: ROCm, MIGraphX, custom ORT, and AI model deployment.
Author-email: Sudheer Ibrahim Daniel Devu <sudheerdevu4work@gmail.com>
License: Apache-2.0
Project-URL: Homepage, https://github.com/SID-Devu/stxh-setup-amd
Project-URL: Repository, https://github.com/SID-Devu/stxh-setup-amd
Project-URL: Issues, https://github.com/SID-Devu/stxh-setup-amd/issues
Keywords: amd,strix-halo,apu,rocm,migraphx,onnxruntime,setup,gpu,rdna3,gfx1151
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Installation/Setup
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# stxh-setup-amd

[![PyPI version](https://img.shields.io/pypi/v/stxh-setup-amd.svg)](https://pypi.org/project/stxh-setup-amd/)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-green.svg)](LICENSE)

Automated setup for **AMD Strix Halo APU** (gfx1151 / RDNA 3.5).

Takes a fresh Ubuntu 24.04 machine from zero to running 23 AI models on
ORT MIGraphX Execution Provider -- ROCm 7.2, MIGraphX, 400 GB swap,
GRUB tuning, Python ML stack, and a custom ONNX Runtime build with
unified-memory fixes.

## Install

```bash
pip install stxh-setup-amd
```

## Usage

```bash
# Full setup (all 8 stages)
export SMB_USER="user@amd.com"
export SMB_PASS="password"
sudo -E stxh-setup --all

# Resume from a specific stage
sudo stxh-setup --from-stage 5

# Run a single stage
sudo stxh-setup --stage 3          # ROCm only

# Skip slow steps
sudo stxh-setup --all --skip-copy --skip-ort-build

# Check what's already done
sudo stxh-setup --status

# Verify everything works
sudo stxh-setup --verify
```

Fallback if `stxh-setup` is not on PATH:

```bash
sudo python3 -m stxh_setup --all
```

## The 8 Stages

| Stage | What it does | Time |
|-------|-------------|------|
| 1 | System update + base packages (build-essential, cmake, ffmpeg, ...) | 5 min |
| 2 | Copy R1models from network share (~206 GB) | 30-90 min |
| 3 | GPU driver + ROCm 7.2 (requires reboot) | 10 min |
| 4 | MIGraphX | 2 min |
| 5 | Swap space (~400 GB for JIT compilation) | 5 min |
| 6 | GRUB kernel parameters (amdgpu.gttsize=28672, requires reboot) | 1 min |
| 7 | Python dependencies (PyTorch+ROCm, JAX+ROCm, TF, HuggingFace, ...) | 15 min |
| 8 | Custom ORT 1.25.0 build with MIGraphX fixes (or installs existing wheel) | 60-90 min |

Each stage is **idempotent** -- if it detects the work is already done, it skips.

## Custom ORT Fixes

The stock `onnxruntime-migraphx` from PyPI OOMs on any model > 512 MB because
the Strix Halo APU only has 512 MB dedicated VRAM. Stage 8 applies two source
patches before building:

| Fix | What |
|-----|------|
| **B** | `hipMalloc` -> `hipMallocManaged` -- spill to 28 GB GTT when VRAM is full |
| **C** | `[=]` -> `[=, this]` -- C++20 lambda capture build fix |

Fix A (skip constant initializer double-allocation) is already upstream in ORT 1.25.0.

## Hardware Target

- **APU**: AMD Strix Halo (gfx1151 / RDNA 3.5)
- **VRAM**: 512 MB dedicated + 28 GB GTT (unified memory)
- **OS**: Ubuntu 24.04 (Noble), kernel 6.18.0+
- **ROCm**: 7.2
- **Key setting**: `HSA_XNACK=1` (demand paging for unified memory)

## License

Apache 2.0

Copyright 2026 Sudheer Ibrahim Daniel Devu
