Skip to content

CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected #666

Closed

Description

@adefaria

Now that I finally converted all of my videos using Tdarr I like how I can leave it running and when new videos are downloaded it compresses them. And this works... But then it dies with "CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected". Now I've configured my Docker container to run Tdarr using Nvidia and I have properly configured it so that that works. But then it breaks with that error. The solution is simply to restart the Docker container and then re-queue the videos but why does it break in the first place?

QjALSDImR-log.txt

Activity

  1. adefaria commented on Aug 2, 2022

    @adefaria
    Author

    Another data point. When transcode fails in the docker container I can replicate the ffmpeg command on the desktop (IOW outside of the docker container) and it works fine.

    Why does it break in the docker container?

  2. HaveAGitGat commented on Aug 8, 2022

    @HaveAGitGat
    Owner

    Hmm seems like a bug between FFmpeg/Docker/Hardware, perhaps an FFmpeg update will fix the issue. The dev container has an FFmpeg update, looking to get it out soon.

  3. adefaria commented on Aug 9, 2022

    @adefaria
    Author

    I can try out the new version when it becomes available. I was suspecting it may be the Nvidia for Cocker containers (I have a foggy memory of installing that to get GPU transcoding to work in a Docker container) and something there broke down causing the CUDA_ERROR_NO_DEVICE. Lately, I'm seeing it just about transcodes a video or two and suddenly there are no devices left to GPU transcode. Restarting the Docker container always fixes the problem but it's essentially babysitting Tdarr, which shouldn't have to be the case.

  4. Sc0th commented on Aug 18, 2022

    @Sc0th

    FWIW I am seeing this exact behavior, happy to supply logs/test if it helps at all, a restart of the docker fixes it every time.

  5. adefaria commented on Aug 18, 2022

    @adefaria
    Author

    I had cron'ed a restart of the Docker container at midnight in an attempt to mitigate this issue but it remains.

    It might be nice if Tdarr allowed access to their database so I could interrogate the state and restart the Docker container if need be but then again if the bug is fixed it would be unnecessary.

    Out of curiosity, @Sc0th, what's your environment? Where are you running the Docker container? What OS/machine? And where's your server?

  6. Sc0th commented on Aug 19, 2022

    @Sc0th

    Apologies, I could have made that post slightly more useful!

    I also tried the automated reboot, also to no avail. I am running the docker using podman on a VM running on Proxmox with PCI pass-through.

    Some (maybe) useful detail:

    GPU - Nvidia 1050 Ti
    Proxmox 7.2-7
    
    Linux infra01 4.18.0-372.19.1.el8_6.x86_64 #1 SMP Tue Aug 2 13:42:59 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux
    AlmaLinux 8.6 (Sky Tiger)
    
    nvidia-container-toolkit-1.10.0-1.x86_64
    kmod-nvidia-515.65.01-1.el8_6.elrepo.x86_64
    
    podman run --name tdarr-node -v /appdata01/INFRA/tdarr-node/configs:/app/configs -v /appdata01/INFRA/tdarr-node/logs:/app/logs -v /MEDIA:/media -v /appdata01/PROD/tdarr/transcode:/transcode -e "nodeID=infra01-tdar
    r-node"  -e "serverIP=x.x.x.x" -e "serverPort=8266" --net=host -e PUID=1000 -e PGID=1000 -e "NVIDIA_DRIVER_CAPABILITIES=all" -e "NVIDIA_VISIBLE_DEVICES=all" --gpus=all -d ghcr.io/haveagitgat/tdarr_node'
    
    Tdarr Server & Node 2.00.18
    

    I am using the following line monitored by Zabbix to alert me when it gets stuck:

    cat /appdata01/PROD/tdarr/conf/server/Tdarr/DB2/StatisticsJSONDB/*.json | jq . | grep -ic err
    

    A result higher than 0 indicates it's got stuck, I did look at using this to 'self heal' by restating the docker on trigger, however the jobs do not appear to requeue automatically so that did not quite go to plan.

    I wait with greatful anticipation of the next release with hope of a fix!

  7. adefaria commented on Aug 19, 2022

    @adefaria
    Author

    Yeah, I think that it will end up being some interaction between Tdarr and the Nvidia runtime for the Docker container that causes Nvidia to lose track of available devices thus reporting NO_CUDA_DEVICE.

    I'm running on my Thelio desktop running Ubuntu 22.04. I have the following:

    Earth:apt list| grep nvidia-container
    
    WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    
    libnvidia-container-dev/bionic 1.10.0-1 amd64
    libnvidia-container-tools/bionic,now 1.10.0-1 amd64 [installed,automatic]
    libnvidia-container1-dbg/bionic 1.10.0-1 amd64
    libnvidia-container1/bionic,now 1.10.0-1 amd64 [installed,automatic]
    nvidia-container-runtime/bionic 3.10.0-1 all
    nvidia-container-toolkit/bionic,now 1.10.0-1 amd64 [installed]
    Earth:
    
  8. adefaria commented on Aug 23, 2022

    @adefaria
    Author

    Still have this issue however today I think I captured a log of Tdarr working on a video when the CUDA_ERROR_NO_DEVICE happened right in the middle. Maybe this log will help in debugging this bug
    .
    to7uvYRwN-log.txt
    .

  9. Lebo77 commented on Aug 27, 2022

    @Lebo77

    I am trying downgrading nvidia-docker2 back to 2.10.0-1 from 2.11.0-1 and seeing if that makes any difference as a workaround. If not I may try 2.9.1-1.

    I am having this same issue on Ubuntu 22.04 LTS.

  10. Lebo77 commented on Aug 28, 2022

    @Lebo77

    Downgrading to the nvidia-docker2 version 2.9.1-1 seems to be a workaround to this issue, at least in the day of testing. If it STOPS working I will let you know.

    Annoying to have my updates reporting a heald-back package, but better than Tdarr-node breaking every hour or two.

  11. HaveAGitGat commented on Aug 28, 2022

    @HaveAGitGat
    Owner

    Ok thanks for the update 👍

  12. adefaria commented on Aug 29, 2022

    @adefaria
    Author

    Thanks. Downgraded to 2.9.1-1. Will report what happens.

  13. Sc0th commented on Aug 29, 2022

    @Sc0th

    You have seen this 'With the release of Docker 19.03, usage of nvidia-docker2 packages is deprecated since NVIDIA GPUs are now natively supported as devices in the Docker runtime.' here: - https://docs.nvidia.com/ai-enterprise/deployment-guide/dg-docker.html ?

    I am using podman, with:

    nvidia-container-toolkit-1.10.0-1.x86_64
    nvidia-x11-drv-515.65.01-1.el8_6.elrepo.x86_64
    libnvidia-container1-1.10.0-1.x86_64
    nvidia-x11-drv-libs-515.65.01-1.el8_6.elrepo.x86_64
    libnvidia-container-tools-1.10.0-1.x86_64
    kmod-nvidia-515.65.01-1.el8_6.elrepo.x86_64
    

    And am seeing the same issue.

  14. adefaria commented on Aug 29, 2022

    @adefaria
    Author

    So are you saying I can just remove nvidia-docker2 and restart the docker container and it'll all work?

  15. 34 remaining items

  16. Lebo77 commented on Oct 6, 2022

    @Lebo77

    Well, I just added the recommended parameter to grub and rebooted. We will see if that fixes it.

  17. adefaria commented on Oct 6, 2022

    @adefaria
    Author

    Hmmm... Still having found how to get to the GRUB menu on my System76 Thelio but I figured I'd simply try to update-grub with the change put into /etc/defaults/grub. I rebooted and went through a few transcodes that queued up without a problem. That was yesterday. Today a new download came in and it transcoded with success! First time I had my Tdarr node survive and overnight! Look like this may be the fix.

    Of course, I wonder if Nvidia will fix this and use the newer cgroup hierarchy and how I might be notified so I can remove this setting and start using the newer setting.

  18. tedcook94 commented on Oct 6, 2022

    @tedcook94

    I'm not sure if this is a Nvidia or a Tdarr issue. I have two other Docker containers (plex and foldingathome) that both use the same GPU as my Tdarr container, and they never had any issues before or after I added the kernel parameter. Only Tdarr would "lose" the GPU from time to time.

    I'm no expert on cgroups, but it looks like there were some deprecated features when going from v1 to v2. Maybe Tdarr is either directly or indirectly using some deprecated v1 feature?

  19. adefaria commented on Oct 6, 2022

    @adefaria
    Author

    Inntereing observation! I didn't think about it but yes, my Plex also runs in a Docker container and uses the CPUs for hardware transcoding. This sounds like good info for the developer.

  20. Sc0th commented on Oct 7, 2022

    @Sc0th

    FWIW this completely broke it for me, so it may not be the full fix.

  21. adefaria commented on Oct 7, 2022

    @adefaria
    Author

    Well for me it's working. What OS/distro are you on? If you didn't type in the right stuff, didn't run update-grub or didn't reboot the Linux kernel will not warn you that you got it wrong.

    I'm on Ubuntu 22.04 and I have the following in /etc/defautls/grub

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash systemd.unified_cgroup_hierarchy=0"
    

    I've run update-grub and rebooted. My Tdarr node has stayed up for about 2 days, much longer than ever before without complaining about this error, and has been transcoding videos. In fact, it just transcoded 4 videos.

  22. Lebo77 commented on Oct 12, 2022

    @Lebo77

    The grub parameter change seems to be working for me. I am on Ubuntu 22.04.1 LTS.

    This is an OK workaround, but hopefully this can get fixed so that users are not required to change how the kernel is operating just to make this work.

  23. adefaria commented on Oct 12, 2022

    @adefaria
    Author

    Agreed. Not sure if I should close this as fixed with this workaround or leave it open to be fixed more properly.

  24. tedcook94 commented on Oct 12, 2022

    @tedcook94

    +1 for this being a workaround, but not an actual fix. However, since we have at least 3 people here who this seemed to resolve their issue, I'm sure there are others that have had similar issues and didn't find this solution.

    @HaveAGitGat, could we possibly document this workaround somewhere in the README/on docs.tdarr.io until a better or more permanent solution is found?

  25. tomgehrke commented on Oct 12, 2022

    @tomgehrke

    Can also confirm the workaround worked for me.

    So another vote for the "not fixed, but here's a workaround" option.

  26. yajrendrag commented on Dec 31, 2022

    @yajrendrag

    I'd been having the same issues - tdarr would work fine for about a day, and then I'd have to restart the containers in order for transcodes to ocurr. When i finally chased it down, I was getting the same error as OP and found a solution on the Arch wiki - though i am running Ubuntu 22.04 and docker 20.10.22. Seems to be an nvidia / docker issue. see Howard O-Neil's reply here. About half way through his answer he gives an alternative method where he details two ways to make this work that don't require adding kernel parameters:

    (1) set the container to privileged. After doing this, i never got the "CUDA_ERROR_NO_DEVICE" error and transcoding continues to work just fine without requiring container restarts.
    (2) Alternatively, if you don't wish to run the container with elevated privileges, you can change the way you do gpu passthrough to use nvidia-container-runtime. nvidia-container-toolkit on ubuntu now contains nvidia-container-runtime, so nothing to install and /etc/docker/daemon.json exists and doesn't require changes. You just need to change the docker run: change --gpus=all to --runtime nvidia and then explicitly add all the /dev/nvidia devices:

       --device=/dev/nvidia-caps:/dev/nvidia-caps \
       --device=/dev/nvidia0:/dev/nvidia0 \
       --device=/dev/nvidiactl:/dev/nvidiactl \
       --device=/dev/nvidia-modeset:/dev/nvidia-modeset \
       --device=/dev/nvidia-uvm:/dev/nvidia-uvm \
       --device=/dev/nvidia-uvm-tools:/dev/nvidia-uvm-tools \
    

    Similarly, you can change the compose file to effect these same changes / additions.

    Running the containers this way has also resulted in no "CUDA_ERROR_NO_DEVICE" errors and transcoding works without requiring daily-ish restarts.

    EDIT - in this 2nd alternative, i found i had to create an override to my docker.service systemd unit which basically waits for the existence of the above nvidia devices to exists.

    systemctl edit docker add [Unit] and then add a line for each device:
    ConditionPathExists=/dev/nvidia0 etc for each of the other devices, but whereas /dev/nvidia-caps is a directory, i just listed the whole path to it's 2 files - e.g., ConditionPathExists=/dev/nvidia-caps/nvidia-cap1
    OR you could add [Service] and add an ExecStartPre=/usr/bin/sleep 30 to delay start of docker giving it long enough for the device files to exist - 30 seconds is probably overkill...

    EDIT 2 - 2nd method did fail after a few days, so the only way i could make it work for container to stay up was to make it privileged.

  27. HaveAGitGat commented on Feb 7, 2023

    @HaveAGitGat
    Owner
  28. HaveAGitGat commented on Mar 17, 2023

    @HaveAGitGat
    Owner

    Issue is open on Jellyfin here so will let solution be handled there ty: jellyfin/jellyfin#9287

  29. tharun571 commented on Jan 20, 2026

    @tharun571

    Docker GPU detection can be especially tricky - nvidia-smi working on the host doesn't guarantee container access.

    Key Docker GPU troubleshooting steps:

    • Verify nvidia-container-runtime is installed and configured
    • Check Docker daemon config includes nvidia runtime
    • Ensure container has proper --runtime=nvidia or --gpus all flags
    • Validate CUDA libraries are accessible inside container

    I built env-doctor specifically to help diagnose these Docker+GPU issues. It checks:

    • Docker runtime configuration
    • GPU forwarding to containers
    • CUDA library paths and permissions
    • Works both inside/outside Docker to pinpoint where detection fails

    Full disclosure: I'm the author. Sharing because Docker GPU setup has unique challenges vs host GPU detection. Hope it helps others troubleshoot these issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions