CUDA OPENGL 互操作性:cudaGLSetGLDevice

发布于 2024-12-08 22:22:33 字数 513 浏览 1 评论 0原文

遵循CUDA 4.0的编程指南,我调用cudaGLSetGLDevice 在任何其他运行时调用之前。但下一个 cuda 调用 cudaMalloc 返回“所有支持 CUDA 的设备都忙或不可用”。

另外,在 NVIDIA 论坛 (http://forums.nvidia.com/index.php?showtopic=186399) 中,一位用户表示: “在多 GPU 系统中,尽管您会遇到 CUDA 更大的缺陷...... a) 当 CUDA 上下文和 OpenGL 上下文位于不同设备上时,您无法进行 CUDA/GL 互操作(根据我的经验,未记录且不受支持) b) 您无法在非 Windows 计算机上执行 GL 设备关联。 c) 你不能在消费类设备上进行 GL 设备关联(仅限 Quadro/Tesla)”

这是真的吗?我的最终作品必须在 Linux 多 GPU 系统上运行。我必须更改要使用的图形库?并且在此 驱动

操作系统:Opensuse 11.4 64 位

显卡:GeForce 9600M GT

程序:275.21

Following the Programming Giude of CUDA 4.0, I call cudaGLSetGLDevice
before any other runtime calls. But the next cuda call, cudaMalloc, return "all CUDA-capable devices are busy or unavailable."

Also, in the NVIDIA forum (http://forums.nvidia.com/index.php?showtopic=186399) an user said that:
"In multi-GPU systems though you're going to encounter even larger flaws in CUDA...
a) You can't do CUDA/GL interop when the CUDA context and the OpenGL context are on different devices (undocumented, and unsupported in my experience)
b) You can't do GL device affinity on non-windows machines.
c) You can't do GL device affinity on consumer devices (Quadro/Tesla only)"

Is this true? My final work must run on a linux multi-gpu system. I have to change the graphic library to use? And in this case, what are you suggestions?

OS: Opensuse 11.4 64 bit

Graphic Card: GeForce 9600M GT

DRIVER: 275.21

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

dawn曙光 2024-12-15 22:22:33

请参阅 Cuda 和 OpenGL Interop

我不得不用 gl* 的负担替换简单的 cudaMalloc()事物。

尽管如此,它的效果还是相当不错的。

// The lattice as a GL Buffer
GLuint gridVBO = 0;
struct cudaGraphicsResource *gridVBO_CUDA = NULL;

// Ask for GL memory buffers
glGenBuffers(1, &gridVBO);
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
const size_t size = L * L * sizeof(unsigned char);
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
glBindBuffer(GL_ARRAY_BUFFER, 0);
cutilSafeCall(cudaGraphicsGLRegisterBuffer(&gridVBO_CUDA, gridVBO, cudaGraphicsMapFlagsWriteDiscard));

// Map the GL buffer to a device pointer 
unsigned char *grid = NULL;
cutilSafeCall(cudaGraphicsMapResources(1, &gridVBO_CUDA, 0));
size_t num_bytes = 0;
cutilSafeCall(cudaGraphicsResourceGetMappedPointer((void **) &grid,
                     &num_bytes, gridVBO_CUDA));

// Execution configuration
dim3 dimBlock(TILE_X, TILE_Y);
dim3 dimGrid(L/TILE_X, L/TILE_Y);

// Kernel call
kernel<<<dimGrid, dimBlock>>>(grid);
cutilCheckMsg("Kernel launch failed");

// Unmap buffer object
cutilSafeCall(cudaGraphicsUnmapResources(1, &gridVBO_CUDA, 0));

See Cuda and OpenGL Interop

I had to replace a simple cudaMalloc() by a burden of gl* things.

Nevertheless, it works pretty well.

// The lattice as a GL Buffer
GLuint gridVBO = 0;
struct cudaGraphicsResource *gridVBO_CUDA = NULL;

// Ask for GL memory buffers
glGenBuffers(1, &gridVBO);
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
const size_t size = L * L * sizeof(unsigned char);
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
glBindBuffer(GL_ARRAY_BUFFER, 0);
cutilSafeCall(cudaGraphicsGLRegisterBuffer(&gridVBO_CUDA, gridVBO, cudaGraphicsMapFlagsWriteDiscard));

// Map the GL buffer to a device pointer 
unsigned char *grid = NULL;
cutilSafeCall(cudaGraphicsMapResources(1, &gridVBO_CUDA, 0));
size_t num_bytes = 0;
cutilSafeCall(cudaGraphicsResourceGetMappedPointer((void **) &grid,
                     &num_bytes, gridVBO_CUDA));

// Execution configuration
dim3 dimBlock(TILE_X, TILE_Y);
dim3 dimGrid(L/TILE_X, L/TILE_Y);

// Kernel call
kernel<<<dimGrid, dimBlock>>>(grid);
cutilCheckMsg("Kernel launch failed");

// Unmap buffer object
cutilSafeCall(cudaGraphicsUnmapResources(1, &gridVBO_CUDA, 0));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文