Jump to content

Disable CPU transcoding or prefer GPU where possible


Recommended Posts

Posted

Hello! I just recently installed a new Quadro RTX 4000 to my server and Emby can see it. However, I have someone playing something right now and transcoding is pegging my CPU at almost 100% during the entire process while the GPU sits at 0% usage. The below widgets are from my Homepage dashboard.

image.thumb.png.35c7393d9091d9ade6acc1e11e6a2a93.png

This is from 2 items that are being played right now. Both transcoding.

image.png.cb8a06c7b1dce1a249f669d0280c59a5.png

I would REALLY like to not have to throttle transcoding on this Xeon W-2135 and have the GPU do some of the work for which it was purchased. Is there a way or can there be a way that we can force the GPU to take some or all of this load?

image.png.ff94e371481db53d28a063aac686a341.png

GrimReaper
Posted (edited)
4 minutes ago, ryderjj89 said:

Is there a way or can there be a way that we can force the GPU to take some or all of this load?

That should've been done automatically with active Premiere subscription (or maybe it was and it errored out with fallback to software transcode) - can you post ffmpeg logs for those sessions?

Edited by GrimReaper
Posted
1 minute ago, GrimReaper said:

That should've been done automatically with active Premiere subscription. Can you post ffmpeg logs for those sessions?

Yeah I kinda thought so. I spent almost $300 on this GPU hoping it would improve things and to see it not do anything at all is..well...discouraging. Here are 2 ffmpeg logs.

ffmpeg-transcode-7621e523-fae6-4624-93fc-6297978c7829_1.txt ffmpeg-transcode-a639ff8a-1515-4c44-809b-fb87157b63cd_1.txt

GrimReaper
Posted

Hm:

Quote

>>>>>>  FindVideoEncoder - MediaType: h264, UseHardwareCodecs: False, HWA-Mode: Advanced
Info    Checking: 'x264'
Info    Check successful - selecting 'x264'

>>>>>>  FindVideoDecoder - MediaType: hevc, UseHardwareCodecs: False, HWA-Mode: Advanced
Info    Checking: 'Automatic software decoder'
Info    Check successful - selecting 'Automatic software decoder'

Do you maybe have Diagnostics plugin installed?

Posted
Just now, GrimReaper said:

Hm:

Do you maybe have Diagnostics plugin installed?

I do have the Diagnostics plugin installed. This is what's checked. I also noticed in one of the logs, this little tidbit which caused it to fallback to software:

CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected

I'm using Ubuntu 24.04 LTS with Emby running in Docker if that helps at all.

image.png.62cbe56edde552c2b3f661e492164601.png

GrimReaper
Posted (edited)

The second session was as said:

12 minutes ago, GrimReaper said:

maybe it was and it errored out with fallback to software transcode

Quote

>>>>>>  FindVideoEncoder - MediaType: h264, UseHardwareCodecs: True, HWA-Mode: Advanced
Info    Checking: 'NVENC Quadro RTX 4000 - H.264 (AVC)'
Info    Check successful - selecting 'NVENC Quadro RTX 4000 - H.264 (AVC)'

>>>>>>  FindVideoDecoder - MediaType: hevc, UseHardwareCodecs: True, HWA-Mode: Advanced
Info    Checking: 'NVDEC Quadro RTX 4000 - H.265 (HEVC)'
Info    Check successful - selecting 'NVDEC Quadro RTX 4000 - H.265 (HEVC)'

Warning: Hardware-accelerated subtitle-overlay is disabled due to diagnostic option

>>>>>>  Subtitle Processing Steps for [0:2]: HDMV PGS subtitles
        Step                    Format             Target Size 
        HDMV_PGS_SUBTITLE    >> Subs: Bitmap       1920x1080   
        scale                >> Video: UNKNOWN     1920x-2     

>>>>>>  Processing Plan
        Name                                        CanDoInHW  WillDoInHW  Reason                                                 
        NVDEC Quadro RTX 4000 - H.265 (HEVC)     >> True       True        Hardware Codec                                          
        VideoInput                               >> True       True        Matching hardware context                               
        Scaling                                  >> True       True                                                                
        ColorConversion                          >> True       True                                                                
        SubtitleOverlay                          >> False      False                                                               
        VideoOutput                              >> True       True        Hardware encoder                                        
        NVENC Quadro RTX 4000 - H.264 (AVC)      >> True       True        Hardware Codec                                          

>>>>>>  Video Processing Steps for [0:0]: H.265 (HEVC)
        Step                    HW-Context   Format       SW-Format           Size   Next
        HEVC                 >> CUDA         cuda         yuv420p10      3840x2160 >> scale_cuda
        scale_cuda           >> CUDA         cuda         yuv420p        1920x1080 >> setsar
        setsar               >> CUDA         cuda         yuv420p        1920x1080 >> hwdownload
        hwdownload           >> -            yuv420p      yuv420p        1920x1080 >> format
        format               >> -            yuv420p      yuv420p        1920x1080 >> format
        format               >> -            yuv420p      yuv420p        1920x1080 >> overlay
        overlay              >> -            yuv420p      yuv420p        1920x1080 >> 

