海阔天空蓝

一个玩过n种运动的语音合成算法攻城狮

0%

multiple_gpu

多GPU并行计算,训练和推理

先来回顾一下Python的多进程multiprocessing和多线程Threading

多进程

https://zhuanlan.zhihu.com/p/85821779

多线程

适合IO密集型任务,不适合CPU密集型任务(如循环,计数)

https://python.land/python-concurrency/the-python-gil

多线程 VS 多进程

https://zhuanlan.zhihu.com/p/20953544

接下来再看下torch实现多GPU并行计算的几种方法

DDP DistributedDataParallel VS DataParallel

  1. DDP 多进程,多线程; DP 单进程,多线程
  2. DDP 可以分布式计算,DP只能单台机器计算
  3. DDP 可以model paralle,DP不可

https://blog.csdn.net/qq_37541097/article/details/109736159

在Pytorch中使用多GPU的常用启动方式一种是torch.distributed.launch一种是torch.multiprocessing模块。