+
    #jE                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
Ht ^t^t^t^t^ t^tRRRRRR	R
RRRRR/tR-R R lltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR.R R lltR  R! ltR" R# ltR$R%/R& R' lltR( R) ltR/R* R+ llt ]!R,8X  d   ]	PD                  ! ] ! 4       4       R# R# )0u  hardware_check.py — Detect whether this machine can realistically run ComfyUI locally.

Improvements over v1:
  - Multi-GPU detection: scans all NVIDIA / AMD GPUs, picks the best one (most VRAM)
  - Apple Silicon: detects Rosetta-via-x86_64 false negative; warns instead of misclassifying
  - Apple generation: defaults to None (unknown) instead of mis-tagging as M1
  - WSL2 detection: identifies WSL2 + nvidia-smi situation explicitly
  - ROCm: prefers `rocm-smi --json` for new ROCm 6.x output
  - Disk space check: warns if /home or workspace volume has < 25 GB free
  - PyTorch verification (optional): tries to import torch and check device availability
  - Windows: prefers PowerShell `Get-CimInstance` over deprecated `wmic`
  - More accurate VRAM thresholds and verdict reasons

Emits a structured JSON report. Exit codes match `verdict`:
    0 → ok
    1 → marginal
    2 → cloud

Usage:
    python3 hardware_check.py [--json] [--check-pytorch]
)annotationsN)Anynvidiaz--nvidiaamdz--amdapple-siliconz
--m-seriesintelcomfy-cloudcpuz--cpuc               $    V ^8  d   QhRRRRRR/# )   cmdz	list[str]timeoutintreturnstr )formats   "h/opt/hermes-venv/lib/python3.14/site-packages/../../../skills/creative/comfyui/scripts/hardware_check.py__annotate__r   6   s!      i # c     c                     \         P                  ! V R R VRR7      pVP                  ;'       g    RVP                  ;'       g    R,           #   \        \         P
                  \        3 d     R# i ; i)TF)capture_outputtextr   check )
subprocessrunstdoutstderrFileNotFoundErrorTimeoutExpiredOSError)r   r   outs   && r   _runr#   6   sd    nn4
 

  bSZZ%5%5266z88'B s   -A A A  A21A2c                   V ^8  d   QhRR/# r   r   boolr   )r   s   "r   r   r   @   s     
 
 
r   c                    \         P                  ! 4       R8w  d   R# R\         P                  ! 4       P                  4       9   g)   R\         P                  ! 4       P                  4       9   d   R#  \	        RR4      ;_uu_ 4       p RV P                  4       P                  4       9   uuRRR4       #   + '       g   i     R# ; i  \         d     R# i ; i)	z;Return True when running under Windows Subsystem for Linux.LinuxF	microsoftwslTz/proc/versionrN)platformsystemreleaseloweropenreadr!   )fhs    r   is_wslr3   @   s    G#h&&(..00EX=M=M=O=U=U=W4W/3''2"'')//"33 (''' s0   0C !B0%
C 0C	;C C CCc                   V ^8  d   QhRR/# r%   r   )r   s   "r   r   r   M   s      D r   c                     \         P                  ! 4       R8w  d   R# \         P                  ! 4       R8X  d   R# \        . RO4      P	                  4       p V R8H  # )zMReturn True when Python is running translated under Rosetta on Apple Silicon.DarwinFarm641)sysctlz-inzsysctl.proc_translated)r,   r-   machiner#   stripr"   s    r   
is_rosettar=   M   sF    H$W$
:
;
A
A
CC#:r   c                   V ^8  d   QhRR/# r   r   dict | Noner   )r   s   "r   r   r   X   s     $ ${ $r   c                    \         P                  ! R4      '       g   R# \        . RO4      p V P                  4       '       g   R# . pV P                  4       P	                  4        F  pVP                  R4       Uu. uF  q3P                  4       NK  	  pp\        V4      ^8  d   KB   \        V^ ,          4      pV^,          p\        V^,          4      p\        T4      ^8  d
   T^,          MRpTP                  RRRTRTR	\        TR
,          ^4      RT/4       K  	  V'       g   R# \        VR R7      p	\        V4      ^8  d   WR&   V	# u upi   \         d     K  i ; i)zIDetect NVIDIA GPUs. Returns the GPU with the most VRAM, plus list of all.
nvidia-smiN,r   vendorr   indexnamevram_gb   driverc                    V R ,          # rG   r   )gs   &r   <lambda>detect_nvidia.<locals>.<lambda>y   s    1Y<r   keyall_gpus)rB   z2--query-gpu=index,name,memory.total,driver_versionz--format=csv,noheader,nounits)shutilwhichr#   r;   
splitlinessplitlenr   
ValueErrorappendroundmax)
r"   gpuslineppartsidxrF   vram_mbrI   bests
             r   detect_nvidiarb   X   s9   <<%%
  C
 99;;D		&&($(JJsO4OqO4u:>	eAh-C8D%(mG !Z!^qhSDuWt^Q/f
 	 )$ t/0D
4y1}ZK/ 5  		s   :E'-EE! E!c                   V ^8  d   QhRR/# r?   r   )r   s   "r   r   r      s     , ,[ ,r   c                    \         P                  ! R 4      '       g   R# \        . RO4      p V P                  4       P	                  R4      '       EdG    \
        P                  ! V 4      p. pVP                  4        F  w  r4VP	                  R4      '       g   K  VP                  R4      ;'       g5    VP                  R4      ;'       g    VP                  R4      ;'       g    RpVP                  R4      ;'       g    VP                  R	4      ;'       g    ^ p \        V4      pVP                  R
RR\        V4      P                  4       R\        VR,          ^4      RR/4       K  	  V'       d%   \        VR R7      p\!        V4      ^8  d   W'R&   V#  \        . RO4      p V P                  4       '       g   R# \$        P&                  ! RV 4      p\$        P&                  ! RV 4      p	V	'       d,   \        \        V	P)                  ^4      4      R,          ^4      MRp
R
RRV'       d    VP)                  ^4      P                  4       MRRV
RR/#   \        \        3 d    ^ p ELAi ; i  \
        P"                   d     Li ; i)rocm-smiN{cardzCard seriesz
Card modelzMarketing NamezAMD GPUzVRAM Total Memory (B)vram_total_memory_brD   r   rF   rG   rI   rocmc                    V R ,          # rK   r   )cs   &r   rM   detect_rocm.<locals>.<lambda>   s    )r   rO   rQ   z,Card (?:series|model|Marketing Name):\s*(.+)z VRAM Total Memory \(B\):\s*(\d+)        )re   --showproductname--showmeminfovram--json   @)re   rn   ro   rp   )rR   rS   r#   r;   
startswithjsonloadsitemsgetr   rW   	TypeErrorrX   r   rY   rZ   rV   JSONDecodeErrorresearchgroup)r"   datacardscard_idinforF   vram_bra   name_mvram_mrG   s              r   detect_rocmr      s.   <<
##
S
TC
yy{c""	::c?DE!%))&11/ C C488L3I C C88$45C C9B "9:bbdhhG\>]bbab [F eCIOO-uVw%7;f	  ".  5&<=u:>',$	  I
JC99;;YYFLFYY:C@F<BeCQ(G4a8G%6Q%%'y7&	 - #I. F ## 		s\   AI+ 1I+ 
I+ #I+ >I+ I+ I&AI+ 3#I+ I($I+ 'I((I+ +JJc                   V ^8  d   QhRR/# r?   r   )r   s   "r   r   r      s      k r   c            
     2   \         P                  ! 4       R 8w  d   R# \         P                  ! 4       R8w  d   R# \        . RO4      P	                  4       p \
        P                  ! RV 4      pV'       d   \        VP                  ^4      4      MRp^ p \        \        . RO4      P	                  4       ;'       g    ^ 4      pV'       d   \        VR,          ^4      MRpRpR F  pW`9   g   K  Tp M	  RRRT ;'       g    RR	VR
VRV/#   \         d     LUi ; i)r6   Nr7   zApple M(\d+)rm   rD   applerF   Apple Silicon
generationvariantunified_memory_gb)r9   -nzmachdep.cpu.brand_stringr9   r   z
hw.memsizerr   )UltraMaxPro)r,   r-   r:   r#   r;   rz   r{   r   r|   rW   rY   )chipmr   	mem_bytesram_gbr   vs          r   detect_apple_siliconr      s   H$W$<=CCED
		/4(A$%QWWQZ4JI;<BBDIIJ	 1:U9(!,sF G$9G % 	'''j7V   s   .D DDc                   V ^8  d   QhRR/# r?   r   )r   s   "r   r   r      s      + r   c                    \         P                  ! 4       R9  d   R# \        P                  ! R4      '       d+   \	        RR.4      p RV 9   d   RV 9   g   RV 9   d	   RR	R
RRR/# \         P                  ! 4       R8X  dG   \        P                  ! R4      '       d+   \	        . RO4      p RV 9   d   RV 9   g   RV 9   d	   RR	R
RRR/# R# )r(   WindowsNclinfoz--listIntelArcXerD   r   rF   zIntel Arc/XerG   rm   
powershellzIris XezIntel Arc/Iris Xe>   r(   r   )r   
-NoProfilezHGet-CimInstance Win32_VideoController | Select-Object Name | Format-List)r,   r-   rR   rS   r#   r<   s    r   detect_intel_arcr      s     44||HHh'(c>u|ts{gv~y#NNI%&,,|*D*D ` ac>u|yC/?gv/BIsSSr   c                   V ^8  d   QhRR/# )r   r   floatr   )r   s   "r   r   r      s      U r   c                    \         P                  ! 4       p V R 8X  dA    \        \        \	        . RO4      P                  4       ;'       g    ^ 4      R,          ^4      # V R8X  d~    \        RR4      ;_uu_ 4       pV FY  pVP                  R4      '       g   K  \        VP                  4       ^,          4      p\        VR,          ^4      u uuRRR4       # 	  RRR4       V R8X  d   \        P                  ! R4      '       dX   \	        . RO4      p\        P                  ! R	V4      pV'       d,   \        \        VP                  ^4      4      R,          ^4      # \	        . RO4      p\        P                  ! R
V4      pV'       d,   \        \        VP                  ^4      4      R,          ^4      # R#   \         d     R# i ; i  + '       g   i     L; i  \         d     R# i ; i)r6   rm   r(   z/proc/meminfor+   z	MemTotal:Nr   r   z(\d{8,})z(\d{6,})r   rr   i   )r   r   z:(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory)wmicComputerSystemrw   TotalPhysicalMemory)r,   r-   rY   r   r#   r;   rW   r0   rs   rU   r!   rR   rS   rz   r{   r|   )sysnamer2   r\   kbr"   r   s         r   total_system_ram_gbr      s|   ooG(	T"@AGGINNQOSZ[]^__ '	os++rD{33 a1$R7^Q77	 ,+ , )<<%%  C 		+s+AS_8!<<KLIIk3'QWWQZG4a883  		 ,+
  		sS   >F4 %G 9G4G
G GG 4GGG	G G G('G(c                    V ^8  d   QhRRRR/# )r   pathr   r   r   r   )r   s   "r   r   r      s      S 5 r   c                     \         P                  ! V 4      p\        VP                  R,          ^4      #   \         d     R# i ; i)rH   rm   rr   )rR   
disk_usagerY   freer!   )r   usages   & r   total_free_disk_gbr      s?    !!$'UZZ7+Q// s   25 AAc                   V ^8  d   QhRR/# r?   r   )r   s   "r   r   r     s      K r   c                     ^ RI p RRRT P                  /p \        T P                  P                  4       4      TR&   TR,          '       d<   T P                  P                  4       TR	&   T P                  P                  ^ 4      TR
&    \        T P                  P                  P                  4       4      TR&   T#   \         d   pRRRRT 2/u Rp?# Rp?ii ; i  \         d	    RTR&    Lfi ; i  \         d
    RTR&    T# i ; i)zJOptional PyTorch availability check. Only run when --check-pytorch is set.N	availableFreasonztorch not importable: Ttorch_versioncuda_availablecuda_device_countcuda_device_0mps_available)
torch	Exception__version__r&   cudais_availabledevice_countget_device_namebackendsmps)r   er   s      r   check_pytorch_cudar     s   L 	T**D'!%ejj&=&=&?!@ !!(-

(?(?(AD$%$)JJ$>$>q$AD!& $U^^%7%7%D%D%F G_ K#  LUH0Fqc.JKKL  '!&'  & %_K&sA   B: A0C 0C1 :CCCCC.-C.1DDc               0    V ^8  d   QhRRRRRRRRRRR	R
/# )r   gpur@   r   r   free_disk_gbr*   r&   rosettar   ztuple[str, str, list[str]]r   )r   s   "r   r   r     s@     Q& Q&+ Q&u Q&E Q&4 Q&Z^ Q&c} Q&r   c                  . pV'       d   VP                  R 4       RRV3# V'       d(   V '       d    V R,          R8X  d   VP                  R4       V'       d(   V\        8  d   VP                  RV R\         R24       V'       d;   V^8  d4   V '       d,   V P                  R4      R	8w  d   VP                  R
V R24       V f(   VP                  R4       VP                  R4       RRV3# V R,          R	8X  d   V P                  R4      pV P                  R4      pV P                  RR4      pV'       d   RV 2MRp	V'       d   V	RV 2,          p	V\        8  d5   VP                  V	 RV R\         R24       VP                  R4       RRV3# V\        8  d   VP                  V	 RV R24       RRV3# VP                  V	 RV R24       RRV3# V R,          R8X  d   VP                  R4       RRV3# V P                  R R4      p
V R!,          pV
\
        8  d5   VP                  V R"V
 R#\
         R24       VP                  R$4       RRV3# V
\        8  d$   VP                  V R%V
 R&24       RV R,          V3# V
\        8  d$   VP                  V R%V
 R'24       RV R,          V3# VP                  V R%V
 R(24       RV R,          V3# ))u   Detected Python running under Rosetta on Apple Silicon. ComfyUI MPS support requires native ARM64 Python — install via `brew install python` or arm64 Miniforge, then re-run.cloudr   rD   r   u[   Detected WSL2 + NVIDIA — confirm `nvidia-smi` works in your WSL distro before installing.zFree disk space (z GB) is below the zo GB recommended minimum. ComfyUI core (~5 GB) plus one SDXL model (~6.5 GB) needs space; Flux Dev needs ~24 GB.r   zSystem RAM (zm GB) is low. ComfyUI swaps model weights through host RAM; <8 GB causes severe slowdowns. 16+ GB recommended.zTNo supported accelerator found (NVIDIA CUDA / AMD ROCm / Apple Silicon / Intel Arc).uR   CPU-only ComfyUI works but is unusably slow for modern models — use Comfy Cloud.r   r   r   rm   Mr    z with u!    GB unified memory — below the z GB practical minimum.zBSD1.5 may work; SDXL/Flux will swap or OOM. Recommend Comfy Cloud.u9    GB — SDXL works but slow. Flux/video likely too tight.marginalr   u*    GB unified memory — good for SDXL/Flux.okr   uZ   Intel Arc detected — ComfyUI IPEX support is experimental; Comfy Cloud is more reliable.rG   rF   z
 has only u    GB VRAM — below the z5Most modern models won't load. Recommend Comfy Cloud. (u;    GB VRAM) — SD1.5 works, SDXL tight, Flux/video unlikely.uA    GB VRAM) — SDXL comfortable, Flux possible with optimizations.u6    GB VRAM) — can run everything including Flux/video.)rX   MIN_FREE_DISK_GBrw   MIN_MAC_RAM_GBOK_MAC_RAM_GBMIN_VRAM_GB_USABLE
OK_VRAM_GBGREAT_VRAM_GB)r   r   r   r*   r   notesgenr   memgen_strrp   rF   s   &&&$$       r   classifyr     s   EE	

 u,,
ss8}0rs'77~-?@P?Q Re e	
 &1*):g)E6( #K K	

 {b	
 	`	
 u,,
8}ggl#'')$gg)3/"AcU)7)}$GLL)6#&GGWWmn LL]^M500LL)6#&_` 55yse+UVW_e++
8}qr7E)) 779c"Dv;D  fJtf$;<N;OOef	
 	LMu,,jfBtfWX	
 3x=%//mvRv%fghS]E))	LLD6D6!WXYX%%r   check_pytorchFc                    V ^8  d   QhRRRR/# )r   r   r&   r   dictr   )r   s   "r   r   r   r  s     < <4 <D <r   c                   \         P                  ! 4       p\         P                  ! 4       p\        4       p\	        \
        P                  P                  R 4      4      p\        4       p\        4       p\        4       ;'       g/    \        4       ;'       g    \        4       ;'       g    \        4       pVfT   VR8X  dM   VR8w  dF   V'       g>   RR.pRVRVRVR	VR
RRRRRRRRRRRRVR\        4       /p	V '       d   \        4       V	R&   V	# \!        WsWFVR7      w  rpRVRVRVR	VR
VRVRVRV
RVR\"        P%                  V4      RVR\        4       /p	V '       d   \        4       V	R&   V	# )~Nr6   r7   u0   Intel Mac detected — no MPS backend available.zFComfyUI will fall back to CPU which is unusably slow. Use Comfy Cloud.osarchsystem_ram_gbr   r*   Fr   r   verdictr   recommended_install_pathr   comfy_cli_flagr   install_urlspytorch)r*   r   )r,   r-   r:   r   r   r   r   
expanduserr=   r3   rb   r   r   r   _install_urlsr   r   _COMFY_CLI_FLAGrw   )r   r   r   r   r   r   r*   r   r   reportr   install_paths   $           r   build_reportr   r  s   ooGD "F%bgg&8&8&=>LlG
(C 	 	 	=	 	!	 	 	  {w(*tww>T

 'DVL5u4w&dUMO
  2 4F9#+\G$ G5
 	gs7s7"L/--l;F .0yMr   c                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   r     s      t r   c                     R RRRRRRR/# )desktopz+https://docs.comfy.org/installation/desktopmanualz2https://docs.comfy.org/installation/manual_install	comfy_cliz0https://docs.comfy.org/comfy-cli/getting-startedr   zhttps://platform.comfy.orgr   r   r   r   r   r     s$    @FG-	 r   c                    V ^8  d   QhRRRR/# )r   argvzlist[str] | Noner   r   r   )r   s   "r   r   r     s     3 3 33 3r   c           	        ^ RI pVP                  RR7      pVP                  RRRR7       VP                  RRR	R7       VP                  V 4      p\	        VP
                  R
7      pVP                  '       d$   \        \        P                  ! V^R7      4       EM\        RVR,           RVR,           R24       VP                  R4      '       d   \        R4       VP                  R4      '       d   \        R4       \        RVR,           R24       \        RVR,           R24       VR,          '       d   VR,          pVR,          R8X  d+   \        RVR,           R VP                  R!^ 4       R"24       M\        RVR,           R VP                  R#^ 4       R$24       VP                  R%4      '       d7   \        VR%,          4      ^8  d    \        R&\        VR%,          4       R'24       M\        R(4       \        R)VR*,           R+VR,,           24       VR-,          '       d   \        R.VR-,           24       VP                  R/4      '       d   VR/,          pVP                  R04      '       du   R1VP                  R24       2pVP                  R34      '       d   VR4VP                  R5R64       R2,          pVP                  R74      '       d
   VR8,          p\        V4       M\        R9VP                  R:4       24       VR;,           F  p\        R<V 24       K  	  VR*,          R=8X  d   ^ # VR*,          R>8X  d   ^# ^# )?    Nz3Check whether this machine can run ComfyUI locally.)descriptionrq   
store_truezEmit machine-readable JSON only)actionhelpz--check-pytorchz5Also probe `torch` for CUDA/MPS availability (slower))r   )indentzOS:        r   r   r   )r*   zEnv:       WSL2r   z3Env:       Rosetta (x86_64 Python on Apple Silicon)zRAM:       r   z GBzFree disk: r   z GB (~/)r   rD   r   zGPU:       rF   u    — r   z GB unified memoryrG   z GB VRAMrQ   z           (z  GPUs total; using best by VRAM)zGPU:       (none detected)zVerdict:   r   u     → r   r   z,           run: comfy --skip-prompt install r   r   zPyTorch:   r   r   z	 + CUDA (r   ?r   z + MPSu   PyTorch:   not available — r   r   u     • r   r   )argparseArgumentParseradd_argument
parse_argsr   r   rt   printdumpsrw   rV   )	r   r   r]   argsr   rL   ptr\   ns	   &        r   mainr    s   ,abANN8L7XNYNN$\O  Q<<D(:(:;Fyyydjj*+F4L>F6N+;1=>::e#$::i  GHF?34C89F>238<=%==uA{g%AfI;eAEE:Mq4Q3RRdefAfI;eAEE)Q4G3HQR55$$Qz]);a)?LQz]);(<<\]^./F9-.fV<V5W4XYZ"##@HXAY@Z[\::i  	"Bvvk""$RVVO%<$=>66*++i(D'EQGGD66/**H$Dd5bffX6F5GHIAF1#, ! iD iJ&r   __main__)   ).)N)#__doc__
__future__r   rt   r   r,   rz   rR   r   systypingr   r   r   r   r   r   r   r   r#   r3   r=   rb   r   r   r   r   r   r   r   r   r   r  __name__exitr   r   r   <module>r     s   , #  	  	   
   
  j	7\T4	7
$N,^> B0Q&h<% <~3l zHHTV r   