Problem: Plex lose GPU Transcoding on QNAP After Reboot

Server Version#: 1.40.4.8679

I have encountered a persistent issue with GPU transcoding in Plex on my QNAP TS-473A after each reboot. Despite configuring everything correctly, the GPU transcoding settings are not retained, and Plex defaults to auto mode, disabling hardware acceleration. Here is a detailed description of the problem, potential workarounds, and the root cause analysis.

Symptoms

  1. Hardware Transcoding Settings Not Retained:

• After every reboot, Plex loses the GPU transcoding settings.

• The settings revert to auto mode, and hardware acceleration is disabled.

  1. Manual Intervention Required:

• Each time the NAS is rebooted, I have to manually delete the HardwareDevicePath from the Preferences.xml file.

• After deleting the HardwareDevicePath, I can select the GPU in Plex transcoder settings.

• However, the problem reappears after the next reboot.

Technical Details

Here are the critical settings from the Preferences.xml file that need to be configured for GPU transcoding:

TranscoderUseHardware=“1”

TranscoderUseHardwareDecoding=“1”

HardwareAcceleratedCodecs=“1”

HardwareDevicePath=“10de:1f82:1462:8d92@0000:01:00.0”

HardwareAcceleratedTranscodeGpu=“1”

TranscoderH264BackgroundPreset=“veryslow”

TranscoderThrottleBuffer=“120”

TranscoderQuality=“1”

Steps to Reproduce the Problem

  1. Configure Plex to use GPU for hardware transcoding.

  2. Reboot the QNAP NAS.

  3. Observe that Plex loses the GPU transcoding settings and reverts to auto mode.

  4. Manually delete HardwareDevicePath from Preferences.xml.

  5. Restart NAS and reconfigure Plex to use GPU transcoding.

  6. Observe the same issue upon the next reboot.

Identified Cause

The issue appears to be that Plex starts too quickly after the NAS reboot, before the GPU drivers are fully initialized. This causes Plex to default to auto mode and disable hardware acceleration.

Workaround

A simple workaround that I found after multiple tests is to restart the Plex server manually after the QNAP system has fully booted. This ensures that the Nvidia drivers are loaded and Plex can recognize the GPU.

Proposed Solution

Plex should provide an option to either:

  1. Restart the Plex server with a delay after the QNAP system starts to ensure the Nvidia drivers are fully loaded.

  2. Introduce a built-in delay in the Plex server startup process to wait for the Nvidia drivers to initialize.

Conclusion

This issue seems to be a bug in the way Plex interacts with the QNAP NAS during startup. By ensuring the Plex server starts only after the Nvidia drivers are fully initialized, the GPU transcoding settings can be retained. Plex or QNAP should consider addressing this issue in future updates.

Screenshots

I have attached a few screenshots that illustrate the problem and the necessary configuration steps:

  1. Plex Transcoder Settings

  2. Hardware Transcoding Device

  3. Preferences.xml Settings

YouTube Explanation

