【问题标题】:ArrayFire out of memory doing convolution on NVIDIA Fermi?ArrayFire 在 NVIDIA Fermi 上做卷积时内存不足?
【发布时间】: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


【解决方案1】:

这是 loadImage 函数中的一个错误。它正在所有三个通道中加载,导致它占用了不必要的内存。 AccelerEyes 会在第二天晚上之前修复它,并尽快报告。

【讨论】:

  • 您能否显示图像卷积的基准(类似于 1000 x 1000 和 5x5 内核)?谢谢。
猜你喜欢
  • 2019-01-26
  • 1970-01-01
  • 1970-01-01
  • 2012-10-05
  • 2016-08-13
  • 2022-11-29
  • 2011-07-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多