I
Immichβ€’2y ago
SamTheRuby

Trying Out GPU Transcoding

Hi I wanted to know if there is any way to try the GPU transcoding feature early. I know it's still in development but I have about 10,000 videos I want to import into immich and if I would have to CPU transcode them it would take way too long. I would really appreciate any help anyone can give me πŸ™‚
77 Replies
bo0tzz
bo0tzzβ€’2y ago
You could try to use the dev image for your microservices container ghcr.io/immich-app/immich-server:pr-3171, but absolutely zero guarantee - it could horribly malfunction and garble all your videos or something like that, so at your own peril πŸ˜›
SamTheRuby
SamTheRubyOPβ€’2y ago
so I just do a docker pull command? how do I set that up? will it automatically use my nvidia gpu?
bo0tzz
bo0tzzβ€’2y ago
I think so But it's probably better to wait until this is released with actual documentation and such ;)
SamTheRuby
SamTheRubyOPβ€’2y ago
any eta?
bo0tzz
bo0tzzβ€’2y ago
nope
SamTheRuby
SamTheRubyOPβ€’2y ago
ah ok I may have to try it since I'm mostly importing my videos not only using it as my storage, I can at least let you know how it goes.
brighteyed
brighteyedβ€’2y ago
It is hard to try it on your Immich instance. As I remember you need (1) to modify docker-compose.yml (see PR). Since hardware acceleration is disabled by default, you (2) will need also to pull the web image to change this setting
SamTheRuby
SamTheRubyOPβ€’2y ago
isin't it like 2 lines in the docker compose file
SamTheRuby
SamTheRubyOPβ€’2y ago
No description
brighteyed
brighteyedβ€’2y ago
Not sure, but I believe also a couple of lines in the devices section
SamTheRuby
SamTheRubyOPβ€’2y ago
of the docker compose file?
brighteyed
brighteyedβ€’2y ago
Yep
SamTheRuby
SamTheRubyOPβ€’2y ago
@brighteyed @bo0tzz In the docker compose file Im assuming I replace the immich-microservices line
immich-microservices:
container_name: immich_microservices
image: immich-microservices:latest
immich-microservices:
container_name: immich_microservices
image: immich-microservices:latest
with immich-server:pr-3171 or do I replace this part?
container_name: immich_server
image: immich-server-dev:latest
container_name: immich_server
image: immich-server-dev:latest
brighteyed
brighteyedβ€’2y ago
Both immich-server and immich-microservices containers use immich-server image
SamTheRuby
SamTheRubyOPβ€’2y ago
so I replace both of the images with immich-server:pr-3171? @brighteyed @bo0tzz
brighteyed
brighteyedβ€’2y ago
I would suggest to setup a separate Immich instance to try this experimental feature
SamTheRuby
SamTheRubyOPβ€’2y ago
it does not look like the gpu is in use, this is the output of nvidia-smi +---------------------------------------------------------------------------------------+ | NVIDIA-SMI 535.54.03 Driver Version: 535.54.03 CUDA Version: 12.2 | |-----------------------------------------+----------------------+----------------------+ | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+======================+======================| | 0 NVIDIA GeForce GTX 1050 Ti Off | 00000000:03:00.0 Off | N/A | | 28% 34C P0 N/A / 75W | 0MiB / 4096MiB | 0% Default | | | | N/A | +-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=======================================================================================| | No running processes found |
SamTheRuby
SamTheRubyOPβ€’2y ago
here are my docker-compose.yml hwaccel.yml and .env files
SamTheRuby
SamTheRubyOPβ€’2y ago
here is my .env file as a txt file so it does not need to be downloaded
SamTheRuby
SamTheRubyOPβ€’2y ago
only thing I changed in the .env is the upload location
Kryptonian
Kryptonianβ€’2y ago
It also needs to be enabled in settings on Immich
SamTheRuby
SamTheRubyOPβ€’2y ago
It is
SamTheRuby
SamTheRubyOPβ€’2y ago
No description
No description
No description
No description
sogan
soganβ€’2y ago
thank you for testing this. the pr has been mostly done but there's so many hardware configurations it's hard to know if it will work for everyone can you share your hwaccel.yml as well as the microservices logs? oh, i see you posted it and it looks good. since you have nvenc enabled in settings, i'm guessing the hwaccel is failing and it's falling back to software do you have nvidia container runtime installed on this server?
SamTheRuby
SamTheRubyOPβ€’2y ago
no I did not, let me see if that fixes the issue @sogan still no luck but I see this in the logs for the microservers container
[Nest] 1 - 07/21/2023, 4:27:54 PM  ERROR [MediaService] An error occurred while configuring transcoding options: Error: ENOENT: no such file or directory, scandir '/dev/dri'
[Nest] 1 - 07/21/2023, 4:27:54 PM  ERROR [MediaService] An error occurred while configuring transcoding options: Error: ENOENT: no such file or directory, scandir '/dev/dri'
and I see that none of the videos are actually being transcoded
sogan
soganβ€’2y ago
Ah, I think this is a bug. Can you add this to your hwaccel.yml and redeploy your microservices container?
devices:
- /dev/dri:/dev/dri
devices:
- /dev/dri:/dev/dri
SamTheRuby
SamTheRubyOPβ€’2y ago
sure one sec THAT WORKED!!!
sogan
soganβ€’2y ago
Awesome!
SamTheRuby
SamTheRubyOPβ€’2y ago
No description
SamTheRuby
SamTheRubyOPβ€’2y ago
TYSM!
sogan
soganβ€’2y ago
Glad I could help! Also if you have an Intel CPU, would you be able to try Quick Sync as well? You don't need to change the hwaccel.yml
SamTheRuby
SamTheRubyOPβ€’2y ago
I dont have a linux setup but I have a windows pc would it work with that? If not I may be able to install linux on it on sunday
sogan
soganβ€’2y ago
Ah, I think quick sync doesn't support WSL2 unfortunately so it would need to be on linux lmk if you do end up trying it since it's the only backend I can't test atm
SamTheRuby
SamTheRubyOPβ€’2y ago
ah ok Ill gladly try testing when I have a chance I also saw that VP9 is not supported on NVEC, doesn't nvidia support VP9 encode and decode? nope nvm sorry just saw that only decoding is supported not encdoing
sogan
soganβ€’2y ago
yeah I thought it did but unfortunately not. they basically skipped over vp9 since the latest ones support av1.
SamTheRuby
SamTheRubyOPβ€’2y ago
yeah, shame but I guess expected I can also pretty much confirm that most amd gpus and APUS do not support VP9 encode @sogan do you know what command I should use to check if Intel quicksync is being used?
sogan
soganβ€’2y ago
you can check the microservices logs. if the -vcodec part says h264_qsv or hevc_qsv and there's no errors, it's using qsv
martabal
martabalβ€’2y ago
@sogan tried it and it works well, nice work ! One concern, all theses hardware acceleration are available for arm devices too ?
Kryptonian
Kryptonianβ€’2y ago
No arm support for hwaccel
sogan
soganβ€’2y ago
not for arm itself, but if the device has a gpu then it should work e.g. jetson
Kryptonian
Kryptonianβ€’2y ago
Eg compute module 4 with an external GPU.
SamTheRuby
SamTheRubyOPβ€’2y ago
@sogan do you also want me to test?
sogan
soganβ€’2y ago
if you can it’d be great. i made a few changes so qsv should work
SamTheRuby
SamTheRubyOPβ€’2y ago
@sogan I get this error:
sogan
soganβ€’2y ago
do you have this uncommented in the hwaccel.yml?
devices:
- /dev/dri:/dev/dri
devices:
- /dev/dri:/dev/dri
SamTheRuby
SamTheRubyOPβ€’2y ago
yes I do
version: "3.8"

# Hardware acceleration for transcoding - Optional
# This is only needed if you want to use hardware acceleration for transcoding.
# Depending on your hardware, you should uncomment the relevant lines below.

services:
hwaccel:
devices:
- /dev/dri:/dev/dri # If using Intel QuickSync or VAAPI
# volumes:
# - /usr/lib/wsl:/usr/lib/wsl # If using VAAPI in WSL2
# environment:
# - NVIDIA_DRIVER_CAPABILITIES=all # If using NVIDIA GPU
# - LD_LIBRARY_PATH=/usr/lib/wsl/lib # If using VAAPI in WSL2
# - LIBVA_DRIVER_NAME=d3d12 # If using VAAPI in WSL2
# deploy: # Uncomment this section if using NVIDIA GPU
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities: [gpu]
version: "3.8"

# Hardware acceleration for transcoding - Optional
# This is only needed if you want to use hardware acceleration for transcoding.
# Depending on your hardware, you should uncomment the relevant lines below.

services:
hwaccel:
devices:
- /dev/dri:/dev/dri # If using Intel QuickSync or VAAPI
# volumes:
# - /usr/lib/wsl:/usr/lib/wsl # If using VAAPI in WSL2
# environment:
# - NVIDIA_DRIVER_CAPABILITIES=all # If using NVIDIA GPU
# - LD_LIBRARY_PATH=/usr/lib/wsl/lib # If using VAAPI in WSL2
# - LIBVA_DRIVER_NAME=d3d12 # If using VAAPI in WSL2
# deploy: # Uncomment this section if using NVIDIA GPU
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities: [gpu]
sogan
soganβ€’2y ago
hmm, this is tricky. there are two possibilities i'm thinking here: 1. the host system is missing a dependency for something, possibly libmfx or mesa? these are installed in the container but maybe there's something that needs to be installed in the host as well? 2. the qsv device is actually not renderD128 for this system but maybe something else? could you try the same settings with vaapi? it will internally use quick sync if it's available. also share: 1. the cpu model and whether this server has a gpu. 2. the output of ls /dev/dri on this server btw i managed to get the same error on another machine i tested. the pr has been updated to fix this issue so it should work now.
abbhishek_chakra
abbhishek_chakraβ€’2y ago
I was thinking of trying out hw transcoding. But my system has an i3 4010u. As per specs it supports intel quick sync but as per documentation min 7th gen intel is needed. So just wanted to confirm if there is any way I can enable it?
sogan
soganβ€’2y ago
You can enable it and see if it works. Let me know how it goes if you do
SamTheRuby
SamTheRubyOPβ€’2y ago
@sogan Im sorry for the delay, Im now on the latest version and when I try to transcode this happens:
SamTheRuby
SamTheRubyOPβ€’2y ago
this is my hwaccel.yml file:
version: "3.8"

# Hardware acceleration for transcoding - Optional
# This is only needed if you want to use hardware acceleration for transcoding.
# Depending on your hardware, you should uncomment the relevant lines below.

services:
hwaccel:
# devices:
# - /dev/dri:/dev/dri # If using Intel QuickSync or VAAPI
# volumes:
# - /usr/lib/wsl:/usr/lib/wsl # If using VAAPI in WSL2
environment:
- NVIDIA_DRIVER_CAPABILITIES=all # If using NVIDIA GPU
# - LD_LIBRARY_PATH=/usr/lib/wsl/lib # If using VAAPI in WSL2
# - LIBVA_DRIVER_NAME=d3d12 # If using VAAPI in WSL2
deploy: # Uncomment this section if using NVIDIA GPU
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
version: "3.8"

# Hardware acceleration for transcoding - Optional
# This is only needed if you want to use hardware acceleration for transcoding.
# Depending on your hardware, you should uncomment the relevant lines below.

services:
hwaccel:
# devices:
# - /dev/dri:/dev/dri # If using Intel QuickSync or VAAPI
# volumes:
# - /usr/lib/wsl:/usr/lib/wsl # If using VAAPI in WSL2
environment:
- NVIDIA_DRIVER_CAPABILITIES=all # If using NVIDIA GPU
# - LD_LIBRARY_PATH=/usr/lib/wsl/lib # If using VAAPI in WSL2
# - LIBVA_DRIVER_NAME=d3d12 # If using VAAPI in WSL2
deploy: # Uncomment this section if using NVIDIA GPU
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
SamTheRuby
SamTheRubyOPβ€’2y ago
this is my docker compose file:
SamTheRuby
SamTheRubyOPβ€’2y ago
this is my .env file
SamTheRuby
SamTheRubyOPβ€’2y ago
sogan
soganβ€’2y ago
can you share the host os and version (e.g. Ubuntu 23.04)?
SamTheRuby
SamTheRubyOPβ€’2y ago
yes it's ubuntu 23.04 server
sogan
soganβ€’2y ago
lol good guess try changing this line capabilities: [gpu] to capabilities: [gpu,video]
SamTheRuby
SamTheRubyOPβ€’2y ago
hmm didn't seem to fix it @sogan
SamTheRuby
SamTheRubyOPβ€’2y ago
SamTheRuby
SamTheRubyOPβ€’2y ago
^ from the immich_microservices container ^
sogan
soganβ€’2y ago
that did seem to fix the issue you had before, but this error is really weird. it normally means the video is corrupt. does software transcoding work?
SamTheRuby
SamTheRubyOPβ€’2y ago
let me try
SamTheRuby
SamTheRubyOPβ€’2y ago
SamTheRuby
SamTheRubyOPβ€’2y ago
this is without the gpu
sogan
soganβ€’2y ago
yeah something's up with that video. if you can download 78b41b5a-aeef-4026-b17d-97901e586f36.mp4 to your pc, try playing it. if it plays, this is a bug with ffmpeg/ffprobe. if it doesn't, the video is corrupt.
SamTheRuby
SamTheRubyOPβ€’2y ago
ok but isin't it happening with all the videos with the gpu
sogan
soganβ€’2y ago
i don't know how many of the videos it affects in this library but i think the logs you shared are for one video but there are several that fail in the last logs you showed so any of those would also work for testing overall though, this doesn't seem to be a hardware transcoding problem at this point. the error is about it not being able to decode the video, but decoding is always software-based (only encoding is hardware accelerated).
SamTheRuby
SamTheRubyOPβ€’2y ago
oh ok thanks, Ill try to renable the gpu, leave it overnight and see what happens
SamTheRuby
SamTheRubyOPβ€’2y ago
@sogan still getting issues with gpu enabled it seems like every video is failing to transcode:
SamTheRuby
SamTheRubyOPβ€’2y ago
No description
SamTheRuby
SamTheRubyOPβ€’2y ago
No description
SamTheRuby
SamTheRubyOPβ€’2y ago
No description
SamTheRuby
SamTheRubyOPβ€’2y ago
here are my settings
SamTheRuby
SamTheRubyOPβ€’2y ago
this is the bottom of the error in the immich_microservices container:
sogan
soganβ€’2y ago
i think this is actually a bug with fluent-ffmpeg in node.js
sogan
soganβ€’2y ago
GitHub
mp4 buffer as input fails to convert a video Β· Issue #932 Β· fluent-...
Version information fluent-ffmpeg version: 2.1.2 ffmpeg version: 4.1.3 OS: macos Code to reproduce A buffer comes from browser to node.js read by FileReader. // videoArrayBuffer is a buffer coming ...
sogan
soganβ€’2y ago
what a weird bug

Did you find this page helpful?