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.
May also work for other RDNA3/4 cards — adjust HSA_OVERRIDE_GFX_VERSION accordingly.
Tested and confirmed working on 26.3.1. No special WSL2-variant driver needed — GPU passthrough is handled by librocdxg on the Linux side.
Install Ubuntu 24.04 from the Microsoft Store. Docker must also be installed inside WSL2.
PixInsight must run inside WSL2 (not native Windows) to use this setup.
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
--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.sudo amdgpu-install -y --usecase=graphics,rocm --no-dkms
echo '/opt/rocm/lib' | sudo tee /etc/ld.so.conf.d/rocm.conf sudo ldconfig
/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.
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
sudo modprobe vgem
# Make it persistent:
echo "vgem" | sudo tee /etc/modules-load.d/vgem.conf
sudo docker pull rocm/tensorflow:rocm7.2.1-py3.12-tf2.20-dev
-v $PWD:/artifacts flag mounts it into the container. Keep ~50 GB free.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
All commands below run inside the Docker container. First build takes 1–3 hours; subsequent builds use Bazel's cache and are much faster.
apt-get update && apt-get install -y clang lld patchelf python3-dev zip unzip wget
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
cd /root git clone https://github.com/ROCmSoftwarePlatform/tensorflow-upstream.git cd tensorflow-upstream git checkout r2.20-rocm-enhanced
./configure
# When asked about Clang: Y
# Clang path: /usr/lib/llvm-18/bin/clang
# All other prompts: Enter for defaults
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.sed -i 's/if use_pywrap_rules():/if False: # patched to force build/' \ tensorflow/tensorflow.bzl
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
./build_rocm_python3 2>&1 | tee /artifacts/build_rocm.log
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/
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
# 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
sudo apt-get install -y libssh2-1 sudo locale-gen en_US.utf8 sudo update-locale LC_ALL=en_US.utf8
Add the ROCm environment variables at the top and fix the library path:
# 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
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
No WSL2-specific AMD driver needed. Adrenalin 26.3.1 is confirmed working — passthrough is handled by librocdxg on the Linux side.
In ROCm 7.2.1, AMD replaced hsa-runtime-rocr4wsl with the open-source librocdxg library. Install it separately from ROCm.
Without this env var, ROCm will not use the /dev/dxg WSL2 passthrough path even with librocdxg installed.
It bundles TF 2.11.0 with no ROCm support. Replace it with your ROCm-compiled libtensorflow.so in /opt/PixInsight/bin/lib/.
The r2.20-rocm-enhanced branch skips building libtensorflow.so by default. The one-line sed patch to tensorflow.bzl is required.
Only /dev/dxg matters at runtime. vgem/dri is only needed temporarily inside the Docker build container.
"amdgpu not found in modules" from rocm-smi is normal and expected on WSL2. Use rocminfo instead to verify GPU detection.
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+.
Cosmetic only — ROCm on WSL2 uses libhsa-runtime64.so rather than librocm.so. Optional symlink fix:
sudo ln -sf /opt/rocm/lib/libhsa-runtime64.so /opt/rocm/lib/librocm.so sudo ldconfig
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.
sudo modprobe vgem
apt-get install -y lld
The pywrap macro patch was not applied. Re-run:
sed -i 's/if use_pywrap_rules():/if False: # patched to force build/' \ tensorflow/tensorflow.bzl
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