get_rank

paddle.distributed.parallel. get_rank ( ) [source]

Returns the rank of current trainer.

Its value is equal to the value of the environment variable PADDLE_TRAINER_ID . The default value is 0.

Returns

(int) The rank of current trainer.

Examples

import paddle
import paddle.distributed as dist

# execute this command in terminal: export PADDLE_TRAINER_ID=0
print("The rank is %d" % dist.get_rank())
# The rank is 0