What is the format of device filters in TensorFlow?

Thus, the session configuration protocol has the device_filters option, with a comment:

// When any filters are present sessions will ignore all devices which do not // match the filters. Each filter can be partially specified, eg "/job:ps" // "/job:worker/replica:3", etc. 

Does anyone have a specific explanation for the format? For example, I want to exclude / gpu: 0 as an option, because I use it to run other models.

I tried

 config = tf.ConfigProto() config.device_filters.append('/gpu:1') config.device_filters.append('/cpu:0') with tf.Session(config=config): # Do stuff 

But I still get ops assigned by gpu 0. I don't want to redefine op-op based devices.

+7
python tensorflow
source share
1 answer

The ConfigProto.device_filters field is currently ignored by TensorFlow, although it is intended to support your future use case. If you want to achieve the same end of ops on /gpu:1 and /cpu:0 , you can do it this way using "soft placement":

 with tf.device("/gpu:1"): # Build your model in this with context. All nodes will get the # device "/gpu:1". with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)): # Execute your mode in this with context. # Soft placement will use /gpu:1 for GPU-compatible ops, and /cpu:0 # for CPU-only ops. 
+3
source share

All Articles