MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / SyncMultiGPUTrainerParameterServer

Class SyncMultiGPUTrainerParameterServer

tensorpack/train/trainers.py:76–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75
76class SyncMultiGPUTrainerParameterServer(SingleCostTrainer):
77
78 __doc__ = SyncMultiGPUParameterServerBuilder.__doc__ + """
79
80 Attributes:
81 devices (list[int]): List of GPU ids.
82
83 """
84
85 @map_arg(gpus=_int_to_range)
86 def __init__(self, gpus, ps_device=None):
87 """
88 Args:
89 gpus ([int]): list of GPU ids.
90 ps_device: either 'gpu' or 'cpu', where variables are stored.
91 The default value is subject to change.
92 """
93 self.devices = gpus
94 if ps_device is None:
95 ps_device = 'gpu' if len(gpus) <= 2 else 'cpu'
96 self._builder = SyncMultiGPUParameterServerBuilder(gpus, ps_device)
97 super(SyncMultiGPUTrainerParameterServer, self).__init__()
98
99 def _setup_graph(self, input, get_cost_fn, get_opt_fn):
100 if len(self.devices) > 1:
101 assert isinstance(input, FeedfreeInput), input
102 tower_fn = self._make_get_grad_fn(input, get_cost_fn, get_opt_fn)
103 grad_list = self._builder.call_for_each_tower(tower_fn)
104 self.train_op = self._builder.build(grad_list, get_opt_fn)
105 return []
106
107
108def SyncMultiGPUTrainer(gpus):

Callers 7

__init__Method · 0.85
SyncMultiGPUTrainerFunction · 0.85
cifar10-resnet.pyFile · 0.85
CAM-resnet.pyFile · 0.85
cifar-convnet.pyFile · 0.85
shufflenet.pyFile · 0.85
mnist-keras.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected