Coder Social home page Coder Social logo

ellinyang / fleet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paddlepaddle/paddlefleetx

0.0 0.0 0.0 487.65 MB

飞桨分布式训练API-基线-示例-算法包

License: Apache License 2.0

Python 36.27% Makefile 0.31% C++ 2.53% Cuda 1.78% C 57.73% Shell 1.33% CMake 0.05%

fleet's Introduction

Fleet

Fleet is High-Level API for distributed training in PaddlePaddle. The name of Fleet means that a large crowd of ships working together to finish a large scale job. The design of Fleet makes a trade-off between easy-to-use and algorithmic extensibility and is highly efficient. First, a user can shift from local machine paddlepaddle code to distributed code within ten lines of code. Second, different algorithms can be easily defined through distributed strategy through Fleet API. Finally, distributed training is extremely fast with Fleet and just enjoy it.

Note: all the examples here should be replicated from develop branch of Paddle

Fleet is Highly Efficient

Deep neural networks training with Fleet API is highly efficient in PaddlePaddle. We benchmark serveral standard models here.

Parameter Server Training

Parameter server training benchmark is performed on click through rate estimation task on Criteo Dataset and Semantic Representation Learning on One-billion word Dataset. Details of hardware and software information for this benchmark can be found in parameter server benchmark.

Collective Training

Collective Training is usually used in GPU training in PaddlePaddle. Benchmark of collective training with Fleet is as follows. Details of hardware and software information for this benchmark can be found in benchmark environment.

Mixed precision accelerated collective training throughput

Fleet is Easy To Use

Fleet is easy to use for both collective training and parameter server training. Here is an example for collective training with Fleet.

Local Single GPU Cards Training

import paddle.fluid as fluid
from utils import gen_data
from nets import mlp

input_x = fluid.layers.data(name="x", shape=[32], dtype='float32')
input_y = fluid.layers.data(name="y", shape=[1], dtype='int64')

cost = mlp(input_x, input_y)
optimizer = fluid.optimizer.SGD(learning_rate=0.01)
optimizer.minimize(cost, fluid.default_startup_program())

train_prog = fluid.default_main_program()
gpu_id = int(os.environ.get('FLAGS_selected_gpus', 0))
place = fluid.CUDAPlace(gpu_id) if args.use_gpu else fluid.CPUPlace()

exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())

step = 1001
for i in range(step):
    cost_val = exe.run(program=train_prog, feed=gen_data(), fetch_list=[cost.name])

Local Multiple GPU Cards Training

import paddle.fluid as fluid
from utils import gen_data
from nets import mlp
from paddle.fluid.incubate.fleet.collective import fleet, DistributedStrategy  # new line 1 
from paddle.fluid.incubate.fleet.base import role_maker # new line 2

input_x = fluid.layers.data(name="x", shape=[32], dtype='float32')
input_y = fluid.layers.data(name="y", shape=[1], dtype='int64')

cost = mlp(input_x, input_y)
optimizer = fluid.optimizer.SGD(learning_rate=0.01)

role = role_maker.PaddleCloudRoleMaker(is_collective=True) # new line 3
fleet.init(role) # new line 4

optimizer = fleet.distributed_optimizer(optimizer, strategy=DistributedStrategy()) # new line 5
optimizer.minimize(cost, fluid.default_startup_program())

train_prog = fleet.main_program # change line 1
place = fluid.CUDAPlace(int(os.environ['FLAGS_selected_gpus'])) # change line 2

exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())

step = 1001
for i in range(step):
    cost_val = exe.run(program=train_prog, feed=gen_data(), fetch_list=[cost.name])

Launch command:

python -m paddle.distributed.launch --selected_gpus="0,1,2,3" trainer.py

More Examples

fleet's People

Contributors

guru4elephant avatar mrchengmo avatar gongweibao avatar mapingshuo avatar 123malin avatar wangxicoding avatar forfishes avatar gavin1332 avatar danleifeng avatar colourful-tree avatar seiriosplus avatar gentelyang avatar suoych avatar raindrops2sea avatar jie-fang avatar xjqbest avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.