Project 001
verified working · april 2026

WSL2 · ROCm · RDNA4 — a survival guide.

How to coax GPU acceleration out of WSL2 using ROCm 7.2.1 on RDNA4 hardware (RX 9070 XT, gfx1201) so PixInsight's BlurX, StarX and NoiseX run at full GPU speed. Written so future-me doesn't have to rediscover any of it.

ROCm 7.2.1 TF 2.20 gfx1201 WSL2 2.6.3 Ubuntu 24.04 Adrenalin 26.3.1
§ 01

Prerequisites

GPU

AMD Radeon RX 9070 XT (gfx1201 / RDNA4)

May also work for other RDNA3/4 cards — adjust HSA_OVERRIDE_GFX_VERSION accordingly.

DRV

AMD Adrenalin 26.1.1 or newer (standard gaming driver)

Tested and confirmed working on 26.3.1. No special WSL2-variant driver needed — GPU passthrough is handled by librocdxg on the Linux side.

OS

Windows 10/11 + WSL2 2.6.3+ with Ubuntu 24.04 LTS

Install Ubuntu 24.04 from the Microsoft Store. Docker must also be installed inside WSL2.

PI

PixInsight installed inside Ubuntu WSL2

PixInsight must run inside WSL2 (not native Windows) to use this setup.

§ 02

Install ROCm 7.2.1 in WSL2

Install the amdgpu-install script

bash
sudo apt update
wget https://repo.radeon.com/amdgpu-install/7.2.1.70201/ubuntu/noble/amdgpu-install_7.2.1.70201-1_all.deb
sudo apt install ./amdgpu-install_7.2.1.70201-1_all.deb
sudo apt update

Install ROCm with the graphics usecase

WARN
Do not use --usecase=wsl — it no longer exists in ROCm 7.2.1. The --no-dkms flag is essential for WSL2 since the kernel driver lives on the Windows side.
bash
sudo amdgpu-install -y --usecase=graphics,rocm --no-dkms

Add ROCm to the library path

bash
echo '/opt/rocm/lib' | sudo tee /etc/ld.so.conf.d/rocm.conf
sudo ldconfig

Install librocdxg — the critical WSL2 GPU bridge

KEY
This is the single most important step for WSL2. librocdxg bridges ROCm to /dev/dxg (the WSL2 GPU passthrough device). Without it, hipInit will always fail with HIP_ERROR_NoDevice.

Follow the quickstart at github.com/ROCm/librocdxg.

Verify GPU detection

bash
export HSA_ENABLE_DXG_DETECTION=1
/opt/rocm/bin/rocminfo 2>&1 | head -30
# Should show: Name: gfx1201 / Marketing Name: AMD Radeon RX 9070 XT
§ 03

Set up the Docker build environment

Load vgem (needed for /dev/dri inside Docker)

bash
sudo modprobe vgem
# Make it persistent:
echo "vgem" | sudo tee /etc/modules-load.d/vgem.conf

Pull the ROCm TensorFlow image

bash
sudo docker pull rocm/tensorflow:rocm7.2.1-py3.12-tf2.20-dev

Start the container

INFO
Run this from the directory where you want build artifacts saved — the -v $PWD:/artifacts flag mounts it into the container. Keep ~50 GB free.
bash
sudo docker run -it \
  --device=/dev/dxg \
  --device=/dev/dri \
  --group-add video \
  --security-opt seccomp=unconfined \
  --cap-add=SYS_PTRACE \
  --ipc=host \
  -v $PWD:/artifacts \
  -w /root \
  rocm/tensorflow:rocm7.2.1-py3.12-tf2.20-dev bash
§ 04

Build libtensorflow.so with ROCm

All commands below run inside the Docker container. First build takes 1–3 hours; subsequent builds use Bazel's cache and are much faster.

Install build dependencies

bash · inside container
apt-get update && apt-get install -y clang lld patchelf python3-dev zip unzip wget

Install Bazelisk

bash · inside container
curl -Lo /usr/local/bin/bazelisk \
  https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64
chmod +x /usr/local/bin/bazelisk
ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel

Clone the ROCm TensorFlow branch

bash · inside container
cd /root
git clone https://github.com/ROCmSoftwarePlatform/tensorflow-upstream.git
cd tensorflow-upstream
git checkout r2.20-rocm-enhanced

Configure

bash · inside container
./configure
# When asked about Clang: Y
# Clang path: /usr/lib/llvm-18/bin/clang
# All other prompts: Enter for defaults

Patch the pywrap macro (required)

WARN
The r2.20-rocm-enhanced branch conditionally skips building libtensorflow.so when USE_PYWRAP_RULES=True. This patch is required or the target won't exist.
bash · inside container
sed -i 's/if use_pywrap_rules():/if False:  # patched to force build/' \
  tensorflow/tensorflow.bzl

Build libtensorflow.so

bash · inside container
export TF_ROCM_AMDGPU_TARGETS='gfx1201'
export HERMETIC_PYTHON_VERSION=3.12

bazel build \
  --config=rocm \
  --config=opt \
  --action_env=HERMETIC_PYTHON_VERSION=3.12 \
  --action_env=TF_ROCM_AMDGPU_TARGETS=gfx1201 \
  --experimental_repository_downloader_retries=3 \
  --verbose_failures \
  '//tensorflow:tensorflow' \
  2>&1 | tee /artifacts/bazel_build_libtf.log

Also build the pip wheel (for framework libs)

bash · inside container
./build_rocm_python3 2>&1 | tee /artifacts/build_rocm.log
§ 05

Copy & install the built libraries

Copy out of the container

bash · inside container
cp -P bazel-bin/tensorflow/libtensorflow.so* /artifacts/
cp /opt/venv/lib/python3.12/site-packages/tensorflow/libtensorflow_framework.so.2 /artifacts/
cp /opt/venv/lib/python3.12/site-packages/tensorflow/libtensorflow_cc.so.2 /artifacts/

Install to the WSL2 system (outside container)

bash · WSL2
sudo cp libtensorflow.so.2.20.0 /usr/local/lib/
sudo cp libtensorflow_framework.so.2 /usr/local/lib/
sudo cp libtensorflow_cc.so.2 /usr/local/lib/
sudo ln -sf /usr/local/lib/libtensorflow.so.2.20.0 /usr/local/lib/libtensorflow.so.2
sudo ln -sf /usr/local/lib/libtensorflow.so.2.20.0 /usr/local/lib/libtensorflow.so
sudo ln -sf /usr/local/lib/libtensorflow_framework.so.2 /usr/local/lib/libtensorflow_framework.so
sudo ln -sf /usr/local/lib/libtensorflow_cc.so.2 /usr/local/lib/libtensorflow_cc.so
sudo ldconfig

Replace PixInsight's bundled TF 2.11.0

INFO
PixInsight ships with TensorFlow 2.11.0 which has no ROCm support. You must replace it with your compiled 2.20 build.
bash · WSL2
# Backup originals
sudo mkdir -p /opt/PixInsight/bin/lib/backup
sudo mv /opt/PixInsight/bin/lib/libtensorflow*.so* /opt/PixInsight/bin/lib/backup/

# Install ROCm libraries
sudo cp /usr/local/lib/libtensorflow.so.2.20.0 /opt/PixInsight/bin/lib/
sudo cp /usr/local/lib/libtensorflow_framework.so.2 /opt/PixInsight/bin/lib/
sudo cp /usr/local/lib/libtensorflow_cc.so.2 /opt/PixInsight/bin/lib/

cd /opt/PixInsight/bin/lib
sudo ln -sf libtensorflow.so.2.20.0 libtensorflow.so.2
sudo ln -sf libtensorflow.so.2.20.0 libtensorflow.so
sudo ln -sf libtensorflow_framework.so.2 libtensorflow_framework.so
sudo ln -sf libtensorflow_cc.so.2 libtensorflow_cc.so
sudo ldconfig
§ 06

Configure PixInsight

Install missing system libraries

bash · WSL2
sudo apt-get install -y libssh2-1
sudo locale-gen en_US.utf8
sudo update-locale LC_ALL=en_US.utf8

Edit /opt/PixInsight/bin/PixInsight.sh

Add the ROCm environment variables at the top and fix the library path:

PixInsight.sh — key additions
# Add these exports near the top of the script:
export ROCM_PATH=/opt/rocm
export HSA_ENABLE_DXG_DETECTION=1       # Critical for WSL2 GPU detection
export HSA_OVERRIDE_GFX_VERSION=12.0.1   # RX 9070 XT (gfx1201)
export HIP_VISIBLE_DEVICES=0
export HSA_ENABLE_SDMA=0
export TF_FORCE_GPU_ALLOW_GROWTH=true
export MIOPEN_FIND_MODE=3
export MIOPEN_USER_DB_PATH=$HOME/.config/miopen
export DISPLAY=:0

# Replace the LD_LIBRARY_PATH line with:
LD_LIBRARY_PATH=/opt/PixInsight/bin/lib:/opt/PixInsight/lib:/opt/rocm/lib:$LD_LIBRARY_PATH

Add to ~/.bashrc for persistence

bash · WSL2
echo 'export HSA_ENABLE_DXG_DETECTION=1' >> ~/.bashrc
echo 'export HSA_OVERRIDE_GFX_VERSION=12.0.1' >> ~/.bashrc
echo 'export ROCM_PATH=/opt/rocm' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
§ 07

Key lessons

01

Standard gaming driver works

No WSL2-specific AMD driver needed. Adrenalin 26.3.1 is confirmed working — passthrough is handled by librocdxg on the Linux side.

02

librocdxg is the real key

In ROCm 7.2.1, AMD replaced hsa-runtime-rocr4wsl with the open-source librocdxg library. Install it separately from ROCm.

03

HSA_ENABLE_DXG_DETECTION=1

Without this env var, ROCm will not use the /dev/dxg WSL2 passthrough path even with librocdxg installed.

04

PixInsight ships outdated TF

It bundles TF 2.11.0 with no ROCm support. Replace it with your ROCm-compiled libtensorflow.so in /opt/PixInsight/bin/lib/.

05

Patch the pywrap macro

The r2.20-rocm-enhanced branch skips building libtensorflow.so by default. The one-line sed patch to tensorflow.bzl is required.

06

/dev/dri not needed for PixInsight

Only /dev/dxg matters at runtime. vgem/dri is only needed temporarily inside the Docker build container.

07

rocm-smi doesn't work in WSL2

"amdgpu not found in modules" from rocm-smi is normal and expected on WSL2. Use rocminfo instead to verify GPU detection.

§ 08

Common errors & fixes

ERR · 01 hsa_init failed, possibly no supported GPU devices

Verify librocdxg is installed. Make sure HSA_ENABLE_DXG_DETECTION=1 is exported before running rocminfo. Check that /dev/dxg exists. Ensure AMD driver is 26.1.1+.

ERR · 02 librocm.so NOT_FOUND

Cosmetic only — ROCm on WSL2 uses libhsa-runtime64.so rather than librocm.so. Optional symlink fix:

bash
sudo ln -sf /opt/rocm/lib/libhsa-runtime64.so /opt/rocm/lib/librocm.so
sudo ldconfig
ERR · 03 PixInsight loads old TF (oneDNN messages in console)

PixInsight is loading its bundled TF 2.11.0 instead of your ROCm build. Verify /opt/PixInsight/bin/lib/libtensorflow.so points to your 2.20.0 build, and that /opt/PixInsight/bin/lib is first in LD_LIBRARY_PATH.

ERR · 04 /dev/dri: No such file or directory (in Docker)
bash
sudo modprobe vgem
ERR · 05 invalid linker name in argument '-fuse-ld=lld'
bash · inside container
apt-get install -y lld
ERR · 06 no such target '//tensorflow:tensorflow'

The pywrap macro patch was not applied. Re-run:

bash · inside container
sed -i 's/if use_pywrap_rules():/if False:  # patched to force build/' \
  tensorflow/tensorflow.bzl
ERR · 07 PixInsight fails to start: missing .so libraries
bash
sudo apt-get install -y libssh2-1
# libalglibdev_64mkl.so lives in /opt/PixInsight/bin/lib/
# Make sure that path is first in LD_LIBRARY_PATH
§ 09

References