Ë
    –\;j'  ã                   óV   — d dl Z d dlZd dlZg Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zy)é    Nc            	      óÄ  — t         j                  j                  dg d¢d¬«      } t        j                  ddgdt        j                  t         j
                  j                  j                  d«      ¬«      ¬	«      }t        j                  dgd¬
«      }t         j
                  j                  j                  | ||¬«      }t         j                  j                  |«      }| ||fS )zD
    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        úcG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\paddle/utils/install_check.pyÚ_simple_networkr      s»   € ô �M‰M×ÑØšL°	ð ó €Eô ×$Ñ$Ø�!ˆfØÜ×Ñ¬&¯)©)×*?Ñ*?×*HÑ*HÈÓ*MÔNô€Fô
 ×"Ñ"¨!¨°IÔ>€DÜ—‘×%Ñ%×,Ñ,¨u¸VÈ$Ð,ÓO€JÜ
�-‰-×
Ñ
˜JÓ
'€CØ�#�vÐÐó    c                  ó~   — t        j                  ddgddggt         j                  ¬«      } | j                  ddd«      S )zK
    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:   € ô —h‘h  c 
¨S°#¨JÐ7¼r¿z¹zÔJ€OØ×"Ñ" 1 a¨Ó+Ð+r   c                  óº   — 	 t        t        j                  j                  «       «      dkD  sJ ‚y# t        $ r"} t        j                  d| › �«       Y d} ~ yd} ~ ww xY w)z*
    Check whether CUDA is available.
    r   Tz‘You 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_availabler0   4   sZ   € ð	Ü”6—=‘=×,Ñ,Ó.Ó/°!Ò3Ð3Ð3ØøÜò Ü�‰ð$à$% 3ð(ô	
ô
 ûðúó   ‚,/ ¯	A¸AÁAc                  óº   — 	 t        t        j                  j                  «       «      dkD  sJ ‚y# t        $ r"} t        j                  d| › �«       Y d} ~ yd} ~ ww xY w)z)
    Check whether XPU is available.
    r   Tz�You 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_availabler4   D   sZ   € ð	Ü”6—=‘=×+Ñ+Ó-Ó.°Ò2Ð2Ð2ØøÜò Ü�‰ð$à$% 3ð(ô	
ô
 ûðúr1   c                 óR  — t        j                  «        | rt        j                  d«       nE|rt        j                  d«       n-|rt        j                  |«       nt        j                  d«       t        j                  dt         j                  j
                  j                  d¬«      ¬«      }t        j                  dt         j                  j
                  j                  d	¬«      ¬«      }t         j                  j                  d
