I'm using mpv in GNU/Linux with Wayland. GPU is AMD Radeon RX 6400. With hardware decoding mpv throwing error "[ffmpeg] AVHWDeviceContext: cu->cuInit(0) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected" what is expected as my GPU supporting ROCm instead of CUDA. What can be done to avoid this error?
Assistant
The error message:
code
[ffmpeg] AVHWDeviceContext: cu->cuInit(0) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
indicates that FFmpeg (and thus mpv) is trying to initialize CUDA hardware acceleration, but your AMD GPU does not support CUDA (which is NVIDIA-specific). Since your GPU is an AMD Radeon RX 6400, it cannot use CUDA, but you want to use hardware video decoding with AMD's capabilities.
Why this happens
By default, your mpv or FFmpeg might be trying to use CUDA hardware acceleration because you or the config specified hwdec=cuda or something similar.
Your AMD GPU supports hardware video decoding via VA-API or Vulkan-based API (possibly via vdpau-amdgpu or more commonly now vaapi on Linux), or potentially through ROCm CUDA alternative, but ROCm is more geared towards compute/GPGPU, not video decode acceleration.
In practice, video decoding on AMD Radeon in Linux is done via VA-API or VDPAU (via compatibility layers).
How to fix this
Use VA-API for video decoding in mpv
Instead of trying CUDA hardware decoding, switch mpv to use VA-API for hardware decoding:
bash
mpv --hwdec=vaapi yourvideo.mp4
Or, to make it permanent, add or edit your ~/.config/mpv/mpv.conf:
code
hwdec=vaapi
Check your system supports VA-API
Make sure the VA-API driver for AMD GPU is installed.
For Debian/Ubuntu:
bash
sudo apt install vainfo mesa-va-drivers
For Fedora:
bash
sudo dnf install libva-utils mesa-va-drivers
Verify VA-API is working
Run:
bash
vainfo
You should see info about your AMD GPU and supported profiles.
Possible MPV GPU backend
Since you are on Wayland, and your GPU is AMD, you likely want to use either --gpu-context=wayland or rely on Vulkan, but this is orthogonal to hwdec.
Avoid specifying hwdec=cuda anywhere
If you have hwdec=cuda in your config or command line, remove it because it will always try to use CUDA and fail on AMD hardware.
Alternative (experimental): Use hwdec=auto
Using hwdec=auto lets mpv pick a supported hardware decoder automatically (e.g., vaapi on AMD).
Summary
Your AMD GPU cannot do CUDA video decode; use VA-API instead.
Configure mpv to use hwdec=vaapi and ensure VA-API drivers are installed.
Remove any hwdec=cuda configuration.
If you want a full example mpv.conf snippet:
ini
hwdec=vaapi
gpu-context=wayland
Extra notes about ROCm and video decode
ROCm is AMD's platform for GPU compute/workloads similar to CUDA. However, ROCm does not provide video decode acceleration API for multimedia apps like mpv or FFmpeg. Video decoding on AMD GPUs relies on driver-level support via VA-API on Linux.
If after switching to VA-API you run into other errors or want to optimize further, feel free to ask!