ArrayFire内存在NVIDIA Fermi上进行卷积?

时间:2013-01-08 23:29:56

标签: image-processing cuda computer-vision gpu arrayfire

我正在尝试使用ArrayFire在a 9000x9000 pixel 3-channel image上执行卷积,大约是75MB。我的GPU是NVIDIA GTX480,内存为1536MB。我希望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像素)没有问题

1 个答案:

答案 0 :(得分:2)

这是loadImage函数中的一个错误。它在所有三个通道中加载,导致它耗尽了超过必要的内存。 AccelerEyes将在下一个夜晚之前修复它,并很快报告。