facerecognition icon indicating copy to clipboard operation
facerecognition copied to clipboard

Checks if are using GPU

Open stalker314314 opened this issue 5 years ago • 9 comments

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:

  • if it is compiled with CUDA support, and
  • If there is CUDA GPU present

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


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

stalker314314 avatar Dec 09 '18 20:12 stalker314314

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

feedthedogs avatar Feb 23 '19 12:02 feedthedogs

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

  • We are planning less invasive detector (HOG detector, as part of #93)
  • @matiasdelellis is preparing Debian packages (as part of #86), but not sure if these will be compiled with CUDA

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:)

stalker314314 avatar Feb 23 '19 13:02 stalker314314

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: [email protected]

xelayz avatar Jan 03 '20 15:01 xelayz

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:

  • Model 1
  • 1GB for PHP memory limit
  • Temporary files set to 800x600
  • 0.4 clustering threshold
  • 0.99 minimum confidence

And after all that configuration I got:

  • 616 faces
  • in 1430 images
  • practically in one hour.

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?

tetebueno avatar May 13 '21 18:05 tetebueno

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)

stalker314314 avatar May 13 '21 20:05 stalker314314

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.

tetebueno avatar May 13 '21 20:05 tetebueno

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.

matiasdelellis avatar May 14 '21 14:05 matiasdelellis

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

aleksandrmetik avatar May 14 '21 16:05 aleksandrmetik

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

ajdelgado avatar Oct 07 '23 06:10 ajdelgado