diff --git a/source/user_guides/howto/training/cluster_howto.rst b/source/user_guides/howto/training/cluster_howto.rst index 6ce04ccff468e29dfd1b09908aa7803a874e09cb..db8a61f9d2c09a38bbf53aa08a47e04dffd495a5 100644 --- a/source/user_guides/howto/training/cluster_howto.rst +++ b/source/user_guides/howto/training/cluster_howto.rst @@ -16,8 +16,8 @@ Fluid分布式训练使用手册 诸如模型并行的特例实现(超大稀疏模型训练)功能将在后续的文档中予以说明。 在数据并行模式的训练中,Fluid使用了两种通信模式,用于应对不同训练任务对分布式训练的要求,分别为RPC通信和Collective -通信。其中RPC通信方式使用 `gRPC`_ ,Collective通信方式使用 - `NCCL2`_ ,Collective通信方式使用 + `NCCL2 `_ +方式将参数分布在多个parameter server上。此方式在默认未关闭参数切分的情况下,参数会较平均的分布在所有的 +parameter server上。如果需要使用其他,可以传入其他的方法,目前可选的方法有: :code:`RoundRobin` 和 +:code:`HashName` 。也可以使用自定义的分布方式,只需要参考 +`这里 `_ +编写自定义的分布函数。 + + +关闭切分参数 +++++++++++ + +参数 :code:`slice_var_up` 指定是否将较大(大于8192个元素)的参数切分到多个parameter server已均衡计算负载,默认为开启。 + +当模型中的可训练参数体积比较均匀或者使用自定义的参数分布方法是参数均匀分布在多个parameter server上, +可以选择关闭切分参数,这样可以降低切分和重组带来的计算和拷贝开销: + +.. code-block:: python + + t.transpile(trainer_id, pservers=pserver_endpoints, trainers=trainers, slice_var_up=False) + + + 使用NCCL2通信方式的训练 -------------------- @@ -92,3 +132,15 @@ parameter server的进程,只需要启动多个trainer进程即可: "PADDLE_PSERVER_PORT", "一个端口,用于在NCCL2初始化时,广播NCCL ID" "PADDLE_CURRENT_IP", "当前节点的IP" +目前使用NCCL2进行分布式训练仅支持同步训练方式。使用NCCL2方式的分布式训练,更适合模型体积较大,并需要使用 +同步训练和GPU训练,如果硬件设备支持RDMA和GPU Direct,可以达到很高的分布式训练性能。 + +注意如果系统中有多个网络设备,需要手动指定NCCL2使用的设备, +假设需要使用 :code:`eth2` 为通信设备,需要设定如下环境变量: + +.. code-block:: bash + + export NCCL_SOCKET_IFNAME=eth2 + +另外NCCL2提供了其他的开关环境变量,比如指定是否开启GPU Direct,是否使用RDMA等,详情可以参考 +`ncclknobs `_ 。 diff --git a/source/user_guides/howto/training/src/dist_train_nccl2.graffle b/source/user_guides/howto/training/src/dist_train_nccl2.graffle index d26db8657dbd4661af49723cfaf45c6c3bb931d4..16f6b8835c4ffb82babca56b62ba44494fd6a947 100644 Binary files a/source/user_guides/howto/training/src/dist_train_nccl2.graffle and b/source/user_guides/howto/training/src/dist_train_nccl2.graffle differ diff --git a/source/user_guides/howto/training/src/dist_train_nccl2.png b/source/user_guides/howto/training/src/dist_train_nccl2.png index 6a35baa06eedb47e88d434803980573db0bf59cc..587a1a48affdde6809d7f8bf77e1055db7cd8c14 100644 Binary files a/source/user_guides/howto/training/src/dist_train_nccl2.png and b/source/user_guides/howto/training/src/dist_train_nccl2.png differ diff --git a/source/user_guides/howto/training/src/dist_train_pserver.graffle b/source/user_guides/howto/training/src/dist_train_pserver.graffle index d65172c5ab84a1e312a679381a9fb9be65c1acba..046c4903231e8ca441884674c08b381766c0bbae 100644 Binary files a/source/user_guides/howto/training/src/dist_train_pserver.graffle and b/source/user_guides/howto/training/src/dist_train_pserver.graffle differ diff --git a/source/user_guides/howto/training/src/dist_train_pserver.png b/source/user_guides/howto/training/src/dist_train_pserver.png index 9f39894dd6bf1853957d6c7612c54b208f0f5e06..cd2f92ad1a14ac12efc2c257c8aa3d1ae403b2b1 100644 Binary files a/source/user_guides/howto/training/src/dist_train_pserver.png and b/source/user_guides/howto/training/src/dist_train_pserver.png differ