Another method is to use OpenCL but I do not recommend it unless if you really want to know more about the GPU, such as clock speeds or to use the GPU for other purposes.
They have an example and it detects GPU memory correctly as well.
https://code.google.com/archive/p/de...encl/downloads