Shortcuts

torch.nn.functional.torch.nn.parallel.data_parallel

torch.nn.parallel.data_parallel(module, inputs, device_ids=None, output_device=None, dim=0, module_kwargs=None)[源代码]

在 device_ids 中指定的 GPU 上并行评估模块(input)。

这是DataParallel模块的功能版本。

Parameters
  • 模块 (模块) – 要在并行中评估的模块

  • 输入 (张量) – 模块的输入

  • device_ids列表整数torch.device)– 要在其上复制模块的GPU id

  • output_device (list of int or torch.device) – 输出所在的GPU位置 使用-1表示CPU。 (默认值: device_ids[0])

Returns

一个包含位于 output_device 上的 module(input) 结果的张量

Return type

张量