[Fix] Improve ROCm detection in WSL environments (#38434)

Signed-off-by: Yizhou Liu <liu_yizhou@outlook.com>

Yizhou committed Aug 30, 2026 at 12:23 UTC 1ebff996a118cdc6e831c521c839d29ffe47d30f
1 file changed +15 -1
vllm/platforms/__init__.py
+15 -1
@@ -10,7 +10,7 @@ from vllm import envs
10 from vllm.plugins import PLATFORM_PLUGINS_GROUP, load_plugins_by_group
11 from vllm.utils.import_utils import resolve_obj_by_qualname
12
13 -from .interface import CpuArchEnum, Platform, PlatformEnum
13 +from .interface import CpuArchEnum, Platform, PlatformEnum, in_wsl
14
15 logger = logging.getLogger(__name__)
16
@@ -125,6 +125,20 @@ def rocm_platform_plugin() -> str | None:
125 except Exception as e:
126 logger.debug("ROCm platform is not available because: %s", str(e))
127
128 + if not is_rocm and in_wsl():
129 + try:
130 + import torch
131 +
132 + if (
133 + not vllm_version_matches_substr("cpu")
134 + and getattr(torch.version, "hip", None)
135 + and torch.accelerator.is_available()
136 + ):
137 + is_rocm = True
138 + logger.debug("Confirmed ROCm platform is available in WSL via PyTorch.")
139 + except Exception as e:
140 + logger.debug("WSL ROCm fallback detection failed because: %s", str(e))
141 +
142 return "vllm.platforms.rocm.RocmPlatform" if is_rocm else None
143
144