ffmpeg using cpu to encode on convert

Getting errors or found a bug when converting faces from a trained model? Post about them here


Forum rules

Read the FAQs and search the forum before posting a new topic.

This forum is for reporting errors with the Convert process. If you want to get tips, or better understand the Convert process, then you should look in the Convert Discussion forum.

Please mark any answers that fixed your problems so others can find the solutions.

Locked
User avatar
wuthapn
Posts: 5
Joined: Sun Aug 02, 2020 2:05 am
Been thanked: 2 times

ffmpeg using cpu to encode on convert

Post by wuthapn »

When I run a convert, ffmpeg does not detect a GPU and uses the CPU to encode the content ( software not hardware encoding ). This makes the final step take a long time. Is there an option I am missing or a reason why ffmpeg decides to use software cpu based encoding, or am I missing something else.

GTX Titan X ( maxwell )
1080 Ti
AMD 1950x threadripper

08/01/2020 20:59:17 INFO Loading Writer from Ffmpeg plugin...
08/01/2020 20:59:17 WARNING No GPU detected. Switching to CPU mode

User avatar
bryanlyon
Site Admin
Posts: 793
Joined: Fri Jul 12, 2019 12:49 am
Answers: 44
Location: San Francisco
Has thanked: 4 times
Been thanked: 218 times
Contact:

Re: ffmpeg using cpu to encode on convert

Post by bryanlyon »

It's not that FFMPEG is using your CPU that it's taking a while. The fact is that conversion is slow due to the amount of work that must be done. GPU acceleration simply isn't a priority because the real bottleneck in conversion comes from things like loading the original frames, color matching, and compositing. Plus, your GPU would be in use for the actual AI part of the conversion and so wont be fully available for accelerating your encode.

User avatar
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 623 times

Re: ffmpeg using cpu to encode on convert

Post by torzdf »

Also, you're misreading that message....

That isn't ffmepg using the CPU, that's Faceswap using the CPU, which is of more concern.

Please post the output from within Faceswap's "Help > Output System Information"

My word is final

User avatar
wuthapn
Posts: 5
Joined: Sun Aug 02, 2020 2:05 am
Been thanked: 2 times

Re: ffmpeg using cpu to encode on convert

Post by wuthapn »

I did a comparison on a 720p video:

opencv: 8m 11s
ffmpeg: 8m 18s

This isn't as drastic because h264/720p is not that complex, however when I performed the process on a 4 minute 5k video, ffmpeg was adding an additional 30+ minutes to encode the results into h265. I ended up having it output the images in opencv and manually running ffmpeg to merge the images into an h265 video which drastically cut the overall time down as I used a hardware encoder.

I unfortunately do not have logs for this, the next time I do a conversion on a video of that resolution I'll come back and post the logs for comparisons sake and to validate the claim.

Thanks for your time.

torzdf wrote: Sun Aug 02, 2020 8:37 am

Please post the output from within Faceswap's "Help > Output System Information"

User avatar
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 623 times

Re: ffmpeg using cpu to encode on convert

Post by torzdf »

Ok. Your GPU is not being detected at all on your machine....

Specifically:

Code: Select all

gpu_devices:
gpu_devices_active:
gpu_driver: No Nvidia driver found 

So, I'm not even sure how you trained on that machine (unless you trained on CPU)

First and foremost make sure that your nvidia drivers are up to date and everything is in order on that side of things.

Also, as an aside, it is not a great idea to have a system installed version of Cuda, unless you have a very good reason to do so. It can lead to conflicts with the version installed inside your Faceswap environment, so if you can, I would recommend that you uninstall system Cuda.

As to your other issue, yes, HEVC encoding is slow. We do it on CPU because video encoding on GPU whilst also using the GPU for ML tasks is not a great idea. The way you are doing it (output to images then stitch back to video yourself) is the best way to proceed.

My word is final

User avatar
wuthapn
Posts: 5
Joined: Sun Aug 02, 2020 2:05 am
Been thanked: 2 times

Re: ffmpeg using cpu to encode on convert

Post by wuthapn »

I'm not sure why it says its not detected, I'm watching it use the heck out of both GPU's cuda cores and vram on my system via nvidia-smi command while its training. I'm doing 13.7 EG/sec on villain with 100% coverage and 32 batch size. My CPU's are basically idle while its running.

I had the latest driver 451.67, but I kept having CUDA errors, downgrading to 451.48 fixed the issue.

Thanks for the input, I'll remove the local machines cuda installation and see if that has any positive/negative impact. I'll see if removing cuda does anything positive or negative on the local machine. I dont mind doing ffmpeg manually if thats best use.

Locked