From 39ae2e8b3dff5697c7be6646ca9f2994ac42f839 Mon Sep 17 00:00:00 2001 From: LeoBorcherding Date: Sat, 16 May 2026 16:57:01 -0500 Subject: [PATCH] fix(win32): distinguish HIP SDK installed vs GPU not ROCm-accessible Previously, when hipinfo was found but exited non-zero (e.g. "no ROCm-capable device detected"), both install.ps1 and setup.ps1 fell through to the WMI-label-only branch and printed "AMD GPU detected -- HIP SDK not found" -- factually wrong since the SDK binary is present. Add $HipSdkInstalled flag (set true when hipinfo binary is found, regardless of exit code). When HipSdkInstalled && !HasROCm: - Show "AMD GPU detected -- not ROCm-accessible (HIP )" instead - Explain this is a driver issue, not an SDK issue, with a link - Still run hipconfig version capture so version shows in output - CPU-only hint now says "GPU not ROCm-accessible" not "require HIP SDK" Also applies to setup.ps1 (same detection block, same branches). Adds TestHipSdkInstalledButDeviceInaccessible (11 tests). --- install.ps1 | 21 ++++++- studio/setup.ps1 | 18 +++++- tests/studio/install/test_rocm_support.py | 72 +++++++++++++++++++++++ 3 files changed, 106 insertions(+), 5 deletions(-) diff --git a/install.ps1 b/install.ps1 index 28a78d47a2..cc2cdbcee1 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1209,6 +1209,7 @@ shell.Run cmd, 0, False } # ── AMD ROCm detection (Windows) — mirrors setup.ps1 ── $HasROCm = $false + $HipSdkInstalled = $false # HIP SDK binary found (independent of device accessibility) $ROCmGpuLabel = $null $ROCmVersion = $null $ROCmGfxArch = $null @@ -1234,6 +1235,7 @@ shell.Run cmd, 0, False } } if ($hipinfoExe) { + $HipSdkInstalled = $true # binary found → SDK is installed regardless of device state try { $hipOut = & $hipinfoExe.Source 2>&1 | Out-String if ($LASTEXITCODE -eq 0 -and $hipOut -match "(?i)gcnArchName") { @@ -1322,8 +1324,10 @@ shell.Run cmd, 0, False } } } - # Capture ROCm version for wheel selection (hipconfig, then amd-smi) - if ($HasROCm) { + # Capture ROCm version for wheel selection (hipconfig, then amd-smi). + # Run whenever the HIP SDK binary is present, not just when the device is accessible -- + # hipconfig --version works even when hipinfo reports no ROCm device (driver issue). + if ($HasROCm -or $HipSdkInstalled) { $hipConfigExe = Get-Command hipconfig -ErrorAction SilentlyContinue if (-not $hipConfigExe) { $hipRoot = if ($env:HIP_PATH) { $env:HIP_PATH } elseif ($env:ROCM_PATH) { $env:ROCM_PATH } else { $null } @@ -1369,6 +1373,15 @@ shell.Run cmd, 0, False $hipSdkPath = if ($env:HIP_PATH) { $env:HIP_PATH } elseif ($env:ROCM_PATH) { $env:ROCM_PATH } else { "on system PATH" } substep "HIP SDK: $hipSdkPath" if ($ROCmVersionFull) { substep "hipconfig: $ROCmVersionFull" } + } elseif ($HipSdkInstalled -and $ROCmGpuLabel) { + # HIP SDK is installed but ROCm can't see the device (driver issue, not SDK issue) + $sdkVer = if ($ROCmVersionFull) { " (HIP $ROCmVersionFull)" } else { "" } + step "gpu" "AMD GPU detected -- not ROCm-accessible$sdkVer" "Yellow" + substep "Detected: $ROCmGpuLabel" "Yellow" + substep "[WARN] HIP SDK is installed but hipinfo reports no ROCm-capable device." "Yellow" + substep " This is a driver issue, not an SDK issue." "Yellow" + substep " Ensure the ROCm compute driver is installed alongside the display driver:" "Yellow" + substep " https://rocm.docs.amd.com/en/latest/deploy/windows/index.html" "Yellow" } elseif ($ROCmGpuLabel) { step "gpu" "AMD GPU detected -- HIP SDK not found" "Yellow" substep "Detected: $ROCmGpuLabel" "Yellow" @@ -1441,7 +1454,9 @@ shell.Run cmd, 0, False # ── Print CPU-only hint when no GPU detected ── if (-not $SkipTorch -and -not $ROCmIndexUrl -and $TorchIndexUrl -like "*/cpu") { Write-Host "" - if ($HasROCm -or $ROCmGpuLabel) { + if ($HipSdkInstalled -and -not $HasROCm) { + substep "Installing CPU-only PyTorch (HIP SDK found but GPU not ROCm-accessible)." "Yellow" + } elseif ($ROCmGpuLabel) { substep "Installing CPU-only PyTorch (ROCm wheels require the HIP SDK)." "Yellow" } else { substep "No NVIDIA GPU detected." "Yellow" diff --git a/studio/setup.ps1 b/studio/setup.ps1 index 68bd6397aa..2772c94b11 100644 --- a/studio/setup.ps1 +++ b/studio/setup.ps1 @@ -684,6 +684,7 @@ if (-not $HasNvidiaSmi) { } # ── AMD ROCm detection (Windows): probe hipinfo/amd-smi for actual GPU ── $HasROCm = $false +$HipSdkInstalled = $false # HIP SDK binary found (independent of device accessibility) $ROCmGpuLabel = $null $script:ROCmGfxArch = $null if (-not $HasNvidiaSmi) { @@ -708,6 +709,7 @@ if (-not $HasNvidiaSmi) { } } if ($hipinfoExe) { + $HipSdkInstalled = $true # binary found → SDK is installed regardless of device state try { $hipOut = & $hipinfoExe.Source 2>&1 | Out-String if ($LASTEXITCODE -eq 0 -and $hipOut -match "(?i)gcnArchName") { @@ -807,8 +809,10 @@ if (-not $HasNvidiaSmi) { } } } - # Capture ROCm version early for display and wheel selection - if ($HasROCm) { + # Capture ROCm version early for display and wheel selection. + # Run whenever the HIP SDK binary is present, not just when the device is accessible -- + # hipconfig --version works even when hipinfo reports no ROCm device (driver issue). + if ($HasROCm -or $HipSdkInstalled) { $script:ROCmVersion = $null $hipConfigExe = Get-Command hipconfig -ErrorAction SilentlyContinue if (-not $hipConfigExe) { @@ -853,6 +857,16 @@ if ($HasNvidiaSmi) { $hipSdkPath = if ($env:HIP_PATH) { $env:HIP_PATH } elseif ($env:ROCM_PATH) { $env:ROCM_PATH } else { "on system PATH" } substep "HIP SDK: $hipSdkPath" if ($script:ROCmVersionFull) { substep "hipconfig: $script:ROCmVersionFull" } +} elseif ($HipSdkInstalled -and $ROCmGpuLabel) { + # HIP SDK is installed but ROCm can't see the device (driver issue, not SDK issue) + $sdkVer = if ($script:ROCmVersionFull) { " (HIP $script:ROCmVersionFull)" } else { "" } + Write-Host "" + step "gpu" "AMD GPU detected -- not ROCm-accessible$sdkVer" "Yellow" + substep "Detected: $ROCmGpuLabel" "Yellow" + substep "[WARN] HIP SDK is installed but hipinfo reports no ROCm-capable device." "Yellow" + substep " This is a driver issue, not an SDK issue." "Yellow" + substep " Ensure the ROCm compute driver is installed alongside the display driver:" "Yellow" + substep " https://rocm.docs.amd.com/en/latest/deploy/windows/index.html" "Yellow" } elseif ($ROCmGpuLabel) { Write-Host "" step "gpu" "AMD GPU detected -- HIP SDK not found" "Yellow" diff --git a/tests/studio/install/test_rocm_support.py b/tests/studio/install/test_rocm_support.py index d602602c6c..9f746e6096 100644 --- a/tests/studio/install/test_rocm_support.py +++ b/tests/studio/install/test_rocm_support.py @@ -2440,5 +2440,77 @@ class TestServerStartupRocmFixes: assert "_distributed_rpc" in source +# ============================================================================= +# TEST: install.ps1 / setup.ps1 -- HipSdkInstalled flag (SDK found, device inaccessible) +# ============================================================================= + + +class TestHipSdkInstalledButDeviceInaccessible: + """Verify that when hipinfo is found but exits non-zero (device not ROCm-accessible), + both scripts distinguish this from 'HIP SDK not found' and emit the correct message.""" + + def test_install_ps1_has_hip_sdk_installed_flag(self): + """install.ps1 must track HipSdkInstalled separately from HasROCm.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + assert "HipSdkInstalled" in source + + def test_setup_ps1_has_hip_sdk_installed_flag(self): + """setup.ps1 must track HipSdkInstalled separately from HasROCm.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + assert "HipSdkInstalled" in source + + def test_install_ps1_sets_flag_when_hipinfo_binary_found(self): + """install.ps1 must set HipSdkInstalled=true inside the 'if ($hipinfoExe)' block.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + # HipSdkInstalled must be assigned inside the hipinfoExe block + hipinfo_block_idx = source.find("if ($hipinfoExe)") + sdk_flag_idx = source.find("$HipSdkInstalled = $true", hipinfo_block_idx) + assert hipinfo_block_idx != -1 and sdk_flag_idx != -1 + assert sdk_flag_idx > hipinfo_block_idx + + def test_setup_ps1_sets_flag_when_hipinfo_binary_found(self): + """setup.ps1 must set HipSdkInstalled=true inside the 'if ($hipinfoExe)' block.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + hipinfo_block_idx = source.find("if ($hipinfoExe)") + sdk_flag_idx = source.find("$HipSdkInstalled = $true", hipinfo_block_idx) + assert hipinfo_block_idx != -1 and sdk_flag_idx != -1 + assert sdk_flag_idx > hipinfo_block_idx + + def test_install_ps1_version_capture_runs_when_sdk_installed(self): + """install.ps1 must capture hipconfig version when HipSdkInstalled even if HasROCm is false.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + assert "HasROCm -or $HipSdkInstalled" in source or "$HipSdkInstalled" in source + + def test_setup_ps1_version_capture_runs_when_sdk_installed(self): + """setup.ps1 must capture hipconfig version when HipSdkInstalled even if HasROCm is false.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + assert "HasROCm -or $HipSdkInstalled" in source or "$HipSdkInstalled" in source + + def test_install_ps1_distinct_message_for_sdk_found_but_device_inaccessible(self): + """install.ps1 must show 'not ROCm-accessible' message (not 'HIP SDK not found') when SDK present.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + assert "not ROCm-accessible" in source + + def test_setup_ps1_distinct_message_for_sdk_found_but_device_inaccessible(self): + """setup.ps1 must show 'not ROCm-accessible' message (not 'HIP SDK not found') when SDK present.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + assert "not ROCm-accessible" in source + + def test_install_ps1_driver_guidance_in_sdk_found_branch(self): + """install.ps1 must tell user this is a driver issue, not an SDK issue.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + assert "driver issue" in source + + def test_setup_ps1_driver_guidance_in_sdk_found_branch(self): + """setup.ps1 must tell user this is a driver issue, not an SDK issue.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + assert "driver issue" in source + + def test_install_ps1_cpu_hint_distinguishes_driver_vs_no_sdk(self): + """install.ps1 CPU-only hint must say 'GPU not ROCm-accessible' not 'require the HIP SDK' when SDK found.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + assert "GPU not ROCm-accessible" in source + + if __name__ == "__main__": pytest.main([__file__, "-v"])