#include< stdio.h>
#include "cuda_runtime.h"
#include <stdlib.h>
#include "device_launch_parameters.h"
bool InitCUDA()
{
int count;
cudaGetDeviceCount(&count);
if (count == 0)
{
fprintf(stderr, "There is no device.\n");
return false;
}
int i;
for (i = 0; i < count; i++)
{
cudaDeviceProp prop;
if (cudaGetDeviceProperties(&prop, i) == cudaSuccess)
{
if (prop.major >= 1)
{
break;
}
}
}
if (i == count)
{
fprintf(stderr, "There is no device supporting CUDA 1.x.\n");
return false;
}
cudaSetDevice(i);
return true;
}
int main()
{
if (!InitCUDA())
{
return 0;
}
printf("HelloWorld, CUDA has been initialized.\n");
system("pause");
return 0;
}
Windows+vs2013+cuda8.0测试
最新推荐文章于 2024-06-26 16:00:05 发布