【问题标题】:why the Nvidia profiler does not show unified memory information为什么 Nvidia Profiler 不显示统一的内存信息
【发布时间】:2019-02-26 04:53:42
【问题描述】:

我在带有 CUDA 9.2 和 Nvidia 驱动程序 (398.82-desktop-win10-64bit-international-whql) 的 Windows 10 64bit 中安装了 TitanXP,并且我有一个使用统一内存的简单程序,如下所示。

// CUDA kernel to add elements of two arrays
__global__
void add(int n, float *x, float *y)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for (int i = index; i < n; i += stride)
    y[i] = x[i] + y[i];
}

int main(void)
{
int N = 1 << 20;
float *x, *y;

// Allocate Unified Memory -- accessible from CPU or GPU
cudaMallocManaged(&x, N * sizeof(float));
cudaMallocManaged(&y, N * sizeof(float));

// initialize x and y arrays on the host
for (int i = 0; i < N; i++) {
    x[i] = 1.0f;
    y[i] = 2.0f;
}

// Launch kernel on 1M elements on the GPU
int blockSize = 256;
int numBlocks = (N + blockSize - 1) / blockSize;
add <<< numBlocks, blockSize >>>(N, x, y);

// Wait for GPU to finish before accessing on host
cudaDeviceSynchronize();

// Check for errors (all values should be 3.0f)
float maxError = 0.0f;
for (int i = 0; i < N; i++)
    maxError = fmax(maxError, fabs(y[i] - 3.0f));
std::cout << "Max error: " << maxError << std::endl;

// Free memory
cudaFree(x);
cudaFree(y);

return 0;
}

我使用 Visual Studio 2017 社区编译此代码,并在命令提示符窗口中运行它,没有错误。

当我在 Nvidia Profiler 中对其进行分析时,它会给我一条“警告”消息,如下所示。

"==852== Warning: Unified Memory Profiling is not supported on the
current configuration because a pair of devices without peer-to-peer
support is detected on this multi-GPU setup. When peer mappings are
not available, system falls back to using zero-copy memory. It can
cause kernels, which access unified memory, to run slower. More
details can be found at:
http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#um-
managed-memory"

我很确定我的电脑只安装了一个 GPU,为什么我无法获得统一的内存分析信息?

顺便说一句,我在另一台具有相同软件环境和相同 GPU 的机器上进行了完全相同的实验,并且分析器确实显示了统一的内存信息。那台特定的计算机有问题吗?为了启用统一内存功能,我需要做任何与硬件相关的配置/设置吗?

【问题讨论】:

    标签: memory cuda profiling nvidia


    【解决方案1】:

    我过去曾遇到过这个问题,但在将我的驱动程序更新到最新版本(如果我没记错的话,于 2018 年 9 月 19 日发布)后问题解决了。

    希望它也能解决您的问题。 让我知道是否有。

    【讨论】:

    • 感谢您的回答。一开始我安装了最新版本,出现了这个问题,后来我试了一个旧版本,在这里发帖,问题仍然存在。
    【解决方案2】:

    我安装了新的 cuda sdk 10,现在可以正常使用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-02
      • 2014-01-03
      • 1970-01-01
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      相关资源
      最近更新 更多