Do not use these nodes any more. Use the nodes at https://github.com/kijai/ComfyUI-LivePortraitKJ. They are more up to date and have all of the MPS support code now.
The original repo which works with Nvidia GPUs is here: https://github.com/kijai/ComfyUI-LivePortraitKJ
If you wish to incorporate these changes into your repo, feel free to open an issue and ask. The commits should be pretty clear, and I also label almost all changes with #HACK so a full text search will work too.
Please let me know if you decide to incorporate any of these changes into your LivePortrait implementation so I can direct people to you repository. I do not intend to maintain this repo.
Some operations are simply not supported on MPS and I didn't rewrite them. Most of my changes are just to .cuda
calls and that sort of thing. Many operations are still done on CPU, so don't expect awesome performance.
On my M1 macbook 32GB it takes around 30 seconds flat + 1 second per video frame. 32 frames is 57 seconds, 600 frames is 650 seconds. VRAM usage is not dependent on video length. I never started using swap, but make sure to open up activity monitor and check if you are on a lower-end model. I'm pretty sure it only took 9 GB VRAM but I didn't profile it carefully.
You may also need to run comfyui with PYTORCH_ENABLE_MPS_FALLBACK=1 python main.py
(you can also set the fallback as a env variable in other ways), where main.py is the comfyui file. It's possible that it is not necessary macbooks after M1.
ComfyUI nodes to use LivePortrait
chrome_GOS5jyhVAX.mp4
I have converted all the pickle files to safetensors: https://huggingface.co/Kijai/LivePortrait_safetensors/tree/main
They go here (and are automatically downloaded if the folder is not present) ComfyUI/models/liveportrait
Insightface is also required. If you have a working compile encironment, installing it can be as easy as:
pip install insightface
or for the portable version, in the ComfyUI_windows_portable -folder:
python_embeded/python.exe -m pip install insightface
If this fails (and it's likely), you can check the Troubleshooting part of the reactor node for alternative:
https://github.com/Gourieff/comfyui-reactor-node
For insightface model, extract this to ComfyUI/models/insightface/buffalo_l
:
https://github.com/deepinsight/insightface/releases/download/v0.7/buffalo_l.zip
Please note that insightface license is non-commercial in nature.