§
    “©ºj³  ã                   óþ  — d dl mZ d dlmZmZ d dlZd dlmZ d dlm	Z	 de
e	         dee	         fd„Z	 	 ddeeeee
e         f                  d
ededee
e                  fd„Zdeeee
e         f         deee
e         f         fd„Zdde
e         d
edede
e         fd„Zdeee
e         eedf         f         d
ededee
e                  fd„Zdd
edede
e         fd„Zde
e         ddfd„Zdeddfd„Zdefd„ZdS )é    )ÚMutableSequence)ÚOptionalÚUnionN)ÚMisconfigurationException)Ú_DEVICEÚgpusÚreturnc                 óœ   — | €dS t          | t          ¦  «        st          d¦  «        ‚t          | ¦  «        dk    s
J d¦   «         ‚| d         S )a  
    Args:
        gpus: Non-empty list of ints representing which GPUs to use

    Returns:
        Designated root GPU device id

    Raises:
        TypeError:
            If ``gpus`` is not a list
        AssertionError:
            If GPU list is empty
    NzGPUs should be a listr   zGPUs should be a non-empty list)Ú
isinstanceÚlistÚ	TypeErrorÚlen)r   s    úx/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/lightning_fabric/utilities/device_parser.pyÚ_determine_root_gpu_devicer      sT   € ð €|Øˆtå�d�DÑ!Ô!ð 1ÝÐ/Ñ0Ô0Ð0åˆt‰9Œ9�qŠ=ˆ=ˆ=Ð;‰=Œ=ˆ=ð �Œ7€Nó    FÚinclude_cudaÚinclude_mpsc                 ó0  — t          | ¦  «         | �>t          | t          ¦  «        r| dk    s#t          | ¦  «                             ¦   «         dv rdS t          | ¦  «        } t          | ||¬¦  «        } | st          d¦  «        ‚t          j	         
                    ¦   «         rUt          j	                             ¦   «         r7t          | ¦  «        dk    r$t          t          ||¬¦  «        ¦  «        dk    r| S t          | ¦  «         t          | ||¬¦  «        S )aH  Parses the GPU IDs given in the format as accepted by the :class:`~pytorch_lightning.trainer.trainer.Trainer`.

    Args:
        gpus: An int -1 or string '-1' indicate that all available GPUs should be used.
            A list of unique ints or a string containing a list of comma separated unique integers
            indicates specific GPUs to use.
            An int of 0 means that no GPUs should be used.
            Any int N > 0 indicates that GPUs [0..N) should be used.
        include_cuda: A boolean value indicating whether to include CUDA devices for GPU parsing.
        include_mps: A boolean value indicating whether to include MPS devices for GPU parsing.

    Returns:
        A list of GPUs to be used or ``None`` if no GPUs were requested

    Raises:
        MisconfigurationException:
            If no GPUs are available but the value of gpus variable indicates request for GPUs

    .. note::
        ``include_cuda`` and ``include_mps`` default to ``False`` so that you only
        have to specify which device type to use and all other devices are not disabled.

    Nr   )Ú0z[]©r   r   z&GPUs requested but none are available.é   )Ú_check_data_typer   ÚintÚstrÚstripÚ!_normalize_parse_gpu_string_inputÚ"_normalize_parse_gpu_input_to_listr   ÚtorchÚdistributedÚis_availableÚis_torchelastic_launchedr   Ú_get_all_available_gpusÚ_check_uniqueÚ_sanitize_gpu_ids©r   r   r   s      r   Ú_parse_gpu_idsr&   1   s  € õ: �TÑÔÐð €|�
 4­Ñ-Ô-€|°$¸!²)°)ÅÀDÁ	Ä	ÇÂÑ@QÔ@QÐU`Ð@`Ð@`Øˆtõ -¨TÑ2Ô2€DÝ-¨dÀÐ[fÐgÑgÔg€DØð RÝ'Ð(PÑQÔQÐQõ 	Ô×&Ò&Ñ(Ô(ðåÔ×6Ò6Ñ8Ô8ðõ �‰IŒI˜ŠNˆNÝÕ'°\È{Ð[Ñ[Ô[Ñ\Ô\Ð`aÒaÐað ˆõ �$ÑÔÐå˜T°È+ÐVÑVÔVÐVr   Úsc                 óÈ   — t          | t          ¦  «        s| S | dk    rdS d| v rd„ |                      d¦  «        D ¦   «         S t          |                      ¦   «         ¦  «        S )Nz-1éÿÿÿÿú,c                 óv   — g | ]6}t          |¦  «        d k    ¯t          |                     ¦   «         ¦  «        ‘Œ7S )r   )r   r   r   )Ú.0Úxs     r   ú
