第6章構築者のための手引き
6.7.4. Summary6.7.4 まとめ
We can specify devices for storage and calculation, such as the CPU or GPU. By default, data is created in the main memory and then uses the CPU for calculations. The deep learning framework requires all input data for calculation to be on the same device, be it CPU or the same GPU. You can lose significant performance by moving data without care. A typical mistake is as follows: computing the loss for every minibatch on the GPU and reporting it back to the user on the command line (or logging it in a NumPy
ndarray) will trigger a global interpreter lock which stalls all GPUs. It is much better to allocate memory for logging inside the GPU and only move larger logs.英語のヒント
保存と計算のために、CPUやGPUといったデバイスを指定できる。既定では、データはメインメモリに作られ、計算にはCPUが使われる。深層学習のフレームワークは、計算のための入力データがすべて、CPUであれ同じGPUであれ、同じデバイス上にあることを求める。不注意にデータを動かすと、性能を大きく失いかねない。典型的な間違いは次のとおりである。ミニバッチごとにGPU上で損失を計算し、それをコマンドラインで利用者に報告する(あるいはNumPyの
ndarrayに記録する)と、グローバルインタプリタロックが引き起こされ、すべてのGPUが止まってしまう。記録用のメモリはGPUの中に割り当て、大きな記録だけを動かすほうがずっとよい。