question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

a memory leak in evaluation

See original GitHub issue

Environment info

  • transformers version: 4.4.0.dev0
  • Platform: Linux-3.10.0-957.el7.x86_64-x86_64-with-glibc2.10
  • Python version: 3.8.8
  • PyTorch version (GPU?): 1.7.1+cu101 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Using GPU in script?: True
  • Using distributed or parallel set-up in script?: False

Who can help

@sgugger

Information

Model I am using (Bert, XLNet …): albert-base-v2 but use a hidden_size of 2048 and a num_attention_heads of 16, distilled from albert-xlarge-v2.

The problem arises when using:

  • the official example scripts: (give details below) examples/text-classification/run_glue.py

The tasks I am working on is:

  • an official GLUE/SQUaD task: (give the name) GLUE QQP task

To reproduce

Steps to reproduce the behavior:

I want to evaluate my model on the GLUE QQP task. If I don’t use eval_accumulation_step, my GPUs are OOM. But if I use eval_accumulation_step and my memory usage will grow up to the memory limit (>250GB) until the first process is killed due to this issue. So I assumed that maybe there is a memory leak. My running script is as below.

CUDA_VISIBLE_DEVICES=0 ~/.conda/envs/thesis-lyh/bin/python run_glue.py \
  --model_name_or_path $MODEL_PATH \
  --task_name $TASK_NAME \
  --eval_accumulation_step 1 \
  --do_eval \
  --max_seq_length 128 \
  --per_device_eval_batch_size 1 \
  --output_dir output/glue/$TASK_NAME/$MODEL_NAME/

No matter what batch_size and accumulation_step are set to, the above problem still occurs. But I am doing fine in models hosted in the model hub and a smaller model I distilled in the same way.

Expected behavior

I have 250GB RAM so it should be enough to save the result.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nooblyhcommented, Apr 6, 2021

Thank you for your reply. I double-check my config today and find that I am reusing the config from distillation and the output_hidden_states is set to true…I am very sorry for my carelessness and thank you so much for your time and attention.

0reactions
sguggercommented, Apr 6, 2021

Ah I understand better now 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Detect and Prevent Memory Leaks | Scout APM Blog
Memory leak is the gradual loss of available computer memory when a program repeatedly fails to return memory it obtained for temporary use....
Read more >
Hunting Java Memory Leaks - Toptal
Fixing memory leaks in Java involves observing symptoms, using verbose GC and profiling, and analyzing memory traces, followed by a thorough review of...
Read more >
Top 20+ Memory Leak Detection Tools for Java and C++
List and Comparison of the top Memory Leak Detection and Management Tools for Java, JavaScript, C, C++, Visual Studio on Linux, Windows and ......
Read more >
Memory leak - HaskellWiki
A memory leak means that a program allocates more memory than necessary for its execution. Although Haskell implementations use garbage ...
Read more >
3 Troubleshoot Memory Leaks - Java - Oracle Help Center
The Java Flight Recorder (JFR) is a commercial feature. You can use it for free on developer desktops or laptops, and for evaluation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found