我在装有CUDA9.2和Nvidia driver (398.82-desktop-win10-64bit-international-whql),的Windows1064位上安装了一台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的机器上做了完全相同的实验,分析器确实显示了统一的内存信息。那台特定的计算机有什么问题吗?是否需要进行与硬件相关的配置/设置才能启用统一内存功能?
发布于 2018-09-23 07:05:41
我过去曾遇到过这个问题,但在将我的驱动程序更新到最新版本(如果我没有弄错的话是在2018年9月19日发布的话)之后,问题解决了。
希望它也能解决你的问题。如果成功了,请告诉我。
发布于 2018-09-25 01:08:15
我安装了新的cuda sdk 10,现在它工作得很好。
https://stackoverflow.com/questions/52449493
复制相似问题