I would like to know my free and total memory on my GPU device thanks to the function cuMemGetInfo()
// ----- Before any variable initialization -----
size_t free;
size_t total;
CUresult result=cuMemGetInfo(&free,&total);
I'm getting the result :
Free memory : 4095 MB
Total memory : 4095 MB
I'm working on a Tesla C2070 with 6GB of memory on a 64bit Windows 7. However, my application is running in 32 bit. My code should give me something like :
Free memory : 5376 MB
Total memory : 5376 MB // values given by the deviceQuery.exe example of CUDA
I 4095*1024*1024 = 4293918720 is about 2^32 (after rounding). indeed, size_t s a pointer to a unsigned int (on 4 Bytes).
So here's my question. Is it possible to change the definition of size_t in order to point to a unsigned long for example?
thanks
size_t
is usually 32 bits when compiling for 32 bits targets. If you want to get a 64 bitssize_t
, simply set your compiler to target 64 bits platforms.If you're using the Visual Studio build chain, here is the documentation on the topic. If you're using the Qt build chain, I don't know how it's done, but it's certainly feasible somehow.
You say in the comments:
To the best of my knowledge, it's not possible. If you build for 32 bits, then you will link against the 32 bits version of
cuMemGetInfo
, which works with 32 bitssize_t
. There's no getting around that.However, if memory serves, I've worked in the past with 64 bits applications built with VS2012, CUDA 6 and Qt 4.8, so it should be possible to set your tool chain to work with 64 bits.