CUDA(三)——GPU属性查看,多GPU时,设置GPU

获取GPU属性

cudaDeviceProp prop;
int count;
for (int i=0;i<count;i++)
{
cudaGetDeviceProperties(&prop,i);
cout<<prop.name<<endl;
}

menset快速初始化一个值

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    cudaDeviceProp prop;
    int dev;
    cudaGetDevice(&dev);
    cout << "ID:" << dev << endl;
    memset(&prop, 0, sizeof(cudaDeviceProp));
    prop.major = 1;
    prop.minor = 3;
    cudaChooseDevice(&dev, &prop);
    cout << "name:" << prop.name << endl;
    cout << dev << endl;
    cudaSetDevice(dev);
}

猜你喜欢

转载自blog.csdn.net/u014413083/article/details/53207311
GPU
今日推荐