matiasdelellis / facerecognition

Nextcloud app that implement a basic facial recognition system.
GNU Affero General Public License v3.0
511 stars 46 forks source link

Checks if are using GPU #64

Open stalker314314 opened 5 years ago

stalker314314 commented 5 years ago

Not sure how we can know this, I think we will need to drill some method in pdlib to get to DLib, maybe DLib can tell us:

After we know that, some calculation on image size can be different

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/67263052-checks-if-are-using-gpu?utm_campaign=plugin&utm_content=tracker%2F74944432&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F74944432&utm_medium=issues&utm_source=github).
feedthedogs commented 5 years ago

As far as I can tell, Dlib's face recognition does not make use of CUDA?

stalker314314 commented 5 years ago

It should theoretically use, if your DLib is compiled with support for CUDA (and you have CUDA:D). Couple of points:

Just for exercise, to get you through rabbit hole. We are using this method to get detected faces, and in PDLib it boils down to this call, which uses net_type which is defined here. At this point, we are into neural network definition in DLib and I cannot dig (to prove) that this uses CUDA underneath, but from DLib docs and from my experience (running app->pdlib->dlib compiled with CUDA), I can tell you it is blazingly fast (1-2 seconds vs 60 seconds for me), so CUDA is definitively used:)

xelayz commented 4 years ago

Can someone do the installation with GPU for me? I have 100k pictures and my CPU will burn without GPU. So I want to connect my 1080 Ti to scan the 100k pictures. And after that I want to dc the GPU and the CPU can do the job. I would pay for it. Nextcloud is on my local NAS.

My mail: rspam@systemli.org

tetebueno commented 3 years ago

Hey there, any progress on this? I've been working on making this work using CUDA (in a Docker container) and I'd like to see if there's any log or something I can dig into to check if the GPU is really being used.

In terms of the time it took for a run, I configured the following:

And after all that configuration I got:

I don't know if settings are poor and that's why it didn't take a minute for each photo as @stalker314314 mentioned above or if it is using the GPU and that's why it didn't take "that long" (personally I find it quite fast, but I wouldn't know what to compare with).

Can anyone shed some light here, please?

stalker314314 commented 3 years ago

I think this issue is kind-of hard to do. One would need to drill API call in pdlib to get "IsUsingCUDA" (easy part) and from pdlib to dlib (hard part, need to sync with author of dlib).

For what is worth, using CUDA is 1-2sec/image (without CUDA is 60 sec/image) and based on data you provided @tetebueno, you are definitively using CUDA (even stronger card than mine, I would say:D)

tetebueno commented 3 years ago

Thanks! That's what I thougth, but I needed an expert to confirm with the given data (by the way, the card is a GeForce 460 SE).

Finally, is there a place I can put some code about using facerecognition using CUDA under Docker? It's been quite a ride making this work, I'd like to share some of the configuration I went through.

matiasdelellis commented 3 years ago

Hi @tetebueno In pdlib 1.0.2 we introduce some constants that infoms that.

[matias@nube ~]$ php --ri pdlib

pdlib

PDlib support => enabled
Pdlib Version => 1.0.2
DLIB_USE_CUDA => false
DLIB_USE_BLAS => true
DLIB_USE_LAPACK => true
USE_AVX_INSTRUCTIONS => false
USE_AVX2_INSTRUCTIONS => false
USE_NEON_INSTRUCTIONS => false
USE_SSE2_INSTRUCTIONS => true
USE_SSE4_INSTRUCTIONS => false

However, it is not reliable, because it depends on how you have compiled pdlib.. and even if it says DLIB_USE_CUDA => true, there is no guarantee that you are using the GPU, since dlib decides how to use it.

To really know if you are using it you should check it with nvidia-smi.

aleksandrmetik commented 3 years ago

Maybe you can display statistics about the speed of processing images? For example, speed per image? It is in any case useful information. Thanks

ajdelgado commented 1 year ago

nvtop will tell you if the GPU is in use (so far I couldn't make it work)