为什么gpu内存中的O3不小于O1? [英] Why don't O3 less than O1 in gpu memory?

查看:44
本文介绍了为什么gpu内存中的O3不小于O1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 2080TI * 1 中训练 EfficientDet-D7(head_only=True).

i'm training EfficientDet-D7(head_only=True) in 2080TI * 1.

我正在使用 NVIDIA/APEX:amp.

And i'm using NVIDIA/APEX:amp.

当我使用 opt_level=O1 时,尽管与不使用 apex 时相比,内存确实减少了.

When i use opt_level=O1, although the memory is definitely reduced compared to when apex is not used.

但是,当我使用opt_level=O2O3时,会消耗更多内存.

But, when I use opt_level=O2orO3, more memory is consumed.

我正在试验相同的 2080 Ti,通过创建两个具有相同 docker 映像的容器,每个都有一个单独的 GPU.学习代码也照原样复制了O1的代码,改成O3,学习所需的args都是一样的.(batch size和d7也是一样的.)

I am experimenting with the same 2080 Ti, each with a separate GPU by creating two containers with the same docker image. The learning code also copied the code using O1 as it is and changed it to O3, and the args required for learning are all the same. (The batch size and d7 are also the same.)

为什么会这样……TT

另外,你能推荐一下这方面的书吗?(例如深度学习内存、gpu...等)

Additionally, Can you recommend the book about this?(ex. deep learning Memory, gpu ... etc)

谢谢!

推荐答案

您正在优化速度.一些速度优化将减少内存使用.其他人会增加他们.

You're optimizing for speed. Some speed optimizations will reduce memory usage. Other will increase them.

  • 速度优化减少内存使用的一个例子是删除不必要的变量和函数调用.

  • An example of when speed optimization reduces memory usage is when unnecessary variables and function calls are removed.

相反的一个例子是循环展开.

An example of the opposite is loop unrolling.

没有理由期望优化会减少或增加内存使用量.这不是优化速度时的目标.任何增加或减少都只是副产品.

There's no reason to expect optimization to either reduce or increase memory usage. That's not the goal when optimizing for speed. Any increase or decrease is just a byproduct.

如果您真的想找出在您的特定情况下发生这种情况的原因,您可以研究编译器的文档并检查汇编代码.

If you really want to find out why it happens in your particular case, you can study the documentation for your compiler and inspect the assembly code.

这篇关于为什么gpu内存中的O3不小于O1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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