Here is a [YouTube video: https://www.youtube.com/watch?v=RZL5hRZEEnU&t=637s] where someone explains the problem by changing the Hardware-Device-Path. However, this solution only works because the server is restarted, which does not address the root problem.

By following these steps, you can mitigate the issue of losing GPU transcoding settings on Plex after a QNAP NAS reboot. Hopefully PLEX will address this issue. There no way to contact PLEX directly…

So i use now a autorun.sh script to delay plex server start:

#!/bin/sh

# Plex-Server stop
/etc/init.d/plex.sh stop

# wait 10 minute (600 sec)
sleep 600

# Plex-Server start
/etc/init.d/plex.sh start

On older devices the delay has to be a lot more that 10 minutes. So go for 30 minutes. because qnap does initialize the gpu drive also really late. I just see after 5 minute when all has bee loaded, on my system the gpu will be initialized. So thats why plex think there is no gpu there on start! The GPU is also not visible in qnap sys info till the driver is loaded. So go for 10 minute or more !

But this also does not work correctly, i will test another codes and will report.

Need more info.

  1. GPU you’re using (GTX 1650?)
  2. Nvidia Drivers (both of them) are installed ?
  3. QTS version

Do you have the ability to change the “Auto” dropdown to a specific value?
(you should because that’s what PMS does now. It stores the PCI ID … not the device path from /dev/dri)

This is the first time anyone has raised this issue here (to my knowledge) since PMS switched from path to pci id.

QTS: 5.1.7.2770
GPU: GTX 1650
Yes, everything is installed.

As I mentioned, it works after restarting Plex App once the QNAP is fully booted up. I can see that the NVIDIA drivers initiate very late, so the Plex server app does not see the GPU when it starts. Later, the GPU will not recognized. Only after restarting the Plex server app does it see the GPU and I can select it. I am not the only one with this problem.

Can someone help me how to stop and start an app like over the gui?

The way with

# Plex-Server stop
/etc/init.d/plex.sh stop

# Plex-Server start
/etc/init.d/plex.sh start

are not enough, because the hole app has to be reinitiate to see the GPU.

Does someone have the right command line for me ?

EDIT:

I got another one but this are also not enough! Iam going crazy… :

#!/bin/sh

# Start other initializations here

(
  # Wait 10 minutes after startup
  sleep 600

  # Disable Plex Media Server
  /sbin/setcfg PlexMediaServer Enable FALSE -f /etc/config/qpkg.conf

  # Wait 30 seconds to ensure Plex is fully stopped
  sleep 30

  # Enable Plex Media Server
  /sbin/setcfg PlexMediaServer Enable TRUE -f /etc/config/qpkg.conf
) &

EDIT 2:

I GOT IT FINALLY :smiley: :
It is not enough to stop the App we have also to stop the Plex Server service also before. SO I prevent the Plex Server to initialize that there are no GPU and then active the Plex Server after 5 minutes again when qnap hopefully has fully initialize the GPU. ITS DONE.

#!/bin/sh

(
  # Stop the Plex Media Server
  sudo /share/CE_CACHEDEV1_DATA/.qpkg/PlexMediaServer/plex.sh stop

  # Disable Plex Media Server App
  /sbin/setcfg PlexMediaServer Enable FALSE -f /etc/config/qpkg.conf

  # Wait 5 minutes
  sleep 300

  # Enable Plex Media Server App
  /sbin/setcfg PlexMediaServer Enable TRUE -f /etc/config/qpkg.conf

  # Start the Plex Media Server
  sudo /share/CE_CACHEDEV1_DATA/.qpkg/PlexMediaServer/plex.sh start
) &

SO plz Plex or QNAP Fix this issue. THX !

We have the following:

  1. TS-877
  2. GT-1050
  3. QTS 5.1.7.2770
  4. (QNAP provided) Nvidia GPU Driver 5.1.0.0822
  5. (QNAP provided) NvKernelDriver 5.1.7.2770

This configuration has never failed.

The script relies on gpuhal_app to tell it the status of installed and available GPUs.

It makes a list of what’s installed.
For each in the list (even if one),
– Make certain the drivers for it are installed
– Make certain it’s in QTS mode (available)

If those conditions are true, it adds the libraries (Nvidia Drivers) to PMS start. (from /opt/NVIDIA_GPU_DRV)

The script has never failed to startup correctly since I wrote plex.sh

This is a QNAP OS-level problem.

Rather than you waiting 5 minutes, you can poll gpuhal_app to monitor for it.
QNAP will probably want to know this info too.

NOTE: Looks like QNAP’s driver is still ‘Release Candidate’ status. (RC-2)

NVIDIA GPU Kernel Driver
5.2.0.2802 build 20240620
Release Candidate 2	2024-06-28	
Global
USA
Europe

5.1.7.2770 looks to be ok

NVIDIA GPU Kernel Driver
5.1.7.2770 build 20240520	2024-05-21	

The problem is, when the QNAP starts, the GPU is not initialized by QNAP. It takes about 1-3 minutes until the GPU is initialized. So, Plex doesn’t see the GPU when it starts, because it starts earlier. Plex does not grab new GPU information once it’s loaded; it only checks for a GPU during startup. This is why a restart for the PLEX Server App is necessary on my system. I does not wait by myself, I run this script with autorun.sh on my QNAP NAS.

Bildschirmfoto 2024-07-12 um 17.00.12

There is nothing we can do if the card isn’t being initialized and made available by the QNAP kernel & drivers

You must work with QNAP on this part.

If you’d like, I can write a routine for you which will wait for the card to become available then enable and start PMS.

Would that be helpful?

Yes, you could write a routine for me, but I think it might cause issues if I let it run permanently. If no GPU is installed, the PlexApp would not start at all. I think there might be a solution on your end. Relying on QNAP might not be the solution, as they will say the GPU is initialized and available to the system at time X. Therefore, Plex would need to query the system for available devices every 5 or 10 minutes. If the system lists a GPU, it should be restored, activated, or updated in Plex settings. The current setup does not do this. Plex initializes graphics cards only at startup.

Additionally, once the GPU is initialized by QNAP, it is listed in the PCI Express-connected devices in the console. Therefore, Plex should be able to detect it. I think this is actually a configuration or update issue with the Plex server.

I hope you understand what I mean. Maybe you can find a way to initialize the GPU and restore the settings while the system is running. The GPU is recorded in the Preferences XML. Therefore, Plex should only need to check every X minutes if the GPU is present or not. Additionally u can add a button: “search for new devices” so Plex will search for GPUs and restore or add them. Or Plex can have a watchdog thats detects all changes in PCIe Devices for GPUs.

I thought about this.

If we cannot rely on QNAP to initialize their hardware before starting PMS – Game Over. Period.

I cannot replicate this on any of our QNAP NAS machines.

I understand what you mean but this goes entirely against how QTS works
– Thunderbolt is P&P; but your NAS doesn’t have that.
– PCIe internal devices are only probed and initialized at kernel load+init.
– They are visible to PMS on a PCIe bus probe when it starts (by PCIe ID) when PMS starts independent of whether or not it’s actually available or usable when the transcode is needed.

Your statement that it forgets the settings is what’s disturbing me the most.

At this point, I need to see this happening.
Please do the following:

  1. Verify Plex DEBUG logging is enabled (settings - server - general - show advanced)
  2. Nvidia card is in QTS mode (Control Panel - Hardware - GPU)
  3. restart PMS in app center
  4. Let it run for a minute or two
  5. Restart the NAS
  6. Allow it to come up fully ready (CPU shows idle)
  7. Open PMS
  8. Download the PMS server logs ZIP file
  9. Attach that ZIP file here

There is a possible issue here which I’ve already addressed with RESTARTING PMS after process crashes. That fix (written in March) should have been in 1.40.4 but got lost somewhere in Engineering. I can give you the plex.sh to manually install.

I opened a ticket regarding this about a year ago.
Plex would start before the Nvidia drivers were loaded.
According to QNAP, this happens because plex was installed prior to the Nvidia drivers, which in my case is true as I added the Nvidia card later on.
Their solution was catastrophic to say the least.
They asked me to uninstall plex then reinstall it.
As you understand this would result in a loss of the database and all settings, and would be catastrophic !!
I stopped responding to the ticket from then on.
What I now do, when restarting the NAS, is to stop-start plex after the device has finished booting.

@broncogr @Zorastman

Chatting with my fellow QTS guy (he introduced me to QNAP),
we have an idea on how to get around QTS’s failing
(Yes, this is QTS & App Center failing)

  1. We assign a package start (RC) order. QTS is ignoring it.
    (Per their documentation – which is where the fault is clear)

  1. Because you installed the GPU after having a running PMS – It all went out the window.

  2. HACK of a solution (without uninstalling PMS)

  • Move PMS to the bottom of /etc/config/qpkg.conf so it is the last application to start (AFTER the Nvidia drivers)

Understanding this, your statement

Here’s the hack (PLEASE do submit a ticket to QNAP again. We will do the same)

  1. Stop PMS
  2. Get into the shell
  3. sudo bash (must be root)
  4. cd /etc/config
  5. cp qpkg.conf qpkg.conf.BAK
  6. vi qpkg.conf
  7. Now for the vi commands:
  8. Find the [PlexMediaServer] block - 19dd (delete 19 lines)
  9. Go to the last line of the file :$ (hit enter after the $)
  10. Add a blank line o (open) then esc (escape) to stop appending
  11. Paste the 19 deleted Plex lines p

Your vi window should look like this (PMS is the new last app in the package list):

Sys_App = 2
Enable = TRUE

[PlexMediaServer]
Status = complete
Name = PlexMediaServer
Build = 20240712
Display_Name = Plex Media Server
Version = 1.40.5
Author = Plex Build Team
QPKG_File = PlexMediaServer.qpkg
Date = 2024-07-12
Shell = /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/plex.sh
Volume_Select = 3
Install_Path = /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer
WebUI = /web
Web_Port = 32400
RC_Number = 101
Timeout = 10,30
Enable = TRUE
FW_Ver_Min = 4.3.0

~
~
  1. Save and exit (:wq)
  2. Start Plex in App Center (make sure that works)
  3. Restart the QNAP (yes, that’s the delay)
  • The Nvidia should init before PMS
  • PMS should find it with ease
  1. IF you want to tweak it further but shouldn’t be necessary, increase the RC_Number to 200 and repeat the process.

ASK if questions

2 Likes

@broncogr

Have you been able to make the edits ?

Not yet.
Probably will have some time tomorrow
Thanks

1 Like

As Chuck already mentioned in his steps, do remember to make a backup of the file before editing :wink:

1 Like

I am on QuTS hero
Here is what the PlexMediaServer entry looks like

How do I proceed ?

Ok… very simple.

  1. Starting at the [PlexMediaServer] line
  2. Cursor-down until you get to the bottom of the block (right before the [SecurityCounselor], counting as you go
    (We want to count the number of lines in the block)
  3. Once you’ve done that
  4. Go back to the [PlexMediaServer] line
  5. Now we’re going to delete the block.

Looking at it, i count 20 lines in the [PlexMediaServer] block.
Confirmed ?

If it’s 20, instead of my 19, then you’ll substitute 20dd instead of my 19dd

I have been working on a way to automate this for everyone.
I’ve tested it here but am still skeptical.

The automation does all the edits for you.

The command line would be:

  1. Copy the file to temp and test & verify it
cp /etc/config/qpkg.conf /tmp
sed -i '/\[PlexMediaServer\]/,/FW_Ver_Min[^$]*$/{H;d};$g' /tmp/qpkg.conf
  1. After the edit. examine /tmp/qpkg.conf & compare with /etc/config/qpkg.conf.
    You should see NO DAMAGE to others… AND PlexMediaServer at the bottom

  2. Next, we repeat the command on the real /etc/config/qpkg.conf

sed -i '/\[PlexMediaServer\]/,/FW_Ver_Min[^$]*$/{H;d};$g' /etc/config/qpkg.conf
1 Like

I am rebooting the server as I couldnt get into Vi anymore…

Can we get this to pm.
I can give you remote access if you want

We can do a remote desktop sharing (anydesk) works well.
and hook up mobile-mobile or google meet (audio)

That way we can talk and do together

(Local time is 02:20am)