occ-ai / obs-backgroundremoval

An OBS plugin for removing background in portrait images (video), making it easy to replace the background when recording or streaming.
GNU General Public License v2.0
2.68k stars 185 forks source link

ROCm support #545

Open umireon opened 4 months ago

umireon commented 4 months ago

I've added the documentation for ROCm-supported build.

payom commented 4 months ago

Can't comment on the build instructions as I don't operate in an Ubuntu environment. However, with the new changes, the plugin builds successfully on my machine. Upon installation, OBS loads the plugin and evidently is making use of the GPU when selecting "GPU - TensorRT" in the settings (which I would recommend to change to avoid confusion).

With the SINet, Mediapipe and PPHumanSeg models, the plugins runs perfectly in my environment. - I can't discern any difference when switching between running over the CPU or the GPU. Unfortunately, the remaining segmentation models don't work. When using the Selfie Segmentation model, I get garbage, and my OBS application outright crashes when selecting either Robust Video Matting or TCMonoDepth due to a "memory access fault" in the HIP backend.

My environment:

umireon commented 4 months ago

@payom Thank you for your feedback! It would be so helpful for us if you posted the whole part of the OBS log when OBS crashed. You can get OBS logs and crash reports from the OBS help menu.

payom commented 4 months ago

Here's the log while running OBS with verbose logging enabled

Unfortunately, the crash doesn't appear to have been captured in the log.

Setting the MIOPEN_ENABLE_LOGGING_CMD flag and running OBS from my terminal, I also get this print out which is what I used to identify what crashed in my earlier message

libDeckLinkAPI.so: cannot open shared object file: No such file or directory
MIOpen(HIP): Command [Pooling_logging_cmd] ./bin/MIOpenDriver pool -M 0 --input 1x3x192x192,110592x36864x192x1 -y 2 -x 2 -p 0 -q 0 -v 2 -u 2 -m avg -F 1 -t 1
MIOpen(HIP): Command [Pooling_logging_cmd] ./bin/MIOpenDriver pool -M 0 --input 1x3x96x96,27648x9216x96x1 -y 2 -x 2 -p 0 -q 0 -v 2 -u 2 -m avg -F 1 -t 1
MIOpen(HIP): Command [Pooling_logging_cmd] ./bin/MIOpenDriver pool -M 0 --input 1x3x48x48,6912x2304x48x1 -y 2 -x 2 -p 0 -q 0 -v 2 -u 2 -m avg -F 1 -t 1
MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver conv -n 1 -c 3 -H 192 -W 192 -k 16 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 -m conv -g 1 -F 1 -t 1
MIOpen(HIP): Command [LogCmdConvolution] ./bin/MIOpenDriver conv -n 1 -c 3 -H 192 -W 192 -k 16 -y 3 -x 3 -p 1 -q 1 -u 2 -v 2 -l 1 -j 1 -m conv -g 1 -F 1 -t 1
MIOpen(HIP): Command [LogCmdFindConvolution] ./bin/MIOpenDriver conv -n 1 -c 16 -H 96 -W 96 -k 16 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 -m conv -g 16 -F 1 -t 1
MIOpen(HIP): Command [LogCmdFusion] ./bin/MIOpenDriver CBAInfer -F 4 -n 1 -c 16 -H 96 -W 96 -k 16 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1 -g 16 -S 0
Memory access fault by GPU node-1 (Agent handle: 0x5bad78b80150) on address 0x7f69b5200000. Reason: Page not present or supervisor privilege.
umireon commented 4 months ago

@royshil How should we implement ROCm support?

royshil commented 4 months ago

i think we need to research ROCm execution provider outside of the plugin to see why it behaves in this way with these particular models, and not with others. Unfortunately i can't do it on my machines, since i don't have AMD GPUs.

the other option would be to switch away from ONNX Runtime to a different neural net framework that has more seemless support for the various accelerator vendors like Nvidia, AMD, Intel, DirectX etc.