TensorFlow: How to measure how much GPU memory each tensor takes?

Now that 1258 has been closed, you can enable memory logging in Python by setting an environment variable before importing TensorFlow:

import os
os.environ['TF_CPP_MIN_VLOG_LEVEL']='3'
import tensorflow as tf

There will be a lot of logging as a result of this. You’ll want to grep the results to find the appropriate lines. For example:

grep MemoryLogTensorAllocation train.log

Leave a Comment