Blick auf den Code:Wo läuft Tensorflow Ops? CPU oder GPU?
import tensorflow as tf
with tf.device('/gpu:0'):
with tf.device('/cpu:0'):
x = tf.constant(0,name='x')
x = x * 2
y = x + 2
config = tf.ConfigProto(log_device_placement=True)
with tf.Session(config=config) as sess:
sess.run(y)
Wenn Sie es ausführen, wird das Ergebnis erhalten.
mul: (Mul): /job:localhost/replica:0/task:0/cpu:0
2017-08-11 21:38:23.953846: I c:\tf_jenkins\home\workspace\release-win\m\windows
-gpu\py\35\tensorflow\core\common_runtime\simple_placer.cc:847] mul: (Mul)/job:l
ocalhost/replica:0/task:0/cpu:0
add: (Add): /job:localhost/replica:0/task:0/gpu:0
2017-08-11 21:38:23.954846: I c:\tf_jenkins\home\workspace\release-win\m\windows
-gpu\py\35\tensorflow\core\common_runtime\simple_placer.cc:847] add: (Add)/job:l
ocalhost/replica:0/task:0/gpu:0
add/y: (Const): /job:localhost/replica:0/task:0/gpu:0
2017-08-11 21:38:23.954846: I c:\tf_jenkins\home\workspace\release-win\m\windows
-gpu\py\35\tensorflow\core\common_runtime\simple_placer.cc:847] add/y: (Const)/j
ob:localhost/replica:0/task:0/gpu:0
mul/y: (Const): /job:localhost/replica:0/task:0/cpu:0
2017-08-11 21:38:23.954846: I c:\tf_jenkins\home\workspace\release-win\m\windows
-gpu\py\35\tensorflow\core\common_runtime\simple_placer.cc:847] mul/y: (Const)/j
ob:localhost/replica:0/task:0/cpu:0
x: (Const): /job:localhost/replica:0/task:0/cpu:0
2017-08-11 21:38:23.954846: I c:\tf_jenkins\home\workspace\release-win\m\windows
-gpu\py\35\tensorflow\core\common_runtime\simple_placer.cc:847] x: (Const)/job:l
ocalhost/replica:0/task:0/cpu:0
Es bedeutet, die mul
läuft auf cpu
und add
läuft auf gpu
. So ziehe ich eine Schlussfolgerung, dass where does ops or tensors define where does ops or tensors run
.
Und wenn ich die Inception sehe, habe ich verwirrt.
with slim.arg_scope([slim.variables.variable], device='/cpu:0'):
# Calculate the loss for one tower of the ImageNet model. This
# function constructs the entire ImageNet model but shares the
# variables across all towers.
loss = _tower_loss(images_splits[i], labels_splits[i], num_classes,
scope, reuse_variables)
Die tower_loss auf cpu zu definieren, die jedes gpu bedeutet, dass nach meinem Abschluss Verlust auf CPU laufen. Aber ich denke, jede GPU sollte eine Replik auf GPU laufen. Also, verstehe ich das falsch?
'/ gpu: I' ist Elternteil von'/cpu: 0 ', view [diese] (https://github.com/ tensorflow/models/blob/master/inception/inception/inception_train.py # L233), also '/ cpu: 0' überschreiben'/gpu: i'. – gaussclb
hier meinte ich Eltern und Kind mit dem 'Baum' Konzept. ..inneres assigment sind Kind; nicht Elternteil. 'gpu: i' sind innere Zuordnung –
'/gpu: i' ist außerhalb von '/ cpu: 0' – gaussclb