Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling vaapi #37

Closed
hroman73 opened this issue Jun 9, 2022 · 8 comments
Closed

Enabling vaapi #37

hroman73 opened this issue Jun 9, 2022 · 8 comments

Comments

@hroman73
Copy link

hroman73 commented Jun 9, 2022

I try to enable vaapi on both sonarr-sma and radarr-sma but get the same error in the log:

E: Package 'libva' has no installation candidate

when i check ffmpeg -hwaccel i get:

ffmpeg: error while loading shared libraries: libva.so.2: cannot open shared object file: No such file or directory

How can I confirm it is utilizing the gpu when re-encoding?

@mdhiggins
Copy link
Owner

Did you build a vaapi supporting version of the container?

@mdhiggins
Copy link
Owner

mdhiggins commented Jun 9, 2022

You'll also need to pass your VAAPI device to the docker container

    devices:
      - /dev/dri/renderD128:/dev/dri/renderD128

Device path may vary depending on your system

Also using just --hwaccel vaapi will only get you a decoder, you'll also need to choose a VAAPI enabled encoder as well for encoding

Getting full hardware level decoder to encoder passing without software abstraction gets even more complicated, see the HWAccel ffmpeg guide and the numerous issues on the main SMA repo for that but it will require you setting pretty much all the hwaccel related options

The radarr-sma repo also has some issues regarding VAAPI setup you can browse through

@hroman73
Copy link
Author

Yes I did both build as well as pass /dev/dri to the container...here is part of the docker-compose.yaml for Sonarr:

sonarr:
hostname: sonarr
container_name: sonarr
build:
context: https://github.com/mdhiggins/sonarr-sma.git#build
args:
sonarr-tag: develop
ffmpeg_tag: 4.4-vaapi2004
depends_on:
- nzbget
volumes:
- sonarr:/config
- downloads:/downloads
- sma:/usr/local/sma/config
- type: volume
source: tv
target: /tv
volume:
nocopy: true
environment:
- TZ=America/New_York
- PUID=1000
- PGID=1000
- SMA_PATH=/usr/local/sma
- SMA_UPDATE=true
- UMASK_SET=022
ports:
- 8989:8989
restart: unless-stopped
devices:
- /dev/dri:/dev/dri

@mdhiggins
Copy link
Owner

I wonder if this is an issue of mixing mono and Ubuntu. I believe the developer branch of Sonarr has migrated to mono but the VAAPI build of FFMPEG is Ubuntu.

Does rolling back to an earlier tag of Sonarr that's still on Ubuntu fix the issue by chance?

@hroman73
Copy link
Author

I switched the tag to latest and have the same issue...

E: Sub-process /usr/bin/dpkg returned an error code (1)
E: Package 'libva' has no installation candidate

@mdhiggins
Copy link
Owner

It looks like the 'latest' tag has also been rebased to mono at this point (as of April) so that switch back to latest probably didn't change anything, feel free to correct me if I'm mistaken here

mdhiggins/radarr-sma#34 (comment)

One option that might work is to not build FFMPEG or use the jrottenberg FFMPEG at all and instead use mono and pull FFMPEG from the repo, see that link for a radarr example but Sonarr should work too (at least on the develop tag which is definitely on mono)

@hroman73
Copy link
Author

i've done the update and the libva error is gone, how would i confirm that ffmpeg is using vaapi?

@mdhiggins
Copy link
Owner

mdhiggins commented Jun 11, 2022

You would have to look at your CPU/GPU usage during a job being run and then compare it with the VAAPI options turned off. Remember, adding the hwaccel parameter only turns on the decoder not the encoder though and decoding isn't all that intensive and not all input codecs will have a hw decoder. For the most performance gains I would include a VAAPI encoder as well (by adding it to the video codec list as your first codec)

https://unix.stackexchange.com/questions/525473/vaapi-usage-monitoring

h264vaapi and h265vaapi are the most common encoder choices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants