cudaGetDeviceProperties中的错误

时间:2013-04-26 08:17:01

标签: cuda

我正在尝试使用以下代码获取设备的内存总线带宽:

 #include <stdio.h>

    int main() {
  int nDevices;

  cudaGetDeviceCount(&nDevices);
  for (int i = 0; i < nDevices; i++) {
    cudaDeviceProp prop;
    cudaGetDeviceProperties(&prop, i);
    printf("Device Number: %d\n", i);
    printf("  Device name: %s\n", prop.name);
    printf("  Memory Clock Rate (KHz): %d\n",
           prop.memoryClockRate);
    printf("  Memory Bus Width (bits): %d\n",
           prop.memoryBusWidth);
    printf("  Peak Memory Bandwidth (GB/s): %f\n\n",
           2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
  }
}

我收到了这个错误:

bandwidth.cu(13): error: class "cudaDeviceProp" has no member "memoryClockRate"

bandwidth.cu(15): error: class "cudaDeviceProp" has no member "memoryBusWidth"

bandwidth.cu(17): error: class "cudaDeviceProp" has no member "memoryClockRate"

bandwidth.cu(17): error: class "cudaDeviceProp" has no member "memoryBusWidth"

4 errors detected in the compilation of "/tmp/tmpxft_000003c4_00000000-4_bandwidth.cpp1.ii".
make: *** [hello.cu_o] Error 2

有人可以帮忙吗?我使用的是特斯拉T10处理器 GPU和 CUDA 3.2

1 个答案:

答案 0 :(得分:1)

您可以在线查看CUDA 3.2 documentation,然后您会看到device properties不同。升级到CUDA 5.0或将您的代码调整为CUDA 3.2。

如果您决定坚持使用CUDA 3.2,请查看SDK示例,尤其是bandwidthTest.cu,其中显示了以前的工作方式。