RuntimeError: CUDA out of memory. Tried to allocate 2.81 GiB (GPU 0; 14.73 GiB total capacity; 12.38

 

        try:
            outputs = (model(train_datas)).cuda()
        except RuntimeError as exception:
            if "out of memory" in str(exception):
                print("WARNING: out of memory")
                if hasattr(torch.cuda, 'empty_cache'):
                    torch.cuda.empty_cache()
            else:
                raise exception

单独使用 torch.cuda.empty_cache() 不会奏效。

RuntimeError: CUDA out of memory. Tried to allocate 2.81 GiB (GPU 0; 14.73 GiB total capacity; 12.38_第1张图片

你可能感兴趣的:(令人崩溃的坑)