<listcomp>z5_normalize_parse_gpu_string_input.<locals>.<listcomp>p   s1   € ÐCÐCÐC 1½¸A¹¼Àº
¸
•�A—G’G‘I”I‘”¸
¸
¸
r   )r   r   Úsplitr   r   )r'   s    r   r   r   j   sb   € Ý�a�ÑÔð ØˆØˆD‚y€yØˆrØ
ˆa€x€xØCÐC¨¯ª°©¬ÐCÑCÔCÐCÝˆq�wŠw‰yŒy‰>Œ>Ðr   c                 ó¬   — t          ||f¦  «        dk    rt          d¦  «        ‚t          ||¬¦  «        }| D ]}||vrt          d| › d|› �¦  «        ‚Œ| S )as  Checks that each of the GPUs in the list is actually available. Raises a MisconfigurationException if any of the
    GPUs is not available.

    Args:
        gpus: List of ints corresponding to GPU indices

    Returns:
        Unmodified gpus variable

    Raises:
        MisconfigurationException:
            If machine has fewer available GPUs than requested.

    r   z*At least one gpu type should be specified!r   zYou requested gpu: z
 But your machine only has: )ÚsumÚ
ValueErrorr"   r   )r   r   r   Úall_available_gpusÚgpus        r   r$   r$   t   sŒ   € õ ˆL˜+Ð&Ñ'Ô'¨1Ò,Ð,ÝÐEÑFÔFÐFÝ0¸lÐXcÐdÑdÔdÐØð ð ˆØÐ(Ð(Ð(Ý+Ø^ dÐ^Ð^ÐJ\Ð^Ð^ñô ð ð )ð €Kr   .c                 óÎ   — | €J ‚t          | t          t          f¦  «        rt          | ¦  «        S | sd S | dk    rt	          ||¬¦  «        S t          t          | ¦  «        ¦  «        S )Nr)   r   )r   r   Útupler   r"   Úranger%   s      r   r   r   Ž   sr   € ð ÐÐÐÝ�$�­%Ð0Ñ1Ô1ð Ý�D‰zŒzÐð ð ØˆtØˆr‚z€zÝ&°LÈkÐZÑZÔZÐZå•�d‘”ÑÔÐr   c                 ó\   — ddl m} ddlm} | r
 |¦   «         ng }|r
 |¦   «         ng }||z   S )z7
    Returns:
        A list of all available GPUs
    r   )Ú_get_all_visible_cuda_devices)Ú_get_all_available_mps_gpus)Ú"lightning_fabric.accelerators.cudar9   Ú!lightning_fabric.accelerators.mpsr:   )r   r   r9   r:   Ú	cuda_gpusÚmps_gpuss         r   r"   r"   ž   sf   € ð
 QÐPÐPÐPÐPÐPØMÐMÐMÐMÐMÐMà3?ÐGÐ-Ð-Ñ/Ô/Ð/ÀR€IØ0;ÐCÐ*Ð*Ñ,Ô,Ð,À€HØ�xÑÐr   Ú
