Function to create model that run on many GPUs and creates a net for parameter_updates that can be run independently for number of iterations then followed by another net that runs once to compute the final parameter updates according to block wise model update filtering rule descri
(
model_helper_obj,
input_builder_fun,
forward_pass_builder_fun,
param_update_builder_fun,
block_learning_rate=1.0,
block_momentum=None,
devices=None,
rendezvous=None,
net_type='dag',
master_device=None,
use_nccl=False,
nesterov=False,
optimize_gradient_memory=False,
reset_momentum_sgd=False,
warmup_iterations=None,
max_concurrent_distributed_ops=4,
add_blobs_to_sync=None,
num_threads_per_device=4,
cpu_device=False,
barrier_net_timeout_sec=_DEFAULT_BARRIER_NET_TIMEOUT_SEC,
)
| 425 | |
| 426 | |
| 427 | def Parallelize_BMUF( |
| 428 | model_helper_obj, |
| 429 | input_builder_fun, |
| 430 | forward_pass_builder_fun, |
| 431 | param_update_builder_fun, |
| 432 | block_learning_rate=1.0, |
| 433 | block_momentum=None, |
| 434 | devices=None, |
| 435 | rendezvous=None, |
| 436 | net_type='dag', |
| 437 | master_device=None, |
| 438 | use_nccl=False, |
| 439 | nesterov=False, |
| 440 | optimize_gradient_memory=False, |
| 441 | reset_momentum_sgd=False, |
| 442 | warmup_iterations=None, |
| 443 | max_concurrent_distributed_ops=4, |
| 444 | add_blobs_to_sync=None, |
| 445 | num_threads_per_device=4, |
| 446 | cpu_device=False, |
| 447 | barrier_net_timeout_sec=_DEFAULT_BARRIER_NET_TIMEOUT_SEC, |
| 448 | ): |
| 449 | ''' |
| 450 | Function to create model that run on many GPUs and creates a net for |
| 451 | parameter_updates that can be run independently for number of iterations |
| 452 | then followed by another net that runs once to compute the final parameter |
| 453 | updates according to block wise model update filtering rule described |
| 454 | in : Scalable Training of Deep Learning Machines by Incremental Block |
| 455 | Training with Intra-block Parallel Optimization and Blockwise Model-Update |
| 456 | Filtering (ICASSP 2016). |
| 457 | ''' |
| 458 | assert scope.CurrentDeviceScope() is None \ |
| 459 | or scope.CurrentDeviceScope().device_type == caffe2_pb2.CPU, \ |
| 460 | "Parallelize must be called without device-scope, \ |
| 461 | device scope was: {}".format(scope.CurrentDeviceScope()) |
| 462 | |
| 463 | assert isinstance(model_helper_obj, model_helper.ModelHelper) |
| 464 | |
| 465 | if devices is None: |
| 466 | devices = list(range(0, workspace.NumGpuDevices())) |
| 467 | if master_device is None: |
| 468 | master_device = devices[0] |
| 469 | |
| 470 | if not cpu_device: |
| 471 | for gpu in devices: |
| 472 | if gpu >= workspace.NumGpuDevices(): |
| 473 | log.warning("** Only {} GPUs available, GPUs {} requested".format( |
| 474 | workspace.NumGpuDevices(), devices)) |
| 475 | break |
| 476 | model_helper_obj._device_type = workspace.GpuDeviceType |
| 477 | model_helper_obj._device_prefix = "gpu" |
| 478 | else: |
| 479 | model_helper_obj._device_type = caffe2_pb2.CPU |
| 480 | model_helper_obj._device_prefix = "cpu" |
| 481 | |
| 482 | model_helper_obj._devices = devices |
| 483 | model_helper_obj._rendezvous = rendezvous |
| 484 | model_helper_obj._sync_barrier_net = None |
no test coverage detected
searching dependent graphs…