cudaMallocManaged() 返回 "operation not supported"

标签 cuda

在 CUDA 6.0 中尝试托管内存时,调用 cudaMallocManaged() 时出现操作不受支持

#include "cuda_runtime.h"

#include <stdio.h>

#define CHECK(r) {_check((r), __LINE__);}

void _check(cudaError_t r, int line) {
  if (r != cudaSuccess) {
    printf("CUDA error on line %d: %s\n", line, cudaGetErrorString(r), line);
    exit(0);
  }
}

int main()
{
  int *c;
  CHECK(cudaMallocManaged(&c, sizeof(int)));
  *c = 0;
  return 0;
}

GeForce GTX 750 Ti (Maxwell),使用compute_50、sm_50 使用 CUDA 6.0 进行编译。 Windows 7 64 位。使用驱动程序 335.23 (whql) 和 337.50 (beta) 进行测试。 Visual Studio 2012。尝试过 32 位调试和发布版本。

C:\rd\projects\cpp\test_cuda6\test_cuda6>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\bin\nvcc.exe" -gencode=arch=compute_50,code=\"sm_50,compute_50\" --use-local-env --cl-version 2012 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin" -I\C\common\inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" --keep-dir Release -maxrregcount=0 --machine 32 --compile -cudart static -DWIN32 -DNDEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MD " -o Release\kernel.cu.obj "C:\rd\projects\cpp\test_cuda6\test_cuda6\kernel.cu"

如果我将 cudaMallocManaged() 替换为 cudaMalloc(),程序运行不会出现错误。

关于如何让 cudaMallocManaged() 工作有什么想法吗?

最佳答案

Tried 32-bit debug and release builds.

使用 64 位调试或发布版本。

来自the documentation :

J.1.4. System Requirements

Unified Memory has three basic requirements:

•a GPU with SM architecture 3.0 or higher (Kepler class or newer)

•a 64-bit host application and operating system, except on Android

•Linux or Windows

64 位主机应用程序意味着您无法编译 32 位调试或发布版本。

关于cudaMallocManaged() 返回 "operation not supported",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23600403/

相关文章:

cuda - 在这篇 NVIDIA 博客文章中,为什么通过共享内存复制速度更快?

cuda - 多个 GPU 和多个可执行文件

memory - 合并访问模式对 CUDA 中的纹理和表面内存很重要吗?

c++ - Cuda原子操作

CURAND 和内核,在哪里生成?

cuda - 是否有正确的 CUDAatomicLoad 函数?

c++ - 如何指定使用 NVIDIA CUDA nvcc 4.1 而不是 4.0?

c# - 将 C# 方法转换为 C++ 方法

cuda - Parallel NSight for Visual studio 2010 支持在服务器上调试吗?

c++ - 扭曲如何与原子操作一起工作?