第13章計算の性能
13.3. Automatic Parallelism13.3 自動並列化
Deep learning frameworks (e.g., MXNet and PyTorch) automatically construct computational graphs at the backend. Using a computational graph, the system is aware of all the dependencies, and can selectively execute multiple non-interdependent tasks in parallel to improve speed. For instance, Fig. 13.2.2 in Section 13.2 initializes two variables independently. Consequently the system can choose to execute them in parallel.
英語のヒント
Typically, a single operator will use all the computational resources on all CPUs or on a single GPU. For example, the
dot operator will use all cores (and threads) on all CPUs, even if there are multiple CPU processors on a single machine. The same applies to a single GPU. Hence parallelization is not quite so useful for single-device computers. With multiple devices things matter more. While parallelization is typically most relevant between multiple GPUs, adding the local CPU will increase performance slightly. For example, see Hadjis et al. (2016) that focuses on training computer vision models combining a GPU and a CPU. With the convenience of an automatically parallelizing framework we can accomplish the same goal in a few lines of Python code. More broadly, our discussion of automatic parallel computation focuses on parallel computation using both CPUs and GPUs, as well as the parallelization of computation and communication.英語のヒント
ふつう、一つの演算子は、すべてのCPUか一つのGPUの計算資源をすべて使う。たとえば、
dot演算子は、一つのマシンに複数のCPUプロセッサがあっても、すべてのCPUのすべてのコア(とスレッド)を使う。同じことが一つのGPUにも当てはまる。したがって、並列化は、装置が一つのコンピュータではあまり役に立たない。装置が複数あると、事情はもっと重要になる。並列化はふつう複数のGPUのあいだで最も重要だが、ローカルのCPUを加えると性能が少し上がる。たとえば、GPUとCPUを組み合わせてコンピュータビジョンのモデルを訓練することに焦点を当てたHadjis et al. (2016)を参照。自動的に並列化するフレームワークの便利さがあれば、同じ目標を数行のPythonのコードで達成できる。もっと広く言えば、自動並列計算についての議論は、CPUとGPUの両方を使う並列計算と、計算と通信の並列化に焦点を当てる。Note that we need at least two GPUs to run the experiments in this section.
英語のヒント
この節の実験を動かすには、少なくとも二つのGPUが要ることに注意してほしい。
import torch
from d2l import torch as d2l