Skip to content

[Bug]: GPU memory leak with plt.figure() #22448

@patrickhaoy

Description

@patrickhaoy

Bug summary

There seems to be a GPU memory leak when calling plt.figure() and plt.close() repeatedly in matplotlib version 3.5.0. Every time these two lines are ran, more and more GPU memory gets hogged up.

Code for reproduction

from matplotlib import pyplot as plt

for i in range(10000):
    plt.figure()
    plt.close()

Actual outcome

When inspecting memory usage, more and more GPU memory gets hogged up. Specifically, I ran nvidia-smi -l 1 and observed Memory-Usage increasing until it hits the GPU memory limits, which is when the process crashes.

Expected outcome

GPU memory usage should not be going up every iteration of this for loop.

Additional information

This is an issue in matplotlib version 3.5.0, but not 3.0.3.

Operating system

Ubuntu

Matplotlib Version

3.5.0

Matplotlib Backend

TkAgg

Python version

3.9.10

Jupyter version

6.4.8

Installation

pip

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy