How to setup Nvidia HW acceleration in Ubuntu Docker?

I’d love some help. This used to work and now I don’t have hardware accel anymore. This is my d.c., other than the fact that I use to use plexpass tag, I am not sure what changed.

I

version: ‘3’
services:

plex:                                                                                                      
    container_name: plex                                                                                   
    environment:                                                                                           
        - TZ=America/New_York                                                                              
        - PLEX_CLAIM=claim-redacted                                                            
        - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'                              
        - TERM=xterm                                                                                       
        - LANG=C.UTF-8                                                                                     
        - LC_ALL=C.UTF-8                                                                                   
        - CHANGE_CONFIG_DIR_OWNERSHIP=true                                                                 
        - HOME=/config                                                                                     
    network_mode: host                                                                                     
    labels:                                                                                                
        - com.centurylinklabs.watchtower.enable=true                                                       
    volumes:                                                                                               
        - '/docker/plex/config:/config'                                                                    
        - '/docker/plex/temp:/transcode'                                                                   
        - '/mnt/video:/data'                                                                               
        - /config                                                                                          
        - /transcode                                                                                       
    restart: always                                                                                        
    logging:                                                                                               
        driver: json-file                                                                                  
        options:                                                                                           
            max-size: 50m                                                                                  
    image: plexinc/pms-docker:beta                                                                         
    devices:                                                                                               
      - /dev/dri:/dev/dri                                                                                  
    privileged: true

Well HW transcoding is a plexpass feature so that may be the case. Is the HW transcoding checkbox in the setting of plex? Try it with that tag.

Tried and it didn’t change a thing, I always had the HW checkbox, with beta and plexpass, which I believe are now the same binary.

Note that the nvidia smi test shows that nvidia docker is the default runtime and is working.

Open Plex in two windows in your browser and put on on the console in settings and play something thatll transcoder in the second and watch the console for red errors. You’ll have to scroll up when you see them. Let me know what they say. Also if you can run nvidia-smi dmon in ssh while you play, see what it does there.

I just got a P2000 and was wondering why it’s not working, and I see some folks posting that it’s not working for them now. I’ve definitely got all the libraries installed. Host is Debian/unstable with 410.104 driver. I can run nvidia-smi -L just fine inside the container:

GPU 0: Quadro P2000 (UUID: GPU-043e0ef5-5ae4-f73f-62bc-58de92490d57)

However, I found this error in the logs related to transcoding:

Apr 17, 2019 23:20:14.005 [0x7fee9effd700] Debug — Codecs: testing h264_nvenc (encoder)
Apr 17, 2019 23:20:14.007 [0x7fee9effd700] Error — [FFMPEG] - Cannot init CUDA

Apr 17, 2019 23:20:14.007 [0x7fee9effd700] Warning — avcodec_open2 returned -1313558101 for encoder 'h264_nvenc'

EDIT: I found I had nvidia-cuda-mps-server running on the host from messing around earlier. After killing it, things seem to be working. The giveaway was that nvidia-smi reported this process on the host but not in the container. And the command didn’t say that no processes were found.

EDIT2: I’m running the same command as posted by @cmuellersmith above. Make sure you have all the correct libraries installed on the host like libnvidia-encode and libnvcuvid. Make sure there aren’t any processes running on the host – you can check with nvidia-smi

Ok. I got forward and Got Docker to run. I can log in to PMS, but next… I got to web version (i look port from container) How to configure my PLEX server because it cannot find any. …?? My metadata, files and folders…

I tried today. The example container of smi is working correctly.
In my server log there is :
ERROR - [FFMPEG] - Cannot load libcuda.so.1

Is the drivers badly installed ? Is it something else?
I m running my container with —runtime=nvidia —/dev/dri/card0:/dev/dri/card0 —/dev/dri/...
Did I miss something?

So I’ve succeeded to resulve part of the problem.
I’ve reinstalled the driver trhough the ppa under ubuntu 18.04
I did pass the env variables to the container.

I have thos now at the beginning of a transcoding task:

Jun 22, 2019 19:10:19.828 [0x7fc8fe7fc700] DEBUG - Codecs: testing h264_nvenc (encoder)
Jun 22, 2019 19:10:19.829 [0x7fc8fe7fc700] VERBOSE - [FFMPEG] - Loaded Nvenc version 9.0
Jun 22, 2019 19:10:19.829 [0x7fc8fe7fc700] VERBOSE - [FFMPEG] - Nvenc initialized successfully
Jun 22, 2019 19:10:19.829 [0x7fc8fe7fc700] VERBOSE - [FFMPEG] - 1 CUDA capable devices found
Jun 22, 2019 19:10:19.829 [0x7fc8fe7fc700] VERBOSE - [FFMPEG] - [ GPU #0 - < GeForce GT 1030 > has Compute SM 6.1 ]
Jun 22, 2019 19:10:19.873 [0x7fc8fe7fc700] ERROR - [FFMPEG] - OpenEncodeSessionEx failed: unsupported device (2)
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] ERROR - [FFMPEG] - No NVENC capable devices found
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] VERBOSE - [FFMPEG] - Nvenc unloaded
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] WARN - avcodec_open2 returned -542398533 for encoder 'h264_nvenc'
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] DEBUG - MDE: Cannot direct stream video stream due to profile or setting limitations
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] DEBUG - Codecs: hardware transcoding: testing API vaapi
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] VERBOSE - [FFMPEG] - Opened VA display via DRM device /dev/dri/renderD128.
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] VERBOSE - [FFMPEG] - libva: VA-API version 1.1.0
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] VERBOSE - [FFMPEG] - libva: va_getDriverName() returns -1
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] ERROR - [FFMPEG] - libva: va_getDriverName() failed with unknown libva error,driver_name=(null)
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] ERROR - [FFMPEG] - Failed to initialise VAAPI connection: -1 (unknown libva error).
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] DEBUG - Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Input/output error
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] DEBUG - Scaled up video bitrate to 19599Kbps based on 1.500000x fudge factor.
Jun 22, 2019 19:10:19.896 [0x7fc8fe7fc700] DEBUG - Scaled maximum bitrate for resolution reduction to 8721Kbps.

so it recognize the GPU. (i know it’s low end but it’s just to test)
the libcuda error has disappeared. nvenc is not available on this card, that’s normal. but then is it nor mal that I don’t have libva driver?
or is it because 1030 is not supported or something like that?

okey now that I4ve digged a little more, libva is for intel decoding support
I’ve change from 1030 to 970 GTX and now it seems recognized as well and the trancoding seem hardware as stated by the dashboardwith the (hw)
and also according to nvidia-smi which gives the the information that a job of plex trancorder is busy at the moment while I’m testing a task.

But is it normal that the cpu doesn’t seem to offload so much to the GPU? the GPU is used at 2% and the cpu is at 20% from time to time ? seems really really bad as an offloading…
Is it because the GPU is not a good one ?

Jun 22, 2019 21:28:05.872 [0x7f98e0f9a700] DEBUG - Completed: [213.202.230.108:50099] 200 GET /library/metadata/188890?asyncAugmentMetadata=0&checkFiles=1&includeChapters=1&includeConcerts=1&includeExternalMedia=1&includeExternalMetadata=1&includeExtras=1&includeGeolocation=1&includeOnDeck=1&includePlexLinks=1&includePopularLeaves=1&includePreferences=0&includeRelated=0&includeRelatedCount=15&includeReviews=1 (13 live) TLS GZIP 7ms 1765 bytes (pipelined: 20)
Jun 22, 2019 21:28:05.872 [0x7f98db7fe700] VERBOSE - [FFMPEG] - Loaded Nvenc version 9.0
Jun 22, 2019 21:28:05.872 [0x7f98db7fe700] VERBOSE - [FFMPEG] - Nvenc initialized successfully
Jun 22, 2019 21:28:05.872 [0x7f98db7fe700] VERBOSE - [FFMPEG] - 1 CUDA capable devices found
Jun 22, 2019 21:28:05.872 [0x7f98db7fe700] VERBOSE - [FFMPEG] - [ GPU #0 - < GeForce GTX 970 > has Compute SM 5.2 ]
Jun 22, 2019 21:28:05.872 [0x7f98e0f9a700] DEBUG - Completed: [213.202.230.108:50097] 200 GET /library/metadata/188890?asyncAugmentMetadata=0&checkFiles=1&includeChapters=1&includeConcerts=1&includeExternalMedia=1&includeExternalMetadata=1&includeExtras=1&includeGeolocation=1&includeOnDeck=1&includePlexLinks=1&includePopularLeaves=1&includePreferences=0&includeRelated=0&includeRelatedCount=15&includeReviews=1 (13 live) TLS GZIP 6ms 1765 bytes (pipelined: 27)
Jun 22, 2019 21:28:05.912 [0x7f98db7fe700] VERBOSE - [FFMPEG] - supports NVENC
Jun 22, 2019 21:28:05.961 [0x7f98db7fe700] VERBOSE - [FFMPEG] - Nvenc unloaded
Jun 22, 2019 21:28:05.961 [0x7f98db7fe700] DEBUG - Codecs: hardware transcoding: testing API vaapi
Jun 22, 2019 21:28:05.961 [0x7f98db7fe700] VERBOSE - [FFMPEG] - Opened VA display via DRM device /dev/dri/renderD128.
Jun 22, 2019 21:28:05.961 [0x7f98db7fe700] VERBOSE - [FFMPEG] - libva: VA-API version 1.1.0
Jun 22, 2019 21:28:05.961 [0x7f98db7fe700] VERBOSE - [FFMPEG] - libva: va_getDriverName() returns -1
Jun 22, 2019 21:28:05.961 [0x7f98db7fe700] ERROR - [FFMPEG] - libva: va_getDriverName() failed with unknown libva error,driver_name=(null)
Jun 22, 2019 21:28:05.961 [0x7f98db7fe700] ERROR - [FFMPEG] - Failed to initialise VAAPI connection: -1 (unknown libva error).
Jun 22, 2019 21:28:05.962 [0x7f98db7fe700] DEBUG - Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Input/output error
Jun 22, 2019 21:28:05.962 [0x7f98db7fe700] DEBUG - Scaled up video bitrate to 12042Kbps based on 1.500000x fudge factor.
Jun 22, 2019 21:28:05.962 [0x7f98db7fe700] DEBUG - Codecs: testing h264_nvenc (encoder)

seems correct ? or should I do something else?

GT1030 doesn’t support NVENC. See https://developer.nvidia.com/video-encode-decode-gpu-support-matrix

Edit: I missed that you swapped it out for a gtx 970. Sorry.

@cmuellersmith (no problem don’t need to apologize) yup that’s what I’ve seen and that’s why I’ve changed to a 970.
What result do you have ? Should the cpu completely be offloaded or just some part? Or the trancoder choose maybe between the cpu and the gpu which one is the best?

On Linux the GPU cannot do the decoding currently, so your CPU will be dealing with that part so it will see some use before the GPU encodes. This was mentioned a few posts back in this thread.

Okey then I guess it’s that. I didn’t know it was that important in terms of scale.
Others operations should be considered as being processed by the cpu?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.