Creates a new TensorFlow MPI session. Unlike a normal `tf.Session`, an MPI Session may only use a single GPU, which must be specified in advance before the session is initialized. In addition, it only uses a single graph evaluation thread, and initializes MPI immediately upon starti
(self, target='', graph=None, config=None)
| 244 | """ |
| 245 | |
| 246 | def __init__(self, target='', graph=None, config=None): |
| 247 | """Creates a new TensorFlow MPI session. |
| 248 | |
| 249 | Unlike a normal `tf.Session`, an MPI Session may only use a single GPU, |
| 250 | which must be specified in advance before the session is initialized. |
| 251 | In addition, it only uses a single graph evaluation thread, and |
| 252 | initializes MPI immediately upon starting. |
| 253 | |
| 254 | If no `graph` argument is specified when constructing the session, |
| 255 | the default graph will be launched in the session. If you are |
| 256 | using more than one graph (created with `tf.Graph()` in the same |
| 257 | process, you will have to use different sessions for each graph, |
| 258 | but each graph can be used in multiple sessions. In this case, it |
| 259 | is often clearer to pass the graph to be launched explicitly to |
| 260 | the session constructor. |
| 261 | |
| 262 | Args: |
| 263 | target: (Optional.) The execution engine to connect to. |
| 264 | graph: (Optional.) The `Graph` to be launched (described above). |
| 265 | config: (Optional.) A `ConfigProto` protocol buffer with configuration |
| 266 | options for the session. |
| 267 | """ |
| 268 | super(Session, self).__init__(target, graph, config=config) |
| 269 | |
| 270 | # Initialize MPI on the relevant device. |
| 271 | # TODO: Move this to library load and eliminate mpi.Session() |
| 272 | if graph is None: |
| 273 | graph = tf.get_default_graph() |
| 274 | with graph.as_default(): |
| 275 | self.run(init()) |
no test coverage detected