cuda run out of memory 和 signal killed 解决方法

无论batch-size设置多小也是会出现这个问题的,我的原因是我将pytorch升级到了1.0.1,然后出现了这个问题

RuntimeError: CUDA out of memory. Tried to allocate 823.88 MiB (GPU 0; 7.93 GiB total capacity; 6.96 GiB already allocated; 189.31 MiB free; 10.26 MiB cached)

解决方法

我出现问题的代码,在输入到网络里面 ,如下:

output = net(input,inputcoord)

将这个代码修改成

withtorch.no_grad():

    output = net(input,inputcoord)

至于signal killed主要原因是OOM不够,也就是内存的空间不够。解决的方法就是把数据放在GPU上处理,这样可以大大减小系统内存的负荷。

input_img = input_img.cuda()

你可能感兴趣的:(cuda run out of memory 和 signal killed 解决方法)