Drop-in amdsmi replacement for WSL2 / Windows (HIP + Windows interop backed).
Project description
amd-smi-wsl
Drop-in amdsmi for AMD GPUs on WSL2 — so vLLM, PyTorch ROCm & friends just work
Website · PyPI · Changelog · Issues · ROCm/amdsmi
On WSL2 an AMD GPU is exposed through DirectX para-virtualisation
(/dev/dxg), not the native amdgpu KFD driver — so /dev/kfd doesn't
exist and import amdsmi fails, which breaks ROCm platform detection in tools
like vLLM. amd-smi-wsl restores the amdsmi import surface using data
sources that do work under WSL2 (the HIP runtime + Windows interop), so those
tools start cleanly — no patching required.
This is a property of the WSL2 GPU stack, not of any single card, so it applies broadly across RDNA generations (RDNA3 / RDNA3.5 / RDNA4 desktop Radeon & Radeon PRO, and Ryzen AI APUs).
import amdsmi # this package, not the native one
amdsmi.amdsmi_init()
h = amdsmi.amdsmi_get_processor_handles()[0]
print(amdsmi.amdsmi_get_gpu_asic_info(h)["market_name"])
# -> AMD Radeon(TM) 8060S Graphics
✨ Highlights
- 🔌 100% import-compatible — every public symbol of the upstream binding:
all 190
amdsmi_*functions, all enums, and the full exception hierarchy. - 🧠 Real data, not fakes — device name, gfx arch, VRAM, compute units, UUID
and live memory from
torch.cuda(HIP); PCI id, subsystem id, revision and driver info from Windows interop. - ♻️ torch re-entrancy safe — a thread-local guard breaks the
amdsmi_init → torch.cuda → amdsmi_initrecursion that PyTorch's ROCm build would otherwise trigger. - 🎯 vLLM canonical names — returns
device_idas a hex string ("0x1586") so vLLM resolves the canonical name (e.g.AMD_Radeon_8060S). - 🧪 Honest
NOT_SUPPORTEDstubs for features the platform genuinely lacks (RAS/ECC, partitioning,set_*, events…), exactly like the native library. - 📦 Zero hard deps — pure-Python, no compiled extensions;
torchis never pinned so it won't fight your ROCm install.
🚀 Proven in production
Used as the platform shim to serve a 35B vision-MoE in 4-bit AWQ
(Qwen3.6-35B-A3B) on a single AMD Radeon 8060S (Strix Halo, gfx1151) under
WSL2 with source-built vLLM — amd-smi-wsl supplies the amdsmi surface vLLM's
ROCm platform detection needs, end-to-end OpenAI-compatible serving included.
Why
On WSL2 any AMD GPU is exposed through DirectX para-virtualisation
(/dev/dxg + dxgkrnl), not the native amdgpu KFD driver. The Linux
/dev/kfd device and its sysfs topology simply do not exist, so — regardless
of which Radeon / Ryzen GPU you have:
import amdsmi(native) fails /amdsmi_init()raises, and- downstream code such as vLLM then fails ROCm platform detection and device-name / topology queries at startup,
even though the HIP runtime itself works perfectly via /dev/dxg.
This package restores the amdsmi import surface and re-implements the
queryable subset on top of data sources that do work in WSL2:
| Source | Provides |
|---|---|
torch.cuda (HIP runtime) |
device count, name, GCN arch, total VRAM, compute units, UUID, live mem usage |
Windows interop (Get-CimInstance Win32_VideoController) |
real PCI device id, subsystem id, revision, driver version/date |
Static gfx -> metadata table |
marketing name / VRAM type / device id fallbacks |
Note on
torchre-entrancy. PyTorch's ROCm build resolves its device count throughamdsmiitself. Since this package replacesamdsmi, a naive probe would recurse (amdsmi_init->torch.cuda->amdsmi_init...). A thread-local re-entrancy guard breaks that cycle sotorchfalls back to its native HIP device count. See the v0.2.0 entry in the changelog.
API coverage
The package exposes every public symbol of the upstream binding —
all 190 amdsmi_* functions, all AmdSmi* enums, and the full
exception hierarchy — so import amdsmi is binary-compatible at the
Python level.
- Implemented for real (read-only queries that map cleanly to HIP /
Windows data): init / shutdown, processor & socket handle enumeration,
asic_info,board_info,vram_info,vram_usage,memory_total,memory_usage,device_uuid,device_bdf,driver_info,gpu_id,subsystem_id/name,revision,vendor_name,topo_get_link_type,topo_get_numa_node_number,lib_version,rocm_version,status_code_to_string, and best-effortactivity/clock_info/temp_metric/power_info(when the runningtorchbuild exposes them). - Faithful
NOT_SUPPORTEDstubs for everything the platform genuinely lacks under WSL2: the entire CPU/HSMP/EPYC surface, performance counters, RAS/ECC, compute/memory partitioning, everyset_*mutator, GPU reset, KFD info, XGMI status, and event notification. These raiseAmdSmiLibraryException(AMDSMI_STATUS_NOT_SUPPORTED)— exactly what the native library does for unsupported features.
Install
pip install amd-smi-wsl
torch (ROCm build) is expected to already be present in your environment and
is therefore not declared as a hard dependency.
Only install this where the real
amdsmicannot be used. In a normal native-Linux ROCm install you should keep the officialamdsmi.
Environment variables
HSA_ENABLE_DXG_DETECTION— auto-set to1for you. On WSL2 the HIP/HSA runtime only enumerates the DirectX-paravirtualized GPU when this is exported before the firsttorch.cudacall. Importing this package sets it (viaos.environ.setdefault, so an explicit value you set is always respected) when it detects WSL — soimport amdsmiis self-contained and you no longer have to export it by hand. Only applied inside WSL, and skipped whenAMDSMI_WSL_DISABLEis set.AMDSMI_WSL_DISABLE=1— makeamdsmi_init()raiseNOT_SUPPORTED(and skip theHSA_ENABLE_DXG_DETECTIONauto-set), useful to test a caller's fallback path.
Relationship to vLLM
This package makes the native-amdsmi code paths in vLLM's
vllm/platforms/rocm.py and vllm/platforms/__init__.py work unchanged on
WSL2, as an alternative to patching vLLM with torch.cuda fallbacks
(cf. vLLM PR #37189).
With this package installed, vLLM resolves the canonical device name from
its hex-keyed _ROCM_DEVICE_ID_NAME_MAP (because asic_info["device_id"] is
returned as a lowercase hex string such as "0x1586"), e.g.:
from vllm.platforms import rocm_platform_plugin
import vllm.platforms.rocm as rocm
rocm_platform_plugin() # -> 'vllm.platforms.rocm.RocmPlatform'
rocm.RocmPlatform.get_device_name(0) # -> 'AMD_Radeon_8060S'
rocm._GCN_ARCH # -> 'gfx1151'
Verified environment
The mechanism is GPU-agnostic (it only relies on the HIP runtime + Windows
interop, which behave the same for any Radeon / Ryzen GPU under WSL2). The
numbers below are from one fully validated end-to-end setup — WSL2 + AMD
Radeon 8060S (Strix Halo, gfx1151) + ROCm 7.2.4 + PyTorch 2.9.1 — and the
device-specific values (name, device_id, gfx arch) will naturally differ on
other cards:
| Check | Result |
|---|---|
import amdsmi + amdsmi_init() |
OK (no recursion) |
amdsmi_get_gpu_asic_info()["market_name"] |
AMD Radeon(TM) 8060S Graphics |
amdsmi_get_gpu_asic_info()["device_id"] |
0x1586 (hex string) |
target_graphics_version |
gfx1151 |
test suite (pytest) |
17 passed |
vLLM rocm_platform_plugin() |
vllm.platforms.rocm.RocmPlatform |
vLLM RocmPlatform.get_device_name(0) |
AMD_Radeon_8060S |
vLLM is_fully_connected([0]) |
True |
Telemetry that the platform does not expose (clock_info, temp_metric,
power_info, gpu_activity) raises AMDSMI_STATUS_NOT_SUPPORTED, as expected.
License
MIT. Status constants, enum values and exception classes are derived from the MIT-licensed ROCm/amdsmi project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file amd_smi_wsl-0.3.0.tar.gz.
File metadata
- Download URL: amd_smi_wsl-0.3.0.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
422613009cb0c009b9e006620d65036e2ead9d0b58cdd9353ed86e149da13bfd
|
|
| MD5 |
27affa3cc3532e99e93a1a884d00281b
|
|
| BLAKE2b-256 |
daacd0e2d50e6790aeef232b187fd61c17afa0a22a74e37c3fc80ec0dd8a91cb
|
File details
Details for the file amd_smi_wsl-0.3.0-py3-none-any.whl.
File metadata
- Download URL: amd_smi_wsl-0.3.0-py3-none-any.whl
- Upload date:
- Size: 32.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30a0256349b16fc2a532a77edb3c4adf270d326f380f06202baf15974321f3d0
|
|
| MD5 |
717593613fbeb5e793d04ccb76b800e2
|
|
| BLAKE2b-256 |
2d48d94a9c89c1f0d974627506da50d6b63746b559f351b74368a3b1ebc06426
|