device_idsc                 ó~   — t          | ¦  «        t          t          | ¦  «        ¦  «        k    rt          d¦  «        ‚dS )zÚChecks that the device_ids are unique.

    Args:
        device_ids: List of ints corresponding to GPUs indices

    Raises:
        MisconfigurationException:
            If ``device_ids`` of GPUs aren't unique

    z!Device ID's (GPU) must be unique.N)r   Úsetr   )r?   s    r   r#   r#   «   s:   € õ ˆ:�„�#�c *™oœoÑ.Ô.Ò.Ð.Ý'Ð(KÑLÔLÐLð /Ð.r   c                 óZ  — d}| €t          |› d�¦  «        ‚t          | t          t          f¦  «        rF| D ]A}t	          |¦  «        }|t
          ur't          |› dt	          |¦  «        j        › d�¦  «        ‚ŒBdS t	          | ¦  «        t
          t          fvrt          |› d| ›d�¦  «        ‚dS )a3  Checks that the device_ids argument is one of the following: int, string, or sequence of integers.

    Args:
        device_ids: gpus/tpu_cores parameter as passed to the Trainer

    Raises:
        TypeError:
            If ``device_ids`` of GPU/TPUs aren't ``int``, ``str`` or sequence of ``int```

    zQDevice IDs (GPU/TPU) must be an int, a string, a sequence of ints, but you passedNz Nonez a sequence of ú.ú )r   r   r   r6   Útyper   Ú__name__r   )r?   ÚmsgÚid_Úid_types       r   r   r   º   sÛ   € ð ^€CØÐÝ˜3˜˜˜Ñ&Ô&Ð&Ý�*�µÐ6Ñ7Ô7ð 2Øð 	Nð 	NˆCÝ˜3‘i”iˆGØ�cÐ!Ð!Ý 3Ð LÐ Lµt¸C±y´yÔ7IÐ LÐ LÐ LÑMÔMÐMð "ð	Nð 	Nõ 
ˆjÑ	Ô	¥#¥s Ð	+Ð	+Ý˜3Ð0Ð0 Ð0Ð0Ð0Ñ1Ô1Ð1ð 
,Ð	+r   c                  ó®   — ddl m}  ddlm} ddlm} |                     ¦   «         rdS |                     ¦   «         rdS |                      ¦   «         rdS dS )	z8Choose the accelerator type (str) based on availability.r   )ÚCUDAAccelerator)ÚMPSAccelerator)ÚXLAAcceleratorÚtpuÚmpsÚcudaÚcpu)r;   rK   r<   rL   Ú!lightning_fabric.accelerators.xlarM   r    )rK   rL   rM   s      r   Ú_select_auto_acceleratorrS   Ñ   sˆ   € àBÐBÐBÐBÐBÐBØ@Ð@Ð@Ð@Ð@Ð@Ø@Ð@Ð@Ð@Ð@Ð@à×"Ò"Ñ$Ô$ð ØˆuØ×"Ò"Ñ$Ô$ð ØˆuØ×#Ò#Ñ%Ô%ð ØˆvØˆ5r   )FF)Úcollections.abcr   Útypingr   r   r   Ú%lightning_fabric.utilities.exceptionsr   Ú lightning_fabric.utilities.typesr   r   r   r   r   Úboolr&   r   r$   r6   r   r"   r#   Úobjectr   rS   © r   r   ú<module>r[      sv  ðð ,Ð +Ð +Ð +Ð +Ð +Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "à €€€à KÐ KÐ KÐ KÐ KÐ KØ 4Ð 4Ð 4Ð 4Ð 4Ð 4ð T¨'¤]ð °xÀÔ7Hð ð ð ð ð8 Øð6Wð 6WØ
�5˜˜c 4¨¤9Ð,Ô-Ô
.ð6Wàð6Wð ð6Wð ˆd�3ŒiÔð	6Wð 6Wð 6Wð 6Wðr¨¨s°C¸¸c¼Ð/BÔ)Cð ÈÈcÐSWÐX[ÔS\ÈnÔH]ð ð ð ð ðð ˜D œIð °Tð ÐPTð ÐaeÐfiÔajð ð ð ð ð4Ø
��T˜#”Y  c¨3 h¤Ð/Ô
0ðØ@DðØSWðàˆd�3ŒiÔðð ð ð ð 
 ð 
 ¨$ð 
 ÀTð 
 ÐVZÐ[^ÔV_ð 
 ð 
 ð 
 ð 
 ðM˜d 3œið M¨Dð Mð Mð Mð Mð2 ð 2¨Dð 2ð 2ð 2ð 2ð. #ð ð ð ð ð ð r   