
    Αi                     :    S SK r S SKJrJrJrJr  / rS rS rS r	g)    N)get_clusterget_cluster_from_argsget_gpusloggerc           
      2   [         R                  " S5      nUc   S5       e[         R                  " S5      nUc   S5       e[         R                  " S5      nUc   S5       e[        [         R                  " S5      5      nUc   S	5       eUR                  S
5      n[	        U5      n[        U5      nUS:w  a"  XQ:w  a  [
        R                  " SU SU S35        U S:w  a2  U S
R                  U5      :w  a  [
        R                  " SU  SU S35        [         R                  " S5      n	U	c  Un
US:  aQ   [        [         R                  " SS5      5      nU[	        U5      :  a!  X:w  a  [
        R                  " SU S35        Un
U
c  Sn
[        [        X[	        U5      -   5      5      n/ n	U H)  nU	R                  U Vs/ s H	  o SU 3PM     sn5        M+     OUU	R                  S
5      n/ n	X-  [	        U5      :X  d   e[        U5       H   nU	R                  UUU-  US-   U-   5        M"     [
        R                  " SU SU SU SU	 35        [        XEX5      u  nnUUR                  U   4$ ! [         a  n[        U5         SnAGN	SnAff = fs  snf )zR
args_node_ips:string, args_node_ip:string, args_port: int, selected_devices:list
PADDLE_TRAINERSNz"PADDLE_TRAINERS should not be NonePOD_IPzPOD_IP should not be NonePADDLE_TRAINER_IDz$PADDLE_TRAINER_ID should not be NoneTRAINER_PORTS_NUMz$TRAINER_PORTS_NUM should not be None,z	127.0.0.1zcPlease NOTE: When using paddlecloud, node_ip is automatically got from POD_IP. Your input node_ip: z doesn't equals to node_ip: z from paddlecloud environment.zPlease NOTE: When using paddlecloud, cluster_node_ips is automatically got from PADDLE_TRAINERS(multi nodes) or POD_IP(single node).Your input cluster_node_ips: z doesn't equals to IPs: DISTRIBUTED_TRAINER_ENDPOINTS   PADDLE_PORT zUse Cloud specified port:.i  :zparsed from args: node_ips:z         node_ip:z node_rank:z trainer_endpoints:)osgetenvintsplitlenr   warningjoin	Exceptionprintlistrangeappenddebugr   pods)args_node_ipsargs_node_ip	args_portselected_devicesnode_ipsnode_ip	node_rankpaddle_ports_num	num_nodestrainer_endpointsstarted_portpaddle_porteportsipporttrainer_endpoints_oriiclusterpods                       ^/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/distributed/cloud_utils.pyget_cloud_clusterr6      s   
 yy*+HE!EEii!G; ;;		-.I H"HH 299%89:'O)OO'~~c"HHIII+'"944@> B

02	
 #(9K(K+_,DXJ O	
 		"AB  q=!"))M2">? %,<(==#0NN%>{m1#MN#.L
 LU<<L8M)MNOB$$%GAdVn%GH  !2 7 7 <+s3H/IIIIy!A$$%((AE5E+E " LL
%hZ 0	YK/BCTBU	W
 ,LGS GLL+++9  a &Hs   3AI1 >J
1
J;JJc                  B    [        [        R                  " SS5      5      $ )NPADDLE_TRAINERS_NUM1)r   r   r        r5   _get_trainers_numr<   n   s    ryy.455r;   c                    [        U R                  5      n[        5       n[        R                  " SU SU 35        S nS nU R
                  (       aP  US:w  aJ  [        U R                  U R                  U R                  U5      u  p4[        R                  " SU 35        X44$ [        X5      u  p4[        R                  " SU 35        X44$ )Nzparsed from args trainerss_num:z selected_devices:r   zget cluster from cloud:zget cluster from args:)r   r$   r<   r   r   use_paddlecloudr6   cluster_node_ipsr&   r+   infor   )argsr$   trainers_numr3   r4   s        r5   get_cluster_and_podrC   r   s     5 56$&L
LL
),7IJZI[\ G
C 1(!!LL	
 	-gY78
 < -TD,WI67<r;   )
r   %paddle.distributed.utils.launch_utilsr   r   r   r   __all__r6   r<   rC   r:   r;   r5   <module>rF      s,    
  P,f6r;   