Created
February 1, 2023 03:43
-
-
Save landersson/d6f4b27e2df947645769bd1103234778 to your computer and use it in GitHub Desktop.
Test case for bug in cudaGLGetDevices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <GLFW/glfw3.h> | |
#include <cuda_gl_interop.h> | |
#include <cuda.h> | |
#include <cstdio> | |
int main() | |
{ | |
if (!glfwInit()) return; | |
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); | |
GLFWwindow* offscreen_context = glfwCreateWindow(640, 480, "", NULL, NULL); | |
if (offscreen_context) { | |
glfwMakeContextCurrent(offscreen_context); | |
int gl_device = -1; | |
unsigned int device_count = 0; | |
if (cudaGLGetDevices(&device_count, &gl_device, 1, cudaGLDeviceListAll) == cudaSuccess) { | |
if (device_count > 0 && gl_device >= 0) { | |
//set_cuda_device(gl_device); | |
} | |
printf("device_count=%d\n", device_count); | |
} | |
glfwDestroyWindow(offscreen_context); | |
} | |
glfwTerminate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment