zoukankan      html  css  js  c++  java
  • Caffe2 初识

    官方网址上的这两句话很好的阐述了Caffe2的特点“A New Lightweight, Modular, and Scalable Deep Learning Framework”、“Code once, run anywhere”。我比较关心的第一个问题是,怎么利用多个GPU加速训练呢?

    Synchronous SGD

    There are multiple ways to utilize multiple GPUs or machines to train models. Synchronous SGD, using Caffe2’s data parallel model, is the simplest and easiest to understand: each GPU will execute exactly same code to run their share of the mini-batch. Between mini-batches, we average the gradients of each GPU and each GPU executes the parameter update in exactly the same way. At any point in time the parameters have same values on each GPU. Another way to understand Synchronous SGD is that it allows increasing the mini-batch size. Using 8 GPUS to run a batch of 32 each is equivalent to one GPU running a mini-batch of 256.

    之前一直不是很明白应用多核GPU加速的原理是什么,读了上述一段话之后,豁然开朗。真的希望自己有一天,也能用寥寥数语将一个复杂概念解释清楚。上述英文的要点可以归结如下(假如我们有八个GPU):

    • 每一个GPU执行相同的代码;
    • 每一个GPU的输入数据不同;
    • 每一个GPU的参数是相同的,gradients是各个GPU得到结果的平均值,每一个GPU都用这一梯度更新相应参数。

    如果在一个GPU上我们设置Batch size为256,在并行训练时,其等效设置为,这八个GPU,每个GPU的Batch size为32。这可以概括为“顺序执行转为并行执行”。

  • 相关阅读:
    我的第一个网络爬虫
    python中os模块的walk函数
    <Think Python>中统计文献单词的处理代码
    <Think Python>中斐波那契使用memo实现的章节
    Python中bisect的使用
    vim中使用系统粘贴板
    linux下的重命名
    HTML Dog 初级教程中关于 forms 的翻译
    unittest:1 用例编写
    python UI自动化实战记录十一: 总结
  • 原文地址:https://www.cnblogs.com/everyday-haoguo/p/Caffe2-SyncSGD.html
Copyright © 2011-2022 走看看