I encountered some problems while training my model, specifically, the training speed is sometimes fast and sometimes slow(fluctuating between 2-10 iters per second). After I used tensorboard to check the network operation, I found that the tf.matmul() node was running on CPU device. As follow:
This makes me quite confused, I try to use tf.device('/gpu:0') to enforce that node running on GPU, I also tried to lower the tensorflow version, but none of these work.
below is my code:
def _repeat(x, n_repeats):
with tf.variable_scope('_repeat'):
rep = tf.transpose(
tf.expand_dims(tf.ones(shape=tf_v.stack([n_repeats, ])), 1), [1, 0])
rep = tf.cast(rep, tf.int32)
# with tf.device('/gpu:0'):
x = tf.matmul(tf.reshape(x, (-1, 1)), rep)
return tf.reshape(x, [-1])
by the way, the tensorflow version is 2.2.5, GPU is rtx3090.
