Split any YouTube song into stems
TypeScript
gpu: ROCm 6.4 AMD engine for RDNA4 (RX 9070 XT), engine upgrade path, sharper probe errors (#19)
Daniel Ravina9cb5ae93d044
diff --git a/python/roformer.py b/python/roformer.pyindex beef3cf..b7270ea 100644--- a/python/roformer.py+++ b/python/roformer.py@@ -60,7 +60,8 @@ def crash_message(e):"""top-level crash handler text: unreadable stderr tails (a bare pythontraceback or an unrelated warnings.warn line) become actionable errors"""msg = f"{e}"- if "no kernel image" in msg.lower():+ low = msg.lower()+ if "no kernel image" in low or "invalid device function" in low:return ("GPU engine incompatible with this GPU (compute capability not supported by the ""installed engine) — update StemKit or turn off GPU acceleration in Settings"diff --git a/python/separate.py b/python/separate.pyindex d924680..75b44c4 100644--- a/python/separate.py+++ b/python/separate.py@@ -21,7 +21,8 @@ def crash_message(e):"""top-level crash handler text: unreadable stderr tails (a bare pythontraceback or an unrelated warnings.warn line) become actionable errors"""msg = f"{e}"- if "no kernel image" in msg.lower():+ low = msg.lower()+ if "no kernel image" in low or "invalid device function" in low:return ("GPU engine incompatible with this GPU (compute capability not supported by the ""installed engine) — update StemKit or turn off GPU acceleration in Settings"diff --git a/src/main/env.ts b/src/main/env.tsindex a9df492..a2a9208 100644--- a/src/main/env.ts+++ b/src/main/env.ts@@ -267,6 +267,18 @@ function cudaVersionAtLeast(v: string, maj: number, min: number): boolean {return parseInt(m[1], 10) * 100 + parseInt(m[2], 10) >= maj * 100 + min}+/* the torch build's HIP runtime version (rocm wheels only), e.g. "6.2.41133";+ empty on cpu/cuda builds or when the venv has no torch */+async function torchHipVersion(): Promise<string> {+ return (+ await runCapture(+ venvPython(),+ ['-c', 'import torch;print(torch.version.hip or "")'],+ 30000+ ).catch(() => '')+ ).trim()+}+/* venvs created before the roformer engine lack a few small packages;verify and install them once per session */export async function ensureEngineDeps(): Promise<boolean> {@@ -781,19 +793,23 @@ export function ensureFtWeights(onProgress?: (pct: number) => void): Promise<boolinux pinned to the cpu index, since the default linux wheel wouldotherwise pull CUDA deps for everyone); these swap in on demand when theGPU-acceleration toggle is enabled — cu121 for NVIDIA (~2.5GB download),- rocm6.2 for AMD on linux. They stay installed when the toggle goes back- off — GPU torch handles cpu devices fine */+ rocm6.4 for AMD on linux (~3GB). They stay installed when the toggle goes+ back off — GPU torch handles cpu devices fine */const GPU_TORCH_VERSION = '2.5.1'const GPU_TORCH_INDEX: Record<GpuVendor, string> = {nvidia: 'https://download.pytorch.org/whl/cu121',- amd: 'https://download.pytorch.org/whl/rocm6.2'+ amd: 'https://download.pytorch.org/whl/rocm6.4'}--/* official rocm wheels ship kernel images for gfx90x/942, gfx1030 and- gfx1100 only; consumer RDNA parts (RX 6600 = gfx1032, 7600 = gfx1102,- 680M iGPU = gfx1035, …) need HSA_OVERRIDE_GFX_VERSION to run the nearest- code object. The compute preflight below validates the result — if the- override does not save the card, the CPU path stays in charge */+const AMD_TORCH_VERSION = '2.8.0'++/* official rocm wheels ship kernel images for a subset of targets; consumer+ RDNA2/3 parts (RX 6600 = gfx1032, 7600 = gfx1102, 680M iGPU = gfx1035, …)+ need HSA_OVERRIDE_GFX_VERSION to run the nearest code object. RDNA4+ (gfx1200/1201) is officially supported since rocm 6.4 — the reason the AMD+ engine pins 2.8.0+rocm6.4: on 6.2 wheels an RX 9070 XT dies at first+ launch with "invalid device function" and no override can rescue it. The+ compute preflight below validates the result — if the wheels still can't+ serve the card, the CPU path stays in charge */function gfxOverride(gfx: string): string | null {const id = parseInt((gfx.match(/gfx(\d+)/) ?? [])[1] ?? '', 10)if (Number.isNaN(id)) return null@@ -864,7 +880,10 @@ export function ensureGpuEngine(// wheel selection: Blackwell-class NVIDIA cards (compute cap 10+)// need the cu128 build; anything already installed from cu121 must be// upgraded to it. Without this, the early-return below would leave the- // older engine in place and separation would die mid-split+ // older engine in place and separation would die mid-split. Same story+ // for AMD: the 2.8.0+rocm6.4 engine is required for RDNA4 (RX 9070 XT+ // = gfx1201 has no kernels — and no override — on 6.2 wheels), so+ // machines holding an older rocm engine must be upgraded toolet torchVersion = GPU_TORCH_VERSIONlet torchIndex = GPU_TORCH_INDEX[vendor]let sizeLabel = '~2.5GB'@@ -875,8 +894,12 @@ export function ensureGpuEngine(torchVersion = BLACKWELL_TORCH_VERSIONtorchIndex = BLACKWELL_TORCH_INDEXsizeLabel = '~3GB'- needUpgrade = !(await cudaVersionAtLeast(await torchCudaVersion(), 12, 8))+ needUpgrade = !cudaVersionAtLeast(await torchCudaVersion(), 12, 8)}+ } else {+ torchVersion = AMD_TORCH_VERSION+ sizeLabel = '~3GB'+ needUpgrade = !cudaVersionAtLeast(await torchHipVersion(), 6, 4)}// already swapped in: the venv's torch speaks to a GPU, nothing to installif (!needUpgrade && (await hasGpuAcceleration())) return true@@ -988,10 +1011,15 @@ export function ensureGpuEngine()if (!ok.trim().includes('ok')) throw new Error('compute probe returned no result')} catch (err) {+ const raw = err instanceof Error ? err.message : String(err)+ // "invalid device function" = no kernel image for this gfx target —+ // not a driver/permission problem, so the generic advice would+ // mislead; point at the engine instead+ const advice = /invalid device function|no kernel image/i.test(raw)+ ? 'This GPU architecture has no kernels in the installed ROCm engine — update StemKit.'+ : 'Check the amdgpu driver and that your user can access /dev/kfd and /dev/dri.'throw new Error(- `AMD GPU probe failed${override ? ` (using ${override})` : ''}: ${- err instanceof Error ? err.message : String(err)- }. Check the amdgpu driver and that your user can access /dev/kfd and /dev/dri`+ `AMD GPU probe failed${override ? ` (using ${override})` : ''}: ${raw.slice(-300)}. ${advice}`)}}diff --git a/src/renderer/src/components/Settings.tsx b/src/renderer/src/components/Settings.tsxindex f8bfa09..853a74b 100644--- a/src/renderer/src/components/Settings.tsx+++ b/src/renderer/src/components/Settings.tsx@@ -271,10 +271,7 @@ export function Settings({ settings, gpu, gpuVendor, onChange, onClose }: Props)</p><DownloadBar pct={gpuPct} starting={gpuBusy && gpuPct === null} error={gpuError} />{showGpuConfirm && (- <ConfirmButton- label={gpuVendor === 'amd' ? 'Download now · ~2.5 GB' : 'Download now · ~3 GB'}- onClick={startGpu}- />+ <ConfirmButton label="Download now · ~3 GB" onClick={startGpu} />)}</div><Toggle