I have a loop in TensorFlow that looks like this:
with tf.device("/gpu:1"): losses = [] for target, output in zip(targets, lstm_outputs): logits = tf.matmul(W, output) + b loss = tf.nn.sparse_softmax_cross_entropy_with_logits(logits, target) losses.append(loss) total_loss = tf.add_n(losses)
I get an OOM error when distributing gradients for this level, since each matrix multiplication is a different operation in a graph that takes memory. Is there a way to prevent TensorFlow from simultaneously distributing all of these operations?
source share