Quote

12:54:13.363 ffmpeg version 5.1-emby_2023_06_25 Copyright (c) 2000-2022 the FFmpeg developers and softworkz for Emby LLC
12:54:13.363   built with gcc 10.3.0 (crosstool-NG 1.25.0)
12:54:13.363 Execution Date: 2025-01-30 12:54:13
12:54:13.367 [AVHWDeviceContext @ 0x234e6a40] cu->cuInit(0) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
12:54:13.367 Device creation failed: -542398533.
12:54:13.367 Failed to set value 'cuda=cuda:0' for option 'init_hw_device': Generic error in an external library
12:54:13.367 Error parsing global options: Generic error in an external library
12:54:13.368 EXIT

Quote

>>>>>>  Selected Codecs
Decoder Automatic software decoder


Encoder x264
        Max Bitrate: 781 Mbit/s
        Color Formats: YUV420P, YUVJ420P, YUV422P, YUVJ422P, YUV444P, YUVJ444P, NV12, NV16, NV21, YUV420P10, YUV422P10, YUV444P10, NV20, GRAY8, GRAY10 - Bit Depths: 8, 10, 12, 14
        Profiles: Baseline Profile (Level 6.2), Main Profile (Level 6.2), High Profile (Level 6.2), High 10 Profile (Level 6.2), High 4:2:2 Profile (Level 6.2), High 4:4:4 Predictive Profile (Level 6.2)

Info    Previous transcoding attempt failed. Falling back to software transcoding.

>>>>>>  FindVideoEncoder - MediaType: h264, UseHardwareCodecs: False, HWA-Mode: Advanced
Info    Checking: 'x264'
Info    Check successful - selecting 'x264'

>>>>>>  FindVideoDecoder - MediaType: hevc, UseHardwareCodecs: False, HWA-Mode: Advanced
Info    Checking: 'Automatic software decoder'
Info    Check successful - selecting 'Automatic software decoder'

>>>>>>  Processing Plan
        Name                                        CanDoInHW  WillDoInHW  Reason                                                 
        Automatic software decoder               >> False      False       Software Codec                                          
        VideoInput                               >> False      False       Not a hardware decoder                                  
        Scaling                                  >> False      False                                                               
        ColorConversion                          >> False      False                                                               
        SubtitleOverlay                          >> False      False                                                               
        VideoOutput                              >> False      False       Not a hardware encoder                                  
        x264                                     >> False      False       Software Codec                                          

>>>>>>  Video Processing Steps for [0:0]: H.265 (HEVC)
        Step                    HW-Context   Format       SW-Format           Size   Next
        HEVC                 >> -            yuv420p10    yuv420p10      3840x2160 >> scale
        scale                >> -            yuv420p10    yuv420p10      1920x1080 >> format
        format               >> -            yuv420p      yuv420p        1920x1080 >> overlay
        overlay              >> -            yuv420p      yuv420p        1920x1080 >> 

Some fellow Linux user will have to step in and hopefully give some insight.

@Q-Droid @Neminem @Lessaj

Edited by GrimReaper
Posted (edited)

Thanks Grim! In the meantime, I'm going to research that. I apparently did not have the nvidia-cuda-toolkit installed so I'm gonna get that added and take a look at some things. But definitely would appreciate anyone who can jump in to assist.

Edit: I unchecked that option to disable hardware subtitle overlay and installed the nvidia-cuda-toolkit to Ubuntu itself. After restarting the container, I'm seeing usage out of it now.

Edited by ryderjj89
Posted (edited)

Unfortunately I'm not particularly familiar with the correct way to pass the GPU to docker, I just run Emby natively on CentOS Stream 9, but what I would check from the host level at least is to ensure that you're using the Nvidia driver, I know they have a new open source driver but I still install the one from their website, and make sure nvidia-smi is working and reporting output. You should not need the nvidia-cuda-toolkit, cuda is included with the Nvidia driver.

image.png.e01f8dc1a0caf56901e6a2319ddb261f.png

 

Edited by Lessaj
  • Like 1
  • Thanks 1
Posted

Well need to ask if you rebooted after first, install of the card.

Some linux distro need a reboot to properly install new drivers.

  • Thanks 1
Posted
1 minute ago, Lessaj said:

Unfortunately I'm not particularly familiar with the correct way to pass the GPU to docker, I just run Emby natively on CentOS Stream 9, but what I would check from the host level at least is to ensure that you're using the Nvidia driver, I know they have a new open source driver but I still install the one from their website, and make sure nvidia-smi is working and reporting output. You should not need the nvidia-cuda-toolkit, cuda is included with the Nvidia driver.

image.png.d347a4ed75e1717dd2112b6f6f86e21d.png

Thanks. I wasn't sure if I needed it but some other posts mentioned running an ./nvcc --version command and that didn't work without the toolkit. I had seen a CUDA version before in nvidia-smi which also confused me.

But I am wondering if it's because I had disabled hardware accelerated subtitle overlay if that caused it to use software. I'll have to keep watching it.

Just now, Neminem said:

Well need to ask if you rebooted after first, install of the card.

