
    ёi%                    f    S SK Jr  S SKrS SKrS SKr/ rS rS rS r	S r
S rS rS	 rS
 rSS jrg)    )annotationsNc            	        [         R                  R                  S/ SQSS9n [         R                  " SS/S[         R                  " [         R
                  R                  R                  S5      S9S	9n[         R                  " S/SS
9n[         R
                  R                  R                  XUS9n[         R                  R                  U5      nXU4$ )z<
Define a simple network composed by a single linear layer.
input)N   r   float32)nameshapedtyper      g?)initializer)r	   r
   attr)r	   r
   )xweightbias)paddlestaticdatacreate_parameter	ParamAttrnnr   Constant
functionallineartensorsum)r   r   r   
linear_outouts        Z/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/utils/install_check.py_simple_networkr      s     MML	  E $$!f&))*?*?*H*H*MNF
 ""!I>D%%,,u$,OJ
--

J
'Cv    c                 z    [         R                  " SS/SS//[         R                  S9n U R                  SSS5      $ )zC
Prepare feeding data for simple network. The shape is [1, 2, 2].

      ?g       @g      @g      @)r
      r   )nparrayr   reshape)np_input_singles    r   _prepare_datar(   ,   s:     hhc
S#J7rzzJO""1a++r    c                      [        [        R                  R                  5       5      S:  d   eg! [         a#  n [
        R                  " SU  35         Sn A gSn A ff = f)z"
Check whether CUDA is available.
r   TzYou are using GPU version PaddlePaddle, but there is no GPU detected on your machine. Maybe CUDA devices is not set properly.
 Original Error is NF)lenr   r   cuda_places	Exceptionloggingwarninges    r   _is_cuda_availabler1   6   sZ    	6==,,./!333 $$%3(	

    -0 
AAAc                      [        [        R                  R                  5       5      S:  d   eg! [         a#  n [
        R                  " SU  35         Sn A gSn A ff = f)z!
Check whether XPU is available.
r   TzYou are using XPU version PaddlePaddle, but there is no XPU detected on your machine. Maybe XPU devices is not set properly.
 Original Error is NF)r*   r   r   
xpu_placesr,   r-   r.   r/   s    r   _is_xpu_availabler5   F   sZ    	6==++-.222 $$%3(	

 r2   c                Z   [         R                  " 5         U (       a  [         R                  " S5        ORU(       a  [         R                  " S5        O4U(       a  [         R                  " U5        O[         R                  " S5        [         R                  " S[         R                  R
                  R                  SS9S9n[         R                  " S[         R                  R
                  R                  S	S9S9n[         R                  R                  S
SXES9n[        5       n[         R                  " U5      nU" U5      n	[         R                  R                  U	5      n
U
R                  5         [         R                  R                  SUR                  5       S9nUR!                  5         g)z
Testing the simple network in dygraph mode using one CPU/GPU/XPU.

Args:
    use_cuda (bool): Whether running with CUDA.
    use_xpu (bool): Whether running with XPU.
gpuxpucpur   g      ?)value)r   r   r   r"   r      )weight_attr	bias_attrMbP?learning_rate
parametersN)r   disable_static
set_devicer   r   r   r   Linearr(   	to_tensorr   r   backward	optimizerAdamrA   step)use_cudause_xpu
use_customcustom_device_namer<   r=   r   input_npinput_tensorr   r   opts               r   _run_dygraph_singlerQ   V   sD    % 	% 	,-% ""699#8#8#A#A#A#LK   !6!6!?!?c!?!JI YY	1+  F H##H-L%J
--

J
'CLLN




(9(9(;   C HHJr    c                   [         R                  " 5         [         R                  R                  [         R                  R	                  5       5         [         R                  R                  5       n[         R                  R                  5       nSUl        [         R                  R                  XE5         [        5       u  pgn[         R                  R                  Xx/S9S   n	SSS5        U (       a  [         R                  " S5      n
ORU(       a  [         R                  " S5      n
O4U(       a  [         R                  " US5      n
O[         R                  " 5       n
[         R                  R                  U
5      nUR                  U5        UR                  UWR                   [#        5       0WW	S   /S9  SSS5        [         R$                  " 5         g! , (       d  f       N= f! , (       d  f       N5= f)z
Testing the simple network with executor running directly, using one CPU/GPU/XPU.

Args:
    use_cuda (bool): Whether running with CUDA.
    use_xpu (bool): Whether running with XPU.
r#   )parameter_listr   N)feed
fetch_list)r   enable_staticr   scope_guardScopeProgramrandom_seedprogram_guardr   append_backward	CUDAPlaceXPUPlaceCustomPlaceCPUPlaceExecutorrunr   r(   rB   )rJ   rK   rL   rM   
train_progstartup_progr   r   r   param_gradsplaceexes               r   _run_static_singlerh   {   sb    		"	"6==#6#6#8	9]]**,
}},,.#$ ]]((B!0!2E --77H 8 K C $$Q'EOOA&E&&'91=EOO%Emm$$U+**mo.[^, 	 	
+ 
:4 - CB	 
:	9s&   A#G$4/G#CG$
G!	G$$
G2c                 8    " S S[         R                  R                  5      n [         R                  R	                  5         U " 5       n[         R
                  " U5      n[         R                  R                  5       n[         R                  R                  SUR                  5       S9n[         R                  " SS/S5      nU" U5      n[         R                  " SS/S5      nU" Xg5      nUR                  5         UR                  5         UR                  5         g)	z*
train script for parallel training check
c                  2   ^  \ rS rSrSrU 4S jrS rSrU =r$ ))train_for_run_parallel.<locals>.LinearNet   z/
simple fc network for parallel training check
c                   > [         TU ]  5         [        R                  R	                  SS5      U l        [        R                  R	                  SS5      U l        g )N
   r#   )super__init__r   r   rD   _linear1_linear2)self	__class__s    r   rp   2train_for_run_parallel.<locals>.LinearNet.__init__   s>    G"II,,R4DM"II,,R3DMr    c                B    U R                  U R                  U5      5      $ )z	
forward
)rr   rq   )rs   r   s     r   forward1train_for_run_parallel.<locals>.LinearNet.forward   s     ==q!122r    )rq   rr   )	__name__
__module____qualname____firstlineno____doc__rp   rw   __static_attributes____classcell__)rt   s   @r   	LinearNetrk      s    		4
	3 	3r    r   r>   r?   rn   r   r#   N)r   r   Layerdistributedinit_parallel_envDataParallelMSELossrG   rH   rA   randnrF   rI   
clear_grad)	r   layerdp_layerloss_fnadaminputsoutputslabelslosss	            r   train_for_run_parallelr      s    3FIIOO 3  ((*KE""5)Hii!G  (;(;(= ! D \\2r(I.FvG\\2q'9-F7#DMMOIIKOOr    c                Z    [         R                  R                  [        [	        U 5      S9  g)z
Testing the simple network in data parallel mode, using multiple CPU/GPU.

Args:
    use_cuda (bool): Whether running with CUDA.
    use_xpu (bool): Whether running with XPU.
    device_list (int): The specified devices.
)nprocsN)r   r   spawnr   r*   )device_lists    r   _run_parallelr      s#     3C<LMr    c                    [        S5        Sn SnSnSn[        R                  " 5       (       a  [        5       n O[        R                  " 5       (       a  [        5       nO[        [        R                  R                  R                  5       5      S:  az  Sn[        [        R                  R                  R                  5       5      S:  aC  [        R                  " S[        R                  R                  R                  5       S    S35        U (       a!  S	n[        R                  R                  5       nOU(       a!  S
n[        R                  R                  5       nOU(       ai  [        R                  R                  R                  5       S   nUn[        [!        [        R                  R                  R#                  U5      5      5      nOSn[        R                  R%                  SS9n[        U5      n['        XX#5        [)        XX#5        [        SU S35         [        U5      S:  a7  U(       a  SSKnSUR,                  S'   [/        U5        [        SU SU S35        [        S5        g! [0         aL  n[        R                  " SU SU S35        [        R                  " SU 35        [        SU S35        UeSnAff = f)ay  
Check whether PaddlePaddle is installed correctly and running successfully
on your system.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # doctest: +SKIP('the output will change in different run')
        >>> paddle.utils.run_check()
        Running verify PaddlePaddle program ...
        I0818 15:35:08.335391 30540 program_interpreter.cc:173] New Executor is Running.
        I0818 15:35:08.398319 30540 interpreter_util.cc:529] Standalone Executor is Used.
        PaddlePaddle works well on 1 CPU.
        PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
z(Running verify PaddlePaddle program ... FNr   Tr#   zWMore than one kind of custom devices detected, but run check would only be executed on .GPUXPUCPU)device_countzPaddlePaddle works well on 1 xcclPADDLE_DISTRI_BACKENDzPaddlePaddle works well on  zs.zXPaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.z%PaddlePaddle meets some problem with aq  s. This may be caused by:
 1. There is not enough GPUs visible on your system
 2. Some GPUs are occupied by other process now
 3. NVIDIA-NCCL2 is not installed correctly on your system. Please follow instruction on https://github.com/NVIDIA/nccl-tests 
 to test your NCCL, or reinstall it following https://docs.nvidia.com/deeplearning/sdk/nccl-install-guide/index.htmlz
 Original Error is: z7PaddlePaddle is installed successfully ONLY for single z2! Let's start deep learning with PaddlePaddle now.)printr   is_compiled_with_cudar1   is_compiled_with_xpur5   r*   	frameworkcoreget_all_custom_device_typer-   r.   r   r+   r4   listrangeget_custom_device_count
cpu_placesrh   rQ   osenvironr   r,   )	rJ   rK   rL   rM   
device_strr   r   r   r0   s	            r   	run_checkr      s   & 

45HGJ##%%%'		$	$	&	&#%	V""==?	@1	D
v$$??ABQFOOijpjzjzjj  k[  k[  k]  ^_  k`  ja  ab  c 
mm//1	
mm..0	%%**EEGJ
'  %%==&
 
mm..A.>{#Lx*I:J	)*Q
78{a6<

23+&/~Qzl"MNf	
  3L>:, OE E	
 	045Ej\ R? ?	
 s   AI1 1
K;AKK)returnNone)
__future__r   r-   numpyr$   r   __all__r   r(   r1   r5   rQ   rh   r   r   r    r    r   <module>r      sJ    #   
$,  "J#L'T	NWr    