diff --git a/install.ps1 b/install.ps1 index 5df7e16d9c..28a78d47a2 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1339,8 +1339,12 @@ shell.Run cmd, 0, False if ($hipConfigExe) { try { $hipVerOut = & $hipConfigExe.Source --version 2>&1 | Out-String - if ($LASTEXITCODE -eq 0 -and $hipVerOut -match '(\d+\.\d+)') { - $ROCmVersion = $Matches[1] + if ($LASTEXITCODE -eq 0) { + $hipVerLine = ($hipVerOut -split '\r?\n' | Where-Object { $_.Trim() } | Select-Object -First 1).Trim() + if ($hipVerLine -match '(\d+\.\d+)') { + $ROCmVersion = $Matches[1] + $ROCmVersionFull = $hipVerLine + } } } catch {} } @@ -1362,6 +1366,9 @@ shell.Run cmd, 0, False step "gpu" "NVIDIA GPU detected" } elseif ($HasROCm) { step "gpu" $ROCmGpuLabel + $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 ($ROCmGpuLabel) { step "gpu" "AMD GPU detected -- HIP SDK not found" "Yellow" substep "Detected: $ROCmGpuLabel" "Yellow" diff --git a/studio/setup.ps1 b/studio/setup.ps1 index b3e977ee75..68bd6397aa 100644 --- a/studio/setup.ps1 +++ b/studio/setup.ps1 @@ -825,7 +825,13 @@ if (-not $HasNvidiaSmi) { if ($hipConfigExe) { try { $hipVerOut = & $hipConfigExe.Source --version 2>&1 | Out-String - if ($LASTEXITCODE -eq 0 -and $hipVerOut -match '(\d+\.\d+)') { $script:ROCmVersion = $Matches[1] } + if ($LASTEXITCODE -eq 0) { + $hipVerLine = ($hipVerOut -split '\r?\n' | Where-Object { $_.Trim() } | Select-Object -First 1).Trim() + if ($hipVerLine -match '(\d+\.\d+)') { + $script:ROCmVersion = $Matches[1] + $script:ROCmVersionFull = $hipVerLine + } + } } catch {} } if (-not $script:ROCmVersion) { @@ -844,6 +850,9 @@ if ($HasNvidiaSmi) { step "gpu" "NVIDIA GPU detected" } elseif ($HasROCm) { step "gpu" $ROCmGpuLabel + $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 ($ROCmGpuLabel) { Write-Host "" step "gpu" "AMD GPU detected -- HIP SDK not found" "Yellow" @@ -1265,7 +1274,7 @@ if (-not $CudaArch) { } if ($HasROCm) { - $rocmVerLabel = if ($ROCmVersion) { "ROCm $ROCmVersion" } else { "ROCm (version unknown)" } + $rocmVerLabel = if ($script:ROCmVersionFull) { "ROCm $script:ROCmVersionFull" } elseif ($script:ROCmVersion) { "ROCm $script:ROCmVersion" } else { "ROCm (version unknown)" } step "rocm" $rocmVerLabel } elseif ($ROCmGpuLabel) { step "rocm" "HIP SDK not found -- GPU-accelerated training unavailable" "Yellow" diff --git a/tests/studio/install/test_rocm_support.py b/tests/studio/install/test_rocm_support.py index 9bfc37f364..0d680b77fd 100644 --- a/tests/studio/install/test_rocm_support.py +++ b/tests/studio/install/test_rocm_support.py @@ -2200,5 +2200,60 @@ class TestHipSdkEnvPathResolution: ) +# ============================================================================= +# TEST: HIP SDK detected substep -- path + hipconfig version shown in terminal +# ============================================================================= + + +class TestHipSdkDetectedSubstep: + """Verify that both scripts print HIP SDK path and full hipconfig version + as substeps under the gpu step when AMD ROCm is successfully detected.""" + + def test_setup_prints_hip_sdk_path_substep(self): + """setup.ps1 must print an 'HIP SDK:' substep showing the resolved path.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + assert "HIP SDK:" in source + + def test_install_prints_hip_sdk_path_substep(self): + """install.ps1 must print an 'HIP SDK:' substep showing the resolved path.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + assert "HIP SDK:" in source + + def test_setup_shows_hipconfig_full_version(self): + """setup.ps1 must capture and display the full hipconfig version string.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + assert "ROCmVersionFull" in source or "hipconfig:" in source + + def test_install_shows_hipconfig_full_version(self): + """install.ps1 must capture and display the full hipconfig version string.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + assert "ROCmVersionFull" in source or "hipconfig:" in source + + def test_setup_captures_full_version_not_just_major_minor(self): + """setup.ps1 must store the raw hipconfig output line, not just major.minor.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + assert "ROCmVersionFull" in source + + def test_install_captures_full_version_not_just_major_minor(self): + """install.ps1 must store the raw hipconfig output line, not just major.minor.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + assert "ROCmVersionFull" in source + + def test_setup_uses_hip_path_or_rocm_path_for_sdk_display(self): + """setup.ps1 HIP SDK path substep must check HIP_PATH then ROCM_PATH.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + assert "HIP_PATH" in source and "ROCM_PATH" in source + + def test_install_uses_hip_path_or_rocm_path_for_sdk_display(self): + """install.ps1 HIP SDK path substep must check HIP_PATH then ROCM_PATH.""" + source = _INSTALL_PS1_PATH.read_text(encoding = "utf-8") + assert "HIP_PATH" in source and "ROCM_PATH" in source + + def test_setup_rocm_step_uses_full_version(self): + """setup.ps1 'rocm' step label must prefer the full version string.""" + source = _SETUP_PS1_PATH.read_text(encoding = "utf-8") + assert "ROCmVersionFull" in source and "rocm" in source + + if __name__ == "__main__": pytest.main([__file__, "-v"])