zoukankan      html  css  js  c++  java
  • CUDA获取显卡数据

    一个简单的获取Nvidia显卡信息的程序

    #include<iostream>
    int main()
    {
        cudaDeviceProp prop;
        int count;
        cudaGetDeviceCount(&count);//获取设备数目,比如GTX295 有两个GPU(也就是双核) count为2
        for(int i=0;i<count;i++)
        {
            cudaGetDeviceProperties(&prop,i);//将第i个GPU数据放到prop中
            std::cout<<"显卡名称:"<<prop.name<<std::endl;
            std::cout<<"显存大小:"<<prop.totalGlobalMem/1024/1024<<" MB"<<std::endl;
            std::cout<<"一个block的共享内存大小:"<<prop.sharedMemPerBlock/1024<<" KB"<<std::endl;
            std::cout<<"block最大线程数:"<<prop.maxThreadsPerBlock<<std::endl;
        }
        system("pause");
    return 0;
    }

    其中结构体cudaDeviceProp 用来存储显卡每个GPU的信息,其定义如下:

    struct cudaDeviceProp {
        char name[256];
        size_t totalGlobalMem;
        size_t sharedMemPerBlock;
        int regsPerBlock;
        int warpSize;
        size_t memPitch;
        int maxThreadsPerBlock;
        int maxThreadsDim[3];
        int maxGridSize[3];
        size_t totalConstMem;
        int major;
        int minor;
        int clockRate;
        size_t textureAlignment;
        int deviceOverlap;
        int multiProcessorCount;
        int kernelExecTimeoutEnabled;
        int integrated;
        int canMapHostMemory;
        int computeMode;
        int maxTexture1D;
        int maxTexture2D[2];
        int maxTexture3D[3];
        int maxTexture2DArray[3];
        int concurrentKernels;
    };
  • 相关阅读:
    Android开机自启动应用
    扫码登录原理
    前端性能优化
    关于android推送的一些心得
    抓包工具Fiddler及iphone设置
    Node.js介绍、优势、用途
    Yapi本地化部署及接口调试(亲测)
    前后端分离,几个常用的API管理系统
    WebGL之Threejs概述
    Eclipse汉化
  • 原文地址:https://www.cnblogs.com/fengyuehan/p/3587070.html
Copyright © 2011-2022 走看看