Some linux distro need a reboot to properly install new drivers.

I had the machine off to install the new card. It was using a GTX 1650 before. I shutdown, removed the old card, installed the new one then updated the GPU that Emby could see through Docker with the UUID from nvidia-smi -L

I also used ubuntu-drivers install which says that all available drivers are already installed.

Posted

The disable hardware accelerated subtitle overlay option is enabled by default, but should not be preventing it since the error indicates unable to init cuda, no capable device.

What does nvidia-smi report on the host? Since you were using a 1650 before if that was working with the nvidia driver then unless it was really old that it didn't support the RTX 4000 that driver should still be working. I'm not sure if you can run nvidia-smi in the docker shell or not, I just haven't had a need to play around with docker containers. I'm thinking it's some kind of permission related issue when presenting the GPU to the docker container, but it's really just a wild guess.

Posted
1 minute ago, Lessaj said:

The disable hardware accelerated subtitle overlay option is enabled by default, but should not be preventing it since the error indicates unable to init cuda, no capable device.

What does nvidia-smi report on the host? Since you were using a 1650 before if that was working with the nvidia driver then unless it was really old that it didn't support the RTX 4000 that driver should still be working. I'm not sure if you can run nvidia-smi in the docker shell or not, I just haven't had a need to play around with docker containers. I'm thinking it's some kind of permission related issue when presenting the GPU to the docker container, but it's really just a wild guess.

This is what shows with nvidia-smi currently. Nothing is being transcoded right now as it looks to have finished. Also, I see you are using the 565.77 drivers. Would you say those are stable enough to update to?

image.png.a97acfa714369bcb82aa62ded357498a.png

Posted

Did you read thru the HW accel guide for Nvidia? It's step by step and states to not use the drivers from distro repos but to get them directly from Nvidia. 

  • Thanks 1
Posted

550.120 doesn't seem that old, it should support the card just fine. 565.77 seems fine to me but the VM does not run a DE so it's purely being used for transcoding purposes. I doubt having a DE running would affect docker using the GPU as well. I mostly picked it because it was the latest supported by nvidia-patch and I was updating my VM anyway so I had to rebuild the kernel modules regardless.

Posted
1 minute ago, Q-Droid said:

Did you read thru the HW accel guide for Nvidia? It's step by step and states to not use the drivers from distro repos but to get them directly from Nvidia. 

I probably read it but was also reading a lot of info at the time about installing drivers. I do see that a "NVIDIA Accelerated Graphics Driver for Linux-x86_64 (550.144.03)" is available here: https://www.nvidia.com/en-us/drivers/details/238858/

Posted

Can any other docker use you card ?

Posted
Just now, Neminem said:

Can any other docker use you card ?

Tbh no other container needs it.

Posted

Tdarr, fileflow, jellyfin, plex, whisper-ars, ebook2audiobook etc.

Posted
Just now, Neminem said:

Tdarr, fileflow, jellyfin, plex, whisper-ars, ebook2audiobook etc.

I don't use any of those, except whisper along with piper for HomeAssistant but that's through rhasspy/wyoming.

I did get the nvidia drivers installed from the nvidia site. I'll have to see next time I catch it transcoding. After the changes made throughout this thread though, I can at least say that I see NVENC/NVDEC icons in the cards for who's playing what. I wasn't seeing those before.

I really just don't want the CPU doing a bunch of work when this GPU is here and ready to be used lol.

Posted

If you're seeing the icon then it should be working now. :) The sample I looked at earlier had PGS subs, you could just try to play that in your browser and see if it ends up hardware transcoding or not since they don't support PGS. I'm actually curious with that option being disabled by default if it will use the GPU or not, I could swear that I still saw my GPU being used when burning in PGS subs before but now my library is 100% SRT so I'm not sure.

Posted

Yeah I'll keep an eye on it now and see. The fact I'm seeing those icons now is encouraging. I'll update again if I notice any issues. Thanks to all of you for your help so far!

  • 2 weeks later...
Posted (edited)

Wife put on a movie tonight and had to do transcoding and ran into the same issue. It's not transcoding with the GPU and gives me this same error.

"19:31:59.606 [AVHWDeviceContext @ 0x3ab74a40] cu->cuInit(0) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected"

Ffmpeg log is attached. It resorted to software transcoding instead. I'd like this to happen as least as possible.

EDIT:

I've followed the step here to add this systemd.unified_cgroup_hierarchy=0 to grub.

https://github.com/HaveAGitGat/Tdarr/issues/666#issuecomment-1269275184

Was also mentioned here: 

Will report back again later to see if it sticks.

ffmpeg-transcode-496f822c-011f-4fc8-a08d-b4db31f116b1_1.txt

Edited by ryderjj89
  • 2 weeks later...
Posted

Wanted to reply here on this.

Turns out that using that systemd.unified_cgroup_hierarchy=0 in grub breaks the memory stats since it uses cgroupfs instead of systemd.

What I did instead is set Emby as Privileged and will see if it will hold the GPU after a couple days. Unfortunately, changing the cgroup hierarchy is a bad trade-off because docker stats, glances, etc all can't show memory usage from the containers properly.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...