获取当前显存容量

头文件

#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>

调用函数

cuda::setDevice(0);
size_t free;
size_t total;
CUresult uRet = cuMemGetInfo(&free, &total);
if (uRet == CUDA_SUCCESS)
	printf("free = %dM\ntotal = %dM", free / 1024 / 1024, total / 1024 / 1024);

结果:

 

 


版权声明:本文为qq_30263737原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。