Skip to content

Potential Memory Leak in expand_as #1963

@zihangdai

Description

@zihangdai

I think I encountered a memory leak situation potentially due to expand_as. I create a gist to reproduce my observations.

Basically, for three different (meaningless) models, once the expand_as function is used, the memory usage will keep increasing.

To run the code, python mem_leak_expand.py --run_expand --model_type [0,1,2] where the --run_expand flag controls whether expand_as is used. Please run it long enough.

I'm on Ubuntu 14.04 with python3.6. I tried two versions of pytorch, 0.1.12_2 and 0.1.12+da0fad8.

Side Note: Even without using expand_as, the memory usauge can also increase for a while, but it will finally stablize at a level. What's more, when Conv2d (i.e. --model_type [1,2]) is used, it can take very long before the memory usage stablizes. I'm not sure whether this is a problem or not.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions