OpenCL 程序在使用 GPU 时冻结
OpenCL program freezes when using GPU
我的程序在CPU和GPU上都不起作用:
ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_CPU, 1, &device_id, &ret_num_devices);
ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &ret_num_devices);
使用 CPU 时,我收到以下消息:
0x000007FEE30E8F90 (amdocl64.dll) 的首次机会异常 项目2.exe:0xC0000005:访问冲突读取位置 0xFFFFFFFFFFFFFFFF. 如果存在此异常的处理程序, 该计划可以安全地继续。
执行此命令时出现问题:
ret = clEnqueueReadBuffer(command_queue, Cmobj, CL_TRUE, 0,
K*L*sizeof(float), C, 0, NULL, NULL);
使用 GPU 程序时,执行此命令时冻结:
ret = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
内存有问题吗?还是别的什么?我使用 Visual Studio 2012, AMD Radeon HD 6470M, AMD APP SDK 2.9-1
你是如何初始化device_id
和ret_num_devices
的?
通常,您需要调用clGetDeviceIDs
两次:首先获取可用设备的数量,然后为设备 ID 分配内存,然后再次调用它以填充该内存,如下所示:
cl_uint numDevices = 0;
cl_device_id *devices;
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
if (numDevices > 0)
{
devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numDevices, devices, NULL);
}
else
{
// error: no device available: exit or fall back to CPU ...
}
// use any of the devices[0 .. numDevices-1]
// after compiling/loading the kernel, you can free(devices)
APP SDK附带的一些示例也显示了这种模式,例如samples/opencl/cl/app/HelloWorld/HelloWorld.cpp例如。也许您只是使用其中一个示例并根据您的需求进行调整?
相关文章:
- 在使用GPU支持编译Tensorflow时,会遇到CUDA_TOOLKIT_PATH未绑定变量
- WIN32:C++,为什么在WM_CLOSE上调用Messagebox函数程序正在冻结
- 有没有办法简单地从 GPU 调用多个 cpp 输出文件?
- Win32 发送输入鼠标移动滞后并冻结
- ImGui 在单击按钮后冻结
- 在 DirectX 11 中从 GPU 读回顶点缓冲区(并获取顶点)
- 跨平台 GPU 计算
- C++:从GPU内存(cudaMemcpy2D)获取BGR图像(cv::Mat)
- 请求最简单的 OpenMP 目标 GPU 示例
- QWidget UI 在使用 QQuickWidget 时冻结
- 如何防止 std::thread 在 QT 中冻结 GUI?
- Adafruit 羽毛RFM69HCW在使用过程中会冻结,需要硬重置
- DirectX 11 如何处理来自 GPU 上的 sharedHandle 的图像
- 编译 GPU 的张量流示例自定义操作
- 多 GPU 批处理 1D FFT:似乎只有一个 GPU 可以工作
- MFC/C++ ComboBox:禁用下拉列表关闭和打开(UI 冻结)的绘制
- 如何在GPU支持下编译tflite?
- OpenCL 在 NVIDIA 和 Intel GPU 上启动内核时CL_INVALID_COMMAND_QUEUE
- OpenGL glGetUniformBlockIndex 在 nvidea GPU 上返回INVALID_INDEX
- OpenCL 程序在使用 GPU 时冻结