| 
									
										
										
										
											2023-06-20 16:00:55 -07:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							| 
									
										
										
										
											2023-06-05 09:14:43 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # get a string representing the system stats. we should be able to infer | 
					
						
							|  |  |  | # this from aws types, but this guarantees we have the info we need in all cases | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # hack to get gpus available for processing | 
					
						
							|  |  |  | # assumes nvidia drivers available for inference tasks | 
					
						
							| 
									
										
										
										
											2023-12-11 20:04:15 -05:00
										 |  |  | if command -v nvidia-smi &>/dev/null; then | 
					
						
							| 
									
										
										
										
											2023-12-18 23:48:21 -08:00
										 |  |  |   gpu=$(nvidia-smi --query-gpu=name --format=csv,noheader | wc -l) | 
					
						
							| 
									
										
										
										
											2023-06-05 09:14:43 -07:00
										 |  |  | else | 
					
						
							| 
									
										
										
										
											2023-12-18 23:48:21 -08:00
										 |  |  |   gpu="0" | 
					
						
							| 
									
										
										
										
											2023-06-05 09:14:43 -07:00
										 |  |  | fi | 
					
						
							|  |  |  | if command -v sysctl >/dev/null && command -v system_profiler >/dev/null; then | 
					
						
							| 
									
										
										
										
											2023-12-18 23:48:21 -08:00
										 |  |  |   cpu=$(sysctl -n hw.logicalcpu_max) | 
					
						
							|  |  |  |   mem=$(sysctl -n hw.memsize | awk '{printf "%.0fGB",$0/1024/1024/1024}') | 
					
						
							| 
									
										
										
										
											2023-06-05 09:14:43 -07:00
										 |  |  | else | 
					
						
							| 
									
										
										
										
											2023-12-18 23:48:21 -08:00
										 |  |  |   cpu=$(getconf _NPROCESSORS_ONLN) | 
					
						
							|  |  |  |   mem=$(grep 'MemTotal' /proc/meminfo | awk '{printf "%.0fGB",$2/1024/1024}') | 
					
						
							| 
									
										
										
										
											2023-06-05 09:14:43 -07:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo "${cpu}cpu_${gpu}gpu_${mem}mem" |