Does JAX Run on AMD GPUs with ROCm?
In this article
Yes, JAX runs on AMD GPUs with ROCm, but with important caveats: official support is limited to specific ROCm versions and a narrow set of AMD GPUs, and the installation process is more involved than on NVIDIA CUDA. As of 2025, JAX's ROCm backend is functional for many models, but you must match versions carefully and may need to build from source for full compatibility.
Background: JAX and Its Hardware Support
JAX is a numerical computing library developed by Google that combines NumPy-like API with automatic differentiation and XLA (Accelerated Linear Algebra) compilation. It is widely used in machine learning research, especially for transformers and scientific computing. Historically, JAX officially supported only NVIDIA GPUs via CUDA, with CPU fallback. AMD support was community-driven for years, and only recently has Google added an official ROCm backend in the JAX repository. However, the official support is still labeled as experimental and is not as mature as CUDA.
How JAX Uses ROCm
ROCm (Radeon Open Compute) is AMD's open-source software stack for GPU computing, analogous to CUDA. JAX's ROCm backend works by compiling XLA to target AMD GPUs through the LLVM-based compiler and the ROCm runtime (HIP). When you install JAX with ROCm support, the `jaxlib` package includes precompiled kernels that use HIP to talk to the GPU. The key components are:
- ROCm runtime (rocr) and HIP libraries
- XLA compiler with ROCm target
- JAX's own device management (via the ROCm platform plugin)
In practice, JAX detects the GPU via the ROCm runtime and launches kernels just as it would on CUDA. Most JAX operations (jit, grad, vmap) work unchanged because they are hardware-agnostic; only the underlying kernel compilation differs.
Supported AMD GPUs and ROCm Versions
Official JAX ROCm support is limited to a specific set of GPUs that are officially supported by ROCm. As of mid-2025, these include:
- AMD Instinct MI200 and MI300 series (data center)
- Radeon RX 6000 series (only some, e.g., RX 6800/6900) and RX 7000 series (RDNA3) for consumer cards
- Older Vega and Radeon VII may work but are not officially supported
ROCm itself officially supports only a subset of AMD GPUs; for example, many consumer cards like the RX 6600 are not officially supported, although they may work with community patches. JAX's official ROCm wheels are built against specific ROCm versions (e.g., ROCm 5.7, 6.0, 6.1). You must install matching ROCm drivers and libraries; otherwise, JAX will fail to load or produce errors.
Installation Steps for JAX with ROCm
To install JAX with ROCm support, follow these steps (assuming a Linux system with an AMD GPU):
- Install ROCm drivers and libraries. For supported GPUs, use AMD's official installation guide for your distribution. Ensure the version matches the JAX wheel you plan to use.
- Create a Python virtual environment (e.g., conda or venv).
- Install JAX with ROCm using pip:
pip install -U "jax[rocm]"or specify a version likepip install jax==0.4.26 jaxlib==0.4.26+rocm601(check the official JAX GitHub for current version tags). - Verify installation by running a simple test:
import jax; print(jax.devices()). If it prints a ROCm device, you're good.
If your GPU is not officially supported, you may need to build jaxlib from source with ROCm, which is more complex and requires ROCm development packages.
Common Problems and Troubleshooting
Users often encounter these issues:
- Version mismatch: JAX expects a specific ROCm version. If you have a different one, you may see errors like "libamdhip64.so not found" or "unsupported ROCm version." Solution: install the exact ROCm version or use a Docker container.
- Unsupported GPU: If your GPU is not in the official list, JAX may not detect it. Workarounds include setting environment variables like
HIP_VISIBLE_DEVICESor using community patches, but these are not guaranteed. - Performance issues: Even if it runs, performance may be lower than on CUDA due to less optimized kernels. Some operations may fall back to CPU if no kernel exists for your GPU.
- Memory errors: ROCm has known issues with memory fragmentation on some cards; try setting
XLA_PYTHON_CLIENT_PREALLOCATE=false.
For troubleshooting, check the JAX GitHub issues and the ROCm forums for specific error messages.
JAX on AMD vs. NVIDIA: What to Expect
In terms of functionality, most JAX code runs identically on AMD and NVIDIA. However, there are differences:
- Performance: NVIDIA GPUs generally have better support and more optimized kernels, especially for mixed-precision and tensor core operations. AMD's performance is competitive on MI200/MI300 for large models, but consumer cards may lag.
- Ecosystem: Many libraries that build on JAX (e.g., Flax, Haiku) are hardware-agnostic, but some tools like profiling (NVIDIA Nsight) are CUDA-only. AMD has ROCm profilers, but they are less mature.
- Community: CUDA has a larger community, so more tutorials and prebuilt wheels. ROCm support is growing but still smaller.
If you are just starting, NVIDIA is easier. If you already have an AMD GPU and are willing to tinker, ROCm can work.
Alternatives to JAX on AMD GPUs
If JAX with ROCm proves too troublesome, consider these alternatives:
- PyTorch with ROCm: PyTorch has official ROCm support for many AMD GPUs, with prebuilt wheels and better documentation.
- TensorFlow with ROCm: Similar to PyTorch, TensorFlow has ROCm support, though it is also limited.
- Use CPU: For small models, CPU might be sufficient.
- Cloud GPUs: Rent NVIDIA GPUs from cloud providers if you need JAX specifically.
These alternatives may be more stable for production use.
Frequently Asked Questions
Does JAX run on AMD Radeon RX 7900 XTX?
Yes, the RX 7900 XTX (RDNA3) is officially supported by ROCm and JAX as of ROCm 5.7 and later. You need to install the matching ROCm version and JAX wheel. Performance is decent, but you may encounter occasional bugs due to the experimental nature of the backend.
Can I use JAX with AMD APUs (integrated graphics)?
ROCm does not officially support APUs (like Ryzen with Vega graphics) for compute, so JAX will not work on them. You would need a discrete AMD GPU that is in the supported list.
Is JAX on ROCm as fast as on CUDA?
Generally, no, especially on consumer GPUs. On data center MI200/MI300, performance is closer, but many kernels are still less optimized. For training large models, you might see 70-90% of CUDA speed, but it varies by operation.
Do I need to compile JAX from source for ROCm?
Only if your GPU is not in the official support list or if you need a different ROCm version. For officially supported GPUs, prebuilt wheels are available from the JAX GitHub releases. Building from source is complex and requires ROCm development packages.
Will JAX ROCm support improve in the future?
It is likely, as AMD is investing in ROCm and Google has shown commitment by adding official support. However, there is no public roadmap. Keep an eye on the JAX GitHub repository for updates.