class_docstr: A multi-tower multi-GPU predictor.
  It builds one predictor for each tower.
docstr: Args:
      config (PredictConfig): the config to use.
      towers: a list of relative GPU id.
docstr_tok: ["Args",":","config","(","PredictConfig",")",":","the","config","to","use",".","towers",":","a","list","of","relative","GPU","id","."]
code: def __init__(self, config, towers):
      """
      Args:
          config (PredictConfig): the config to use.
          towers: a list of relative GPU id.
      """
      assert len(towers) > 0
      self.graph = config._maybe_create_graph()
      self.predictors = []
      self.return_input = config.return_input
      with self.graph.as_default():
          handles = []
  
          input = PlaceholderInput()
          input.setup(config.input_signature)
  
          for idx, t in enumerate(towers):
              tower_name = "tower" + str(t)
  
              device = "/gpu:{}".format(t)
              with tf.variable_scope(
                  tf.get_variable_scope(), reuse=idx > 0
              ), tf.device(device), PredictTowerContext(tower_name):
                  logger.info(
                      "Building graph for predict tower '{}' on device {} ...".format(
                          tower_name, device
                      )
                  )
                  config.tower_func(*input.get_input_tensors())
                  handles.append(config.tower_func.towers[-1])
  
          config.session_init._setup_graph()
          self.sess = config.session_creator.create_session()
          config.session_init._run_init(self.sess)
  
          for h in handles:
              input_tensors = h.get_tensors(config.input_names)
              output_tensors = h.get_tensors(config.output_names)
              self.predictors.append(
                  OnlinePredictor(
                      input_tensors,
                      output_tensors,
                      config.return_input,
                      self.sess,
                  )
              )
  
file_path: tensorpack/tensorpack/predict/multigpu.py
imports: import tensorflow
  from ..input_source import PlaceholderInput
  from ..tfutils.tower import PredictTowerContext
  from ..utils import logger
  from .base import OnlinePredictor
label_desc: Use image node_id 1 to create a new MultiTowerOfflinePredictor object from inherited base classes: OnlinePredictor with example: obj = MultiTowerOfflinePredictor(config, towers)