gpt4 book ai didi

c++ - cudaMalloc 问题和 "out of memory"错误

转载 作者:行者123 更新时间:2023-11-28 01:08:42 27 4
gpt4 key购买 nike

在不超过可用内存的情况下,分配设备内存是否有任何限制?尝试分配 64MB 后出现以下错误:

cudaSafeCall() Runtime API error : out of memory.

但是,根据 cuMemGetInfo,剩余空间超过 200MB。

这是场景:

size_t size = 4096 * 4096 * sizeof (float);
cuMemGetInfo(&fr, &ttl); // fr indicates 284 MB
cutilSafeCall(cudaMalloc((void**) &tmp, size));
p1 = tmp;
cuMemGetInfo(&fr, &ttl); // fr indicates 220 MB
cutilSafeCall(cudaMalloc((void**) &tmp, size)); // this fails !!!
p2 = tmp;

我错过了什么?

我正在使用:

Cuda compilation tools, release 3.2, V0.2.1221
NVidia Driver 260.19.26
Linux(Slackware) x86

更新:

这种行为是非常不确定的。上述案例有时会成功,我会得到正确的结果,没有任何错误。

最佳答案

正如 Thomas 所指出的,问题在于内存碎片。 (通过实验证实。我没有找到可靠的来源链接)

关于c++ - cudaMalloc 问题和 "out of memory"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4750293/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com