cudaMalloc总是给出内存 [英] cudaMalloc always gives out of memory

查看:172
本文介绍了cudaMalloc总是给出内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面对一个简单的问题,其中所有我调用cudaMalloc失败,给我一个内存错误,即使它只是一个字节我分配。

I'm facing a simple problem, where all my calls to cudaMalloc fail, giving me an out of memory error, even if its just a single byte I'm allocating.

cuda设备可用,并且还有很多可用的内存(bot用相应的调用检查)。

The cuda device is available and there is also a lot of memory available (bot checked with the corresponding calls).

任何想法可能是什么问题?

Any idea what the problem could be?

推荐答案

感谢大家的帮助。

不是真的与cudaMalloc本身,但它阴影了真正的问题,这是由于cuda的初始化似乎失败。

The problem was not really with the cudaMalloc itself but it shadowed the real problem which was due to the initialisation of cuda which seemed to fail.

因为第一次调用cuda是在一个单独的线程我did'nt有一个GLContext可用,导致失败。我需要确保在初始化上下文之后,在主线程中通过虚拟malloc初始化cuda。

Because the first call to cuda was in a separate Thread I did'nt have a GLContext available, leading to failures. I needed to make sure that I initialised cuda by a dummy malloc in the main thread after the initialisation of the context.

这篇关于cudaMalloc总是给出内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