PaddlePaddle Notes

Single and multi-engine training training

use_cuda = True
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
exe = fluid.Executor(place)
fluid.CUDAPlace

Doka Training:

Use  fluid.compiler.CompiledProgram to compile  fluid.Program , and then call with_data_parallel 

train_program = fluid.Program()
if not use_cuda:
    os.environ [ ' CPU_NUM ' ] = str (2 )

compiled_prog = compiler.CompiledProgram(
    train_program).with_data_parallel(
    loss_name=loss.name)
loss_data, = exe.run(compiled_prog,
                     feed={"X": x},
                     fetch_list=[loss.name])

CompiledProgram  will be passed fluid.Program into the calculation map, namely Graph, because compiled_prog the incoming train_program is completely different objects, not yet able to compiled_prog be saved. (How to save)

 

CUDAPlace

 

parameter:
  • id (int, optional) - GPU device ID. If it is  None, the default will be used for the device id of 0. The default value  None.

The sample code

import paddle.fluid as fluid
gpu_place = fluid.CUDAPlace(0)

 这里编号指的是可见显卡的逻辑编号,而不是显卡实际的编号。

 

Guess you like

Origin www.cnblogs.com/shona/p/12238659.html