tensorflow / tensorflow/probability

Memory leak in tfp.math.minimize, reproducible from tutorial notebook

Open
#1,995 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Python version: 3.11.6
tensorflow==2.18.0
# via
# -r requirements.in
# tf-keras
tensorflow-probability==0.24.0
# via -r requirements.in
tf-keras==2.18.0
# via -r requirements.in

I am trying to perform an analysis built on the multiple changepoint detection and Bayesian model selection code found in this tutorial notebook: https://www.tensorflow.org/probability/examples/Multiple_changepoint_detection_and_Bayesian_model_selection

In the process of running the analysis for multiple datasets I observed that the memory used increases with each successive analysis, by about 20 MB per run in my code. I confirmed that this occurs with the original tutorial notebook as well to ensure that there is not an error specific to my code. The easiest way to reproduce is to download the notebook, execute all cells, then rerun from the "Unknown number of states" section. I have tried adding tf_keras.backend.clear_session() between each run, deleting all created objects before rerunning, and running garbage collection, but nothing has released the ~20MB of memory that is allocated with each tfp.math.minimize run.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Multiple changepoint detection and Bayesian model selection tutorial notebook and reproduce the issue by executing all cells, then rerunning from the “Unknown number of states” section. Compare memory across repeated runs of tfp.math.minimize and verify that the approximately 20 MB increase per run no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.