hacksider / Deep-Live-Cam

real time face swap and one-click video deepfake with only a single image
GNU Affero General Public License v3.0
39.55k stars 5.77k forks source link

why using whole tensorflow library just to get number of gpus? aren't there alternatives? #229

Closed tikendraw closed 2 weeks ago

tikendraw commented 2 months ago

Installing a big library such as tensorflow just for gpu count seems overkill.

./requirements.txt
18:tensorflow==2.13.0rc1; sys_platform == 'darwin'
19:tensorflow==2.12.1; sys_platform != 'darwin'

./modules/core.py
6:# reduce tensorflow log level
16:import tensorflow
130:    # prevent tensorflow memory leak
131:    gpus = tensorflow.config.experimental.list_physical_devices('GPU')
133:        tensorflow.config.experimental.set_memory_growth(gpu, True)
MYusufY commented 2 months ago

as i know, tensorflow doesnt just get the count of the GPUs, but also optimizes itself, its looking for supported GPUs. So this may be the reason. I tried changing tensorflow and using another method, such as pynvml, pytorch and pycuda, but because of i have no nvidia GPUs, i didnt get a clear result but yeah, as i know tensorflow is different.

i can may be wrong too, but this is what i know. Have a good day.

hacksider commented 2 months ago

If you find an alternative, feel free to push to the code to help everyone out on this. ☺️

MYusufY commented 2 months ago

Of course ☺️ only thing is as i said i dont have enouh GPUs to check if it works so i didnt want to contribute, but if theres no problem, i can ☺️

MYusufY commented 2 months ago

Hi @hacksider, i created a PR to use CUPY instead of Tensorflow in core.py:

I accidentally didnt write description while creating PR :) But here are some notes: I didnt be able to test it as i said. I have not enough GPUs unfotunately! :)

So i pushed it to the experimental branch, hope it works and helps everyone. Thanks :)