【问题标题】:using cuda to run one thread on gpu, why was the gpu load so high?使用cuda在gpu上运行一个线程,为什么gpu负载这么高?
【发布时间】:2015-06-30 10:28:26
【问题描述】:

下面是我的gpu信息:

Device 0: "GeForce GT 440"
  CUDA Driver Version / Runtime Version          7.0 / 7.0
  CUDA Capability Major/Minor version number:    2.1
  Total amount of global memory:                 1536 MBytes (1610612736 bytes)
  ( 3) Multiprocessors, ( 48) CUDA Cores/MP:     144 CUDA Cores
  GPU Max Clock rate:                            1189 MHz (1.19 GHz)
  Memory Clock rate:                             800 Mhz
  Memory Bus Width:                              192-bit
  L2 Cache Size:                                 393216 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65535),
3D=(2048, 2048, 2048)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 32768
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1536
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (65535, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  CUDA Device Driver Mode (TCC or WDDM):         WDDM (Windows Display Driver Mo
del)
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:

cuda 代码很简单:

__global__ void kernel(float *d_data)
{
    *d_data = -1;
    *d_data = 1/(*d_data);
    *d_data = (*d_data) / (*d_data);
}
int main()
{
    float *d_data;
    cudaMalloc(&d_data, sizeof(float));
    while (1)
        kernel << <1, 1 >> >(d_data);
    float data;
    cudaMemcpy(&data, d_data, sizeof(int), cudaMemcpyDeviceToHost);
    printf("%f\n",data);
    return 0;
}

然后运行代码,我得到 GPU-Z 的 gpu 负载为 99%!!

GPU-Z:http://www.techpowerup.com/gpuz/

我错过了什么吗?如何理解gpu负载?

【问题讨论】:

    标签: cuda gpu


    【解决方案1】:

    GPU“负载”只是衡量 GPU 忙碌的时间比例除以总时间间隔。

    因此,如果您的程序运行 1.0 秒,而内核运行时间为 0.8 秒,则该时间间隔内的 GPU 负载将为 80%。使用 GPU-Z,由于此数字会定期更新,因此如果您的内核在整个更新期间都在运行,那么它将看起来大约 100% 忙碌。

    由于对于您给定的代码,您的内核一直在运行,因此 GPU 负载应该接近 100%。内核在做什么并不重要。如果内核正在运行,则 GPU 很忙,这就是衡量负载的方式。

    【讨论】:

    • 感谢您的回答,对我有帮助!!
    • GPU“负载”只是衡量gpu繁忙时间的比例,除以总时间间隔。就是说“负载”跟硬件源gpu的使用大小没有关系吧?
    • 这是另一个问题,我已经编译了一个算法,它只使用一个线程(&lt;&lt;&lt;1,1&gt;&gt;&gt;)调用“app”就可以在gpu上运行。然后我使用脚本运行它:./app,我花了 175.95 秒。接下来,我更改脚本:./app & ./app &.
    • 没错。我希望您的程序持续运行内核,在运行它的任何 GPU 上都会显示 ~99% 的负载。
    • 脚本会同时启动两个“app”,它们分别花了我 353.41s 和 353.25s。在这个测试之前,我认为运行两个“app”的时间会接近运行一个“app”的时间,原因是gpu可以同时运行两个“app”。你能给我一些建议吗?
    猜你喜欢
    • 2019-02-26
    • 2015-10-17
    • 2023-04-10
    • 1970-01-01
    • 2011-05-01
    • 2019-10-23
    • 1970-01-01
    • 2020-11-10
    • 2022-10-23
    相关资源
    最近更新 更多