Open
Description
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