【发布时间】:2015-03-19 12:11:49
【问题描述】:
我正在尝试使用 ArrayFire 对 a 9000x9000 pixel 3-channel image 执行卷积,约为 75MB。我的 GPU 是具有 1536MB RAM 的 NVIDIA GTX480。我希望 ArrayFire 使用 75MB 的输入图像和大约 75MB 的输出图像。然而,ArrayFire 运行了一段时间,最终说它内存不足:
Memory Usage: 1325 MB free (1536 MB total) //printed before calling convolutionTest()
warning: device memory is low //printed in convolutionTest()
src/gena/gi_mem.cpp:349: error: tried to allocate 309mb (45mb free / 1536mb total) //exception
在具有 1536MB 内存的 GPU 上对 75mb 图像执行卷积时,ArrayFire 会耗尽内存。为什么会发生这种情况,我该怎么办?
代码:
#include <stdio.h>
#include <arrayfire.h>
using namespace af;
static const float h_sobel[] = {-2.0, -1.0, 0.0,
-1.0, 0.0, 1.0,
0.0, 1.0, 2.0}; // 3x3 sobel weights
static void convolutionTest() {
array sobel_k = array(3, 3, h_sobel);
array img_gray = loadimage("9k_x_9k.png", false); // 'false' makes it a 1 channel grayscale [0-255]
array img_convolved = convolve(img_gray, sobel_k); // should I preallocate the output space?
}
int main(int argc, char** argv) {
try {
info();
convolutionTest();
} catch (af::exception& e) {
fprintf(stderr, "%s\n", e.what()); //prints src/gena/gi_mem.cpp:349: error: tried to allocate 309mb (45mb free / 1536mb total)
}
return 0;
}
系统配置及注意事项:
- ArrayFire 1.9
- Ubuntu 10.04
- CUDA 5.0
- NVIDIA GTX480 (Fermi) GPU,具有 1536MB 的 RAM
-
helloworld和其他 ArrayFire 示例正常工作 - ArrayFire 的卷积对于较小的图像(例如 512x512 像素)没有问题
【问题讨论】:
-
你能给我图片的尺寸吗?
-
ArrayFire 在对 9000x9000 像素的图像执行
convolve()时崩溃。 512x512 像素的图像可以正常工作。随意下载 9000x9000 图片here。 -
您在此处提供的代码是否失败?还是您在 for 循环中运行卷积测试?
-
这里提供的代码失败了,没有循环。
-
也添加了一些解释。完成。
标签: image-processing cuda computer-vision gpu arrayfire