【发布时间】: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.
【问题讨论】:
-
@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)