Fleet

class paddle.fluid.incubate.fleet.base.fleet_base. Fleet ( mode ) [source]

Fleet is the base class, transpiler and pslib are implementation of Fleet.

Parameters

mode (Mode) – the implementation of Fleet’s mode.

Returns

None

is_first_worker ( )

Check whether the node is the first instance of worker.

Returns

True if this is the first node of worker,

False if not.

Return type

bool

worker_index ( )

Get current worker index.

Returns

node id

Return type

int

worker_num ( )

Get current total worker number.

Returns

worker numbers

Return type

int

is_worker ( )

Check whether the node is an instance of worker.

Returns

True if this is a node of worker,

False if not.

Return type

bool

worker_endpoints ( to_string=False )

Get current server endpoints, such as [“127.0.0.1:1001”, “127.0.0.1:1002”].

Returns

server endpoints

Return type

list/string

server_num ( )

Get current total worker number.

Returns

server number

Return type

int

server_index ( )

Get current server index.

Returns

node id

Return type

int

server_endpoints ( to_string=False )

Get current server endpoints, such as [“127.0.0.1:1001”, “127.0.0.1:1002”].

Returns

server endpoints

Return type

list/string

is_server ( )

Check whether the node is an instance of server.

Returns

True if this is a node of server,

False if not

Return type

bool

is_xpu ( )

Check whether the node is an instance of server.

Returns

True if this is a node of server,

False if not.

Return type

bool

split_files ( files )

split files before distributed training, example 1: files is [a, b, c ,d, e] and trainer_num = 2, then trainer

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/fluid/incubate/fleet/base/fleet_base.py:docstring of paddle.fluid.incubate.fleet.base.fleet_base.Fleet.split_files, line 3)

Unexpected indentation.

0 gets [a, b, c] and trainer 1 gets [d, e].

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/fluid/incubate/fleet/base/fleet_base.py:docstring of paddle.fluid.incubate.fleet.base.fleet_base.Fleet.split_files, line 4)

Block quote ends without a blank line; unexpected unindent.

example 2: files is [a, b], and trainer_num = 3, then trainer 0 gets

[a], trainer 1 gets [b], trainer 2 gets []

Parameters

files (list) – file list need to be read.

Returns

files belongs to this worker.

Return type

list

init ( role_maker=None )

should be called only once in user’s python scripts, init() will initialize RoleMaker which is used for identifying

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/fluid/incubate/fleet/base/fleet_base.py:docstring of paddle.fluid.incubate.fleet.base.fleet_base.Fleet.init, line 3)

Unexpected indentation.

current node’s role, e.g. worker, server, etc.

Parameters

role_maker (RoleMakerBase) – subclass of RoleMakerBase.

Returns

None

all_reduce_worker ( input, output )

all reduce between workers, only support array of one dim.

Parameters
  • input (list|numpy.array) – array of one dim

  • output (list|numpy.array) – array of one dim

barrier_worker ( )

barrier between workers