Commit 91db7c18 authored by Bharath Ramsundar's avatar Bharath Ramsundar Committed by GitHub
Browse files

Merge pull request #746 from Moooooooon/master

Yapfed_Preventing TF from allocating all of the GPU mem
parents beb03094 13abfdd5
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -438,8 +438,8 @@ class TensorflowGraphModel(Model):
    feeding and fetching the same tensor.
    """
    weights = []
    placeholder_scope = TensorflowGraph.get_placeholder_scope(graph,
                                                              name_scopes)
    placeholder_scope = TensorflowGraph.get_placeholder_scope(
        graph, name_scopes)
    with placeholder_scope:
      for task in range(self.n_tasks):
        weights.append(
@@ -482,11 +482,15 @@ class TensorflowGraphModel(Model):
    if train:
      if not self.train_graph.session:
        config = tf.ConfigProto(allow_soft_placement=True)
        #gpu memory growth option
        config.gpu_options.allow_growth = True
        self.train_graph.session = tf.Session(config=config)
      return self.train_graph.session
    else:
      if not self.eval_graph.session:
        config = tf.ConfigProto(allow_soft_placement=True)
        #gpu memory growth option
        config.gpu_options.allow_growth = True
        self.eval_graph.session = tf.Session(config=config)
      return self.eval_graph.session

@@ -639,8 +643,8 @@ class TensorflowClassifier(TensorflowGraphModel):
    Placeholders are wrapped in identity ops to avoid the error caused by
    feeding and fetching the same tensor.
    """
    placeholder_scope = TensorflowGraph.get_placeholder_scope(graph,
                                                              name_scopes)
    placeholder_scope = TensorflowGraph.get_placeholder_scope(
        graph, name_scopes)
    with graph.as_default():
      batch_size = self.batch_size
      n_classes = self.n_classes
@@ -792,8 +796,8 @@ class TensorflowRegressor(TensorflowGraphModel):
    Placeholders are wrapped in identity ops to avoid the error caused by
    feeding and fetching the same tensor.
    """
    placeholder_scope = TensorflowGraph.get_placeholder_scope(graph,
                                                              name_scopes)
    placeholder_scope = TensorflowGraph.get_placeholder_scope(
        graph, name_scopes)
    with graph.as_default():
      batch_size = self.batch_size
      labels = []