d||¬«      }t        «       }t        j                  |«      } ||«      }	t         j                  j                  |	«      }
|
j                  «        t         j                  j                  d|j                  «       ¬«      }|j!                  «        y)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_attrçü©ñÒMbP?©Úlearning_rateÚ
parametersN)r   Údisable_staticÚ
set_devicer   r   r   r   ÚLinearr'   Ú	to_tensorr   r   ÚbackwardÚ	optimizerÚAdamr@   Ústep)Úuse_cudaÚuse_xpuÚ
use_customÚcustom_device_namer;   r<   r   Úinput_npÚinput_tensorr   r   Úopts               r   Ú_run_dygraph_singlerP   T   sF  € ô ×ÑÔÙÜ×Ñ˜%Õ Ù	Ü×Ñ˜%Õ Ù	Ü×ÑÐ,Õ-ä×Ñ˜%Ô Ü×"Ñ"Ø¤6§9¡9×#8Ñ#8×#AÑ#AÈÐ#AÓ#Lô€Kô × Ñ Ø¤§¡×!6Ñ!6×!?Ñ!?ÀcÐ!?Ó!Jô€Iô �Y‰Y×ÑØ	ˆ1˜+°ð ó €Fô ‹€HÜ×#Ñ# HÓ-€LÙ˜Ó%€JÜ
�-‰-×
Ñ
˜JÓ
'€CØ‡L�L„NÜ
×
Ñ
×
Ñ
Ø¨×(9Ñ(9Ó(;ð  ó €Cð ‡H�H…Jr   c                 óú  — t        j                  «        t         j                  j                  t         j                  j	                  «       «      5  t         j                  j                  «       }t         j                  j                  «       }d|_        t         j                  j                  ||«      5  t        «       \  }}}t         j                  j                  ||j                  g¬«      d   }	ddd«       | rt        j                  d«      }
nE|rt        j                  d«      }
n-|rt        j                  |d«      }
nt        j                  «       }
t         j                  j                  |
«      }|j!                  |«       |j!                  |j                  t#        «       ij                  	d   j                  g¬«       ddd«       t        j$                  «        y# 1 sw Y   ŒôxY w# 1 sw Y   Œ*xY w)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_backwardr   Ú	CUDAPlaceÚXPUPlaceÚCustomPlaceÚCPUPlaceÚExecutorÚrunr'   rA   )rI   rJ   rK   rL   Ú
train_progÚstartup_progr   r   r   Úparam_gradsÚplaceÚexes               r   Ú_run_static_singlerg   y   sv  € ô ×ÑÔÜ	�‰×	"Ñ	"¤6§=¡=×#6Ñ#6Ó#8Õ	9Ü—]‘]×*Ñ*Ó,ˆ
Ü—}‘}×,Ñ,Ó.ˆØ#$ˆÔ Ü�]‰]×(Ñ(¨°\ÕBÜ!0Ó!2ÑˆE�3˜Ü Ÿ-™-×7Ñ7Ø V§[¡[ Mð 8ó àñˆK÷ Cñ Ü×$Ñ$ QÓ'‰EÙÜ—O‘O AÓ&‰EÙÜ×&Ñ&Ð'9¸1Ó=‰Eä—O‘OÓ%ˆEä�m‰m×$Ñ$ UÓ+ˆØ�‰�ÔØ�‰ØØ—*‘*œm›oÐ.ØŸ™ +¨a¡.×"5Ñ"5Ð6ð 	ô 	
÷+ 
:ô4 ×ÑÕ÷- CÐBú÷	 
:Ð	9ús&   ÁA$G1Â4>G%Ã2CG1Ç%G.	Ç*G1Ç1G:c                  ó:  —  G d„ dt         j                  j                  «      } t         j                  j	                  «         | «       }t        j
                  |«      }t         j                  j                  «       }t         j                  j                  d|j                  «       ¬«      }t        j                  ddgd«      } ||«      }t        j                  ddgd«      } |||«      }|j                  «        |j                  «        |j                  «        y)	z2
    train script for parallel training check
    c                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )ú)train_for_run_parallel.<locals>.LinearNetz?
        simple fc network for parallel training check
        c                 ó¶   •— t         ‰| �  «        t        j                  j	                  dd«      | _        t        j                  j	                  dd«      | _        y )Né
   r"   )ÚsuperÚ__init__r   r   rC   Ú_linear1Ú_linear2)ÚselfÚ	__class__s    €r   rn   z2train_for_run_parallel.<locals>.LinearNet.__init__ª   s>   ø€ Ü‰GÑÔÜ"ŸI™I×,Ñ,¨R°Ó4ˆDŒMÜ"ŸI™I×,Ñ,¨R°Ó3ˆD�Mr   c                 óB   — | j                  | j                  |«      «      S )z!
            forward
            )rp   ro   )rq   r   s     r   Úforwardz1train_for_run_parallel.<locals>.LinearNet.forward¯   s   € ð —=‘= §¡¨qÓ!1Ó2Ð2r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rn   rt   Ú__classcell__)rr   s   @r   Ú	LinearNetrj   ¥   s   ø„ ñ	ô	4ö
	3r   rz   r=   r>   rl   r   r"   N)r   r   ÚLayerÚdistributedÚinit_parallel_envÚDataParallelÚMSELossrF   rG   r@   ÚrandnrE   rH   Ú
clear_grad)	rz   ÚlayerÚdp_layerÚloss_fnÚadamÚinputsÚoutputsÚlabelsÚlosss	            r   Útrain_for_run_parallelrŠ   Ÿ   sØ   € ô3”F—I‘I—O‘Oô 3ô  ×Ñ×(Ñ(Ô*á‹K€EÜ×"Ñ" 5Ó)€Hä�i‰i×ÑÓ!€GÜ×Ñ× Ñ Ø¨×(;Ñ(;Ó(=ð !ó €Dô �\‰\˜2˜r˜( IÓ.€FÙ�vÓ€GÜ�\‰\˜2˜q˜' 9Ó-€FÙ�7˜FÓ#€Dà‡M�M„OØ‡I�I„KØ‡O�OÕr   c                 ó`   — t         j                  j                  t        t	        | «      ¬«       y)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#   € ô ×Ñ×ÑÔ3¼CÀÓ<LÐÕMr   c                  ój  — t        d«       d} d}d}d}t        j                  «       rt        «       } nÖt        j                  «       rt        «       }n·t        t        j                  j                  j                  «       «      dkD  rƒd}t        t        j                  j                  j                  «       «      dkD  rMt        j                  dj                  t        j                  j                  j                  «       d   «      «       | r!d}t        j                  j                  «       }n°|r!d	}t        j                  j                  «       }n�|rit        j                  j                  j                  «       d   }|}t!        t#        t        j                  j                  j%                  |«      «      «      }n"d
}t        j                  j'                  d¬«      }t        |«      }t)        | |||«       t+        | |||«       t        d|› d�«       	 t        |«      dkD  r2|rddl}d|j.                  d<   t1        |«       t        d|› d|› d�«       t        d«       y# t2        $ rJ}t        j                  d|› d|› d�«       t        j                  d|› �«       t        d|› d�«       |‚d}~ww xY w)a­  
    Check whether PaddlePaddle is installed correctly and running successfully
    on your system.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> paddle.utils.run_check()
            >>> # doctest: +SKIP('the output will change in different run')
            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"   zZMore 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_cudar0   Úis_compiled_with_xpur4   r)   Ú	frameworkÚcoreÚget_all_custom_device_typer,   r-   Úformatr   r*   r3   ÚlistÚrangeÚget_custom_device_countÚ
cpu_placesrg   rP   ÚosÚenvironr�   r+   )	rI   rJ   rK   rL   Ú
device_strrŽ   r”   r¤   r/   s	            r   Ú	run_checkr§   Õ   sp  € ô& 
Ð
4Ô5à€HØ€GØ€JØÐä×#Ñ#Ô%Ü%Ó'‰Ü	×	$Ñ	$Ô	&Ü#Ó%‰Ü	ŒV×Ñ×"Ñ"×=Ñ=Ó?Ó	@À1Ò	DØˆ
ÜŒv×Ñ×$Ñ$×?Ñ?ÓAÓBÀQÒFÜ�O‰OØl×sÑsÜ×$Ñ$×)Ñ)×DÑDÓFÀqÑIóôñ Øˆ
Ü—m‘m×/Ñ/Ó1‰Ù	Øˆ
Ü—m‘m×.Ñ.Ó0‰Ù	Ü×%Ñ%×*Ñ*×EÑEÓGÈÑJˆ
Ø'ÐÜÜÜ× Ñ ×%Ñ%×=Ñ=Ø&óóó
‰ð ˆ
Ü—m‘m×.Ñ.¸AÐ.Ó>ˆÜ�{Ó#€Lä�x ¨*Ð6HÔIÜ˜ '¨:Ð7IÔJÜ	Ð)¨*¨°QÐ
7Ô8ðÜˆ{Ó˜aÒÙÛà6<�—
‘
Ð2Ñ3Ü˜+Ô&ÜÐ/°¨~¸Q¸z¸lÈ"ÐMÔNÜØfõ	
øô ò Ü�‰Ø3°L°>ÀÀ:À,ð OEð Eô	
ô 	�‰Ð0°°Ð4Ô5ÜØEÀjÀ\ð R?ð ?ô	
ð ˆûðús   ÈAI É	J2É(AJ-Ê-J2)r,   Únumpyr#   r   Ú__all__r   r'   r0   r4   rP   rg   rŠ   r�   r§   © r   r   Ú<module>r«      sG   ðó ã ã à
€òò$,òò ò "òJ#òL'òT	NóYr   