【问题标题】:CUDA profiling tools "no kernels were profiled"CUDA 分析工具“没有分析内核”
【发布时间】:2020-11-23 18:33:15
【问题描述】:

我无法让 CUDA 分析工具正常工作。我的笔记本电脑华硕有两个视频卡。一个是集成的(英特尔),另一个是 Nvidia GTX 960M。

我怀疑视觉分析器正在使用集成显卡,所以我更改了此特定应用程序的默认显卡,在“Nvidia控制面板”和“Manager 3d设置->程序设置”下使用“高-高性能 NVidia 处理器”。

什么都没有改变。运行 Visual Profiler,在“Overall GPU usage”选项卡中,我得到“No GPU devices in Session”,这意味着据我所知没有使用任何 GPU。

另外,我注意到通知区域中的 Nvidia 显示图标没有报告任何正在使用视频卡的应用程序。

这里似乎有什么问题?如何同时为 Visual Profiler 和命令行 nvprof.exe 应用程序启用 Nvidia GPU?似乎 Nsight 都不适合我。

我正在测试的代码如下:

#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>


#define NUM_THREADS 256

#define IMG_SIZE 1048576

struct Coefficients_SOA {
  int r;
  int b;
  int g;
  int hue;
  int saturation;
  int maxVal;
  int minVal;
  int finalVal; 
};


__global__
void complicatedCalculation(Coefficients_SOA*  data)
{
  int i = blockIdx.x*blockDim.x + threadIdx.x;


  int grayscale = (data[i].r + data[i].g + data[i].b)/data[i].maxVal;
  int hue_sat = data[i].hue * data[i].saturation / data[i].minVal;
  data[i].finalVal = grayscale*hue_sat; 
}

void complicatedCalculation()
{

  Coefficients_SOA* d_x;

  cudaMalloc(&d_x, IMG_SIZE*sizeof(Coefficients_SOA)); 

  int num_blocks = IMG_SIZE/NUM_THREADS;

  complicatedCalculation<<<num_blocks,NUM_THREADS>>>(d_x);

  cudaFree(d_x);
}



int main(int argc, char*argv[])
{

    complicatedCalculation();
    return 0;
}

最好的问候,

PS:我在win10/64bit下安装了CUDA Version 11

另外,我根据https://docs.nvidia.com/cuda/pdf/CUDA_Installation_Guide_Windows.pdf验证了CUDA安装

为了您的方便,我附上了 DeviceQuery 和 BandwidthTest CUDA 示例程序。

deviceQuery 示例报告

    D:\Program Files\nVidia\CUDA Samples\v11.0\bin\win64\Release>deviceQuery
deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 960M"
  CUDA Driver Version / Runtime Version          11.0 / 11.0
  CUDA Capability Major/Minor version number:    5.0
  Total amount of global memory:                 4096 MBytes (4294967296 bytes)
  ( 5) Multiprocessors, (128) CUDA Cores/MP:     640 CUDA Cores
  GPU Max Clock rate:                            1176 MHz (1.18 GHz)
  Memory Clock rate:                             2505 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 2097152 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  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: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  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): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 4 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 Model)
  Device supports Unified Addressing (UVA):      Yes
  Device supports Managed Memory:                Yes
  Device supports Compute Preemption:            No
  Supports Cooperative Kernel Launch:            No
  Supports MultiDevice Co-op Kernel Launch:      No
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.0, CUDA Runtime Version = 11.0, NumDevs = 1
Result = PASS

带宽测试示例报告

D:\Program Files\nVidia\CUDA Samples\v11.0\bin\win64\Release>bandwidthTest
[CUDA Bandwidth Test] - Starting...
Running on...

 Device 0: GeForce GTX 960M
 Quick Mode

 Host to Device Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)        Bandwidth(GB/s)
   32000000                     12.2

 Device to Host Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)        Bandwidth(GB/s)
   32000000                     11.8

 Device to Device Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)        Bandwidth(GB/s)
   32000000                     68.9

Result = PASS

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

【问题讨论】:

  • 您需要确保: 1. 您没有设置任何CUDA_VISIBLE_DEVICES 环境变量。 2. 您的应用程序和笔记本电脑已实际启用/打开了 GTX960M。您不妨阅读this。 3. 您已按照here 的描述正确启用了分析。
  • @RobertCrovella 谢谢,我会检查所有的,我会告诉你的。
  • @RobertCrovella 在我的环境变量中,没有CUDA_VISIBLE_DEVICES
  • @RobertCrovella 我可以确认我完成了你提到的所有 3 个部分,但我没有看到任何区别。使用 Visual Profiler 或 CLI nvprof 我还可以确认通知区域中的 Nvidia GPU 活动,不会报告上述两个应用程序。
  • verify your CUDA install了吗?您是否确认可以正确运行已编译的 CUDA 代码?而且,GTX960M 是 cc5.0 设备,nsight 计算/nsight 系统不支持,所以你应该把注意力集中在nvvp(或nvprof

标签: cuda profiling nvidia


【解决方案1】:

问题解决了。作为一个 CUDA 世界的初学者,我不知道我应该在命令行下添加参数 gencode 来编译我的 CUDA 文件(CUDA SDK 示例项目的 Visual Studio 已经有这些参数了为什么我有 GPU 活动)。

因此,对于我的 CUDA Capability Major/Minor 版本号为 5.0 的 maxwell 架构,命令行下的完整参数列表应该是这样的。

nvcc -run -m64 -gencode arch=compute_50,code=sm_50 -o aos_soa.exe aos_soa.cu

不幸的是,我的第一本书“学习 CUDA 编程”,来自 Packt Publishing,第 49 页提到我应该只使用以下参数进行编译,除了源代码文件中包含的事实之外包含上述所有参数的“Makefile”(仅适用于 linux,因此我忽略了它)。

$ nvcc -o aos_soa ./aos_soa.cu

现在我可以在 nvprof 下查看我的 GPU 统计信息。

nvprof aos_soa.exe
==18308== NVPROF is profiling process 18308, command: aos_soa.exe
==18308== Profiling application: aos_soa.exe
==18308== Profiling result:
            Type  Time(%)      Time     Calls       Avg       Min       Max  Name
 GPU activities:  100.00%  1.1421ms         1  1.1421ms  1.1421ms  1.1421ms  complicatedCalculation(Coefficients_SOA*)
      API calls:   83.40%  226.57ms         1  226.57ms  226.57ms  226.57ms  cudaMalloc
                   15.90%  43.183ms         1  43.183ms  43.183ms  43.183ms  cuDevicePrimaryCtxRelease
                    0.58%  1.5790ms         1  1.5790ms  1.5790ms  1.5790ms  cudaFree
                    0.07%  198.40us         1  198.40us  198.40us  198.40us  cuModuleUnload
                    0.03%  70.100us         1  70.100us  70.100us  70.100us  cudaLaunchKernel
                    0.01%  26.800us         1  26.800us  26.800us  26.800us  cuDeviceTotalMem
                    0.01%  20.200us       101     200ns     100ns  3.3000us  cuDeviceGetAttribute
                    0.00%  11.600us         1  11.600us  11.600us  11.600us  cuDeviceGetPCIBusId
                    0.00%  1.4000us         3     466ns     200ns     700ns  cuDeviceGetCount
                    0.00%  1.4000us         2     700ns     200ns  1.2000us  cuDeviceGet
                    0.00%     600ns         1     600ns     600ns     600ns  cuDeviceGetName
                    0.00%     400ns         1     400ns     400ns     400ns  cuDeviceGetLuid
                    0.00%     300ns         1     300ns     300ns     300ns  cuDeviceGetUuid

【讨论】:

    猜你喜欢
    • 2018-02-03
    • 1970-01-01
    • 2019-04-10
    • 2011-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-26
    • 1970-01-01
    相关资源
    最近更新 更多