如何修复这个奇怪的错误:“RuntimeError: CUDA error: out of memory" [英] How to fix this strange error: "RuntimeError: CUDA error: out of memory"

查看:164
本文介绍了如何修复这个奇怪的错误:“RuntimeError: CUDA error: out of memory"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行了一个关于深度学习网络的代码,首先我训练了网络,它运行良好,但运行到验证网络时出现此错误.

I ran a code about the deep learning network,first I trained the network,and it works well,but this error occurs when running to the validate network.

我有五个 epoch,每个 epoch 都有一个训练和验证的过程.我在第一个纪元验证时遇到了错误.所以我没有运行验证代码,我发现代码可以运行到第二个epoch并且没有错误.

I have five epoch,every epoch has a process of training and validation. I met the error when validate in the first epoch. So I don not run the validate code, I found that code can run to the second epoch and have no error.

我的代码:

for epoch in range(10,15): # epoch: 10~15
    if(options["training"]["train"]):
        trainer.epoch(model, epoch)

    if(options["validation"]["validate"]):
    #if(epoch == 14):
        validator.epoch(model)

我觉得验证的代码可能有一些错误.但我找不到那个.

I feel the code of validation may have some bugs. But I can not find that.

推荐答案

显示您提供的错误,因为您的 GPU 内存不足.解决此问题的一种方法是减少批处理大小,直到您的代码运行时不会出现此错误.

The error, which you has provided is shown, because you ran out of memory on your GPU. A way to solve it is to reduce the batch size until your code will run without this error.

这篇关于如何修复这个奇怪的错误:“RuntimeError: CUDA error: out of memory"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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