mpv-player / mpv-player/mpv

mpv blocks CUDA device and fails to run multiple videos using nvdec

Open
#16,397 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

os:linux
Dominant language
C
Stars
37k
Forks
3.5k
Avg merge
1d 10h
Merged PRs (30d)
22

Description

mpv Information
mpv 0.40.0+git20250325.97cb16d68340 Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
libplacebo version: v7.349.0
FFmpeg version: 7.1 (runtime 7.1.1)
FFmpeg library versions:
   libavcodec      61.19.100 (runtime 61.19.101)
   libavdevice     61.3.100
   libavfilter     10.4.100
   libavformat     61.7.100
   libavutil       59.39.100
   libswresample   5.3.100
   libswscale      8.3.100
Other Information
- Linux version: NAME="openSUSE Tumbleweed"
- Kernel Version: Linux pc 6.14.6-1-default #1 SMP PREEMPT_DYNAMIC Tue May 13 09:56:22 UTC 2025 (ad69173) x86_64 x86_64 x86_64 GNU/Linux
- GPU Model: 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation AD103 [GeForce RTX 4080] [10de:2704] (rev a1)
- Mesa/GPU Driver Version: OpenGL version string: 4.6.0 NVIDIA 570.153.02
- Window Manager and Version: plasma6-desktop-6.3.5-1.1.x86_64
- Source of mpv: official repo
- Latest known working version: N/A
- Issue started after the following happened:
Reproduction Steps

Running mpv with nvdec/cuda hwdec even as mpv --no-config --hwdec=nvdec the 1st video works fine but:

  1. when I run a second video at the same time I get
[vo/gpu/cuda] cu->cuCtxCreate(&p->display_ctx, CU_CTX_SCHED_BLOCKING_SYNC, display_dev) failed -> CUDA_ERROR_DEVICE_UNAVAILABLE: CUDA-capable device(s) is/are busy or unavailable
[vo/gpu/cuda] CUDA hwdec only works with OpenGL or Vulkan backends.

2 .Also it block other CUDA software like ai model using pytorch or tensorflow.

Expected Behavior

Nvidia states that
https://docs.nvidia.com/video-technologies/video-codec-sdk/13.0/nvdec-application-note/index.html

NVDEC natively supports multiple hardware decoding contexts with negligible context-switching penalty.

So it should be possible to run in a non-blocking mode. and should be able to run multiple videos at the same time using nvdec.

Actual Behavior
  1. when I run a second video at the same time I get
[vo/gpu/cuda] cu->cuCtxCreate(&p->display_ctx, CU_CTX_SCHED_BLOCKING_SYNC, display_dev) failed -> CUDA_ERROR_DEVICE_UNAVAILABLE: CUDA-capable device(s) is/are busy or unavailable
[vo/gpu/cuda] CUDA hwdec only works with OpenGL or Vulkan backends.

2 .Also it block other CUDA software like ai model using pytorch or tensorflow.

Log File

output.txt

Sample Files

No response

I carefully read all instruction and confirm that I did the following:
  • I tested with the latest mpv version to validate that the issue is not already fixed.
  • I provided all required information including system and mpv version.
  • I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • I attached the backtrace in the case of a crash.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached output.txt and the CUDA hwdec path exercised by mpv --no-config --hwdec=nvdec. Reproduce the failure with two simultaneous videos and with another CUDA application; done means multiple videos can use nvdec without producing CUDA_ERROR_DEVICE_UNAVAILABLE or blocking other CUDA software.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.