Skip to content

ROCm/librocdxg

Repository files navigation

AMD ROCDXG Libary

A user-mode library that enables ROCm functionality on Windows Subsystem for Linux (WSL). This library allows users to run GPU-accelerated Linux workloads under WSL, supporting AI, HPC, and other experimental use cases.

Prerequisites

  • Download the compatible Windows driver from AMD Drivers
  • Download and install the latest stable version of WSL2 WSL Install
  • The following tools are required to build librocdxg:
    • CMake >= 3.15
    • GCC >= 11.4

Quickstart

1. Install Windows SDK

Download and install the Windows SDK from windows SDK

2. Install AMD ROCm package

please install the ROCm package by following the official ROCm Installation Quick Guide:

ROCm Installation Quick Start

Note This step may take several minutes, depending on internet connection and system speed. Follow the quick-start guide for package repository setup and ROCm package installation.

3. Build librocdxg

Run the following commands in your WSL console:

  1. Clone librocdxg repository to your local WSL.
git clone https://github.com/ROCm/librocdxg.git
cd librocdxg
  1. Verify that ROCm has been successfully installed.
tree -L 1 /opt

Expected result:

/opt/
├── [...]
├── rocm -> /etc/alternatives/rocm
├── rocm-7.2.0
└── [...]
  1. Build the librocdxg.
# Set the Windows SDK path (adjust version number if different)
export win_sdk='/mnt/c/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/'
 
# Build the library
mkdir -p build
cd build
cmake .. -DWIN_SDK="${win_sdk}/shared"
make
sudo make install

Note

  • The Windows SDK path may vary depending on the version you installed. Common locations include:
    • C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\
  • Ensure you have the necessary permissions to access the Windows SDK directory from WSL

4. Load the AMD ROCDXG libary

Set the environment variable HSA_ENABLE_DXG_DETECTION=1 to load librocdxg.so.

export HSA_ENABLE_DXG_DETECTION=1

5. Post-install verification checks

Run these post-installation checks to verify that the installation is complete.

Check if the GPU is listed as an agent:

rocminfo

Expected result:

[...]
*******
Agent 2
*******
  Name:                    gfx1100
  Marketing Name:          Radeon RX 7900 XTX
  Vendor Name:             AMD
  [...]
[...]

6. Container Launch – WSL-Specific Flags

When you launch the container, add these WSL-specific arguments (they do not replace the native-Linux GPU flags):

Flag Purpose
--device /dev/dxg Pass the /dev/dxg device node into the container so applications inside the container can access the GPU.
-v /usr/lib/wsl/lib/libdxcore.so:/usr/lib/libdxcore.so
-v /opt/rocm/lib/librocdxg.so:/usr/lib/librocdxg.so
Make the AMD ROCDXG and Microsoft DXCore libraries available inside the container so that ROCm/HIP applications can route their GPU compute calls through ROCDXG and DXCore to communicate with the GPU.
-e HSA_ENABLE_DXG_DETECTION=1 Tells the HSA runtime to detect GPU exposed via the DXG device (/dev/dxg) and to load the ROCDXG library.

Example docker run command:

docker run -it  \
    -v /usr/lib/wsl/lib/libdxcore.so:/usr/lib/libdxcore.so \
    -v /opt/rocm/lib/librocdxg.so:/usr/lib/librocdxg.so \
    -e HSA_ENABLE_DXG_DETECTION=1 \
    --device=/dev/dxg \
    --cap-add=SYS_PTRACE \
    --security-opt seccomp=unconfined \
    --ipc=host \
    --shm-size 8G \
    rocm/pytorch:latest

7. Known Issues and Limitations

  • The ROCm-supported version of JAX is not currently enabled or validated under WSL. As a result, JAX workloads on WSL may fail to install, initialize, or execute correctly.
  • Monitoring: AMD-smi are not supported. GPU metrics (temperature, clocks, and power) must be monitored via Windows-native tools such as Task Manager or AMD Software: Adrenalin Edition.
  • Debugging/Profiling: ROCm-profiler, Debugger are not supported.

WSL Compatiblity Matrix

  • Windows 11
  • Ubuntu 24.04 LTS / Ubuntu 22.04 LTS
  • The AMD ROCDXG library utilizes a ROCm runtime feature introduced in ROCm 7.1, which loads librocdxg to enable ROCm functionality within the WSL environment. This design keeps the librocdxg solution loosely coupled with both AMD ROCm release and Windows display driver. As a result, the AMD ROCDXG library can evolve independently, following its own development schedule without impacting the existing ROCm solution.
AMD Rocdxg Lib Version AMD ROCm Version AMD Windows Driver Version Supported AMD GPU Products
1.1.0 7.2 AMD Windows x86 drivers can be directly downloaded from AMD Driver Radeon

AMD Radeon RX 9070
AMD Radeon RX 9070 XT
AMD Radeon RX 9070 GRE
AMD Radeon AI PRO R9700
AMD Radeon RX 9060
AMD Radeon RX 9060 XT
AMD Radeon RX 7900 XTX
AMD Radeon RX 7900 XT
AMD Radeon RX 7900 GRE
AMD Radeon PRO W7900
AMD Radeon PRO W7900 Dual Slot
AMD Radeon PRO W7800
AMD Radeon PRO W7800 48GB
AMD Radeon RX 7800 XT
AMD Radeon PRO W7700

Ryzen

AMD Ryzen AI Max+ 395
AMD Ryzen AI Max 390
AMD Ryzen AI Max 385
AMD Ryzen AI 9 HX 375
AMD Ryzen AI 9 HX 370
AMD Ryzen AI 9 365

Documentation

For detailed documentation—including ROCm installation guides, configuration options, and metric descriptions—see "Use ROCm on Radeon and Ryzen".

Contributing

See CONTRIBUTING.md for guidelines on setting up your WSL environment, building, and submitting pull requests.