Reputation: 73
We are trying to recognize numbers on number plates given pictures of it. We have trained the data set based on a single gpu. Is it possible to evaluate the data on multiple gpus without modifying the model? We use Tensorflow library for training and evaluating.
Upvotes: 0
Views: 536
Reputation: 256
It is really difficult to help you without any code. I can give you an insight. To pass from GPU to multi GPU, you have to :
1) Split your data according the number of GPU (be careful of the size, it must be matrix)
2) Build your graph on each gpu with a loop looking like :
with tf.variable_scope(tf.get_variable_scope()) as outer_scope:
for i in enumerate(range(nb_of_GPU)):
name = 'tower_{}'.format(i)
with tf.device("/gpu:"+str(i)), tf.name_scope(name):
logits = self.build_graph(splitted_inputs[i])
batch_loss = self.compute_loss(logits, splitted_labels[i])
batch_acc = self.compute_acc(logits, splitted_labels[i])
losses.append(batch_loss)
accs.append(batch_acc)
tf.summary.scalar("loss", batch_loss)
gradient = optimizer.compute_gradients(batch_loss)
tower_grads.append(gradient)
outer_scope.reuse_variables()
avergage_grads = average_gradients(tower_grads)
train_op = optimizer.apply_gradients(avergage_grads)
You also have to change the size of the placeholder for inputs.
So the answer of your question Is it possible to evaluate the data on multiple gpus without modifying the model? is No. You will have to change some things.
Upvotes: 1