@@ -17,7 +17,6 @@ def main():
1717 sys .exit (1 )
1818
1919 print ("Creating RunPod instance..." )
20- print (f"SSH public key: { ssh_public_key [:50 ]} ..." )
2120
2221 pod = runpod .create_pod (
2322 name = "nanogpt-benchmark" ,
@@ -26,54 +25,34 @@ def main():
2625 gpu_count = 8 ,
2726 volume_in_gb = 0 ,
2827 container_disk_in_gb = 100 ,
29- ports = "22/tcp,8888/http " ,
28+ ports = "22/tcp" ,
3029 support_public_ip = True ,
3130 env = {"SSH_PUBLIC_KEY" : ssh_public_key },
3231 )
3332
3433 pod_id = pod ["id" ]
3534 pod_host_id = pod .get ("machine" , {}).get ("podHostId" , pod_id )
36- print (f"Pod created : { pod_id } " )
37- print (f"SSH host ID : { pod_host_id } " )
35+ print (f"Pod ID : { pod_id } " )
36+ print (f"SSH target : { pod_host_id } @ssh.runpod.io " )
3837
3938 with open ("pod_id.txt" , "w" ) as f :
4039 f .write (pod_id )
41- with open ("ssh_host_id .txt" , "w" ) as f :
40+ with open ("ssh_target .txt" , "w" ) as f :
4241 f .write (pod_host_id )
4342
44- print ("Waiting for pod..." )
45- start_time = time .time ()
46-
47- while True :
43+ print ("Waiting for pod to be RUNNING..." )
44+ for _ in range (24 ):
4845 pod_info = runpod .get_pod (pod_id )
4946 status = pod_info .get ("desiredStatus" )
50-
47+ print ( f" Status: { status } " )
5148 if status == "RUNNING" :
52- public_ip = pod_info .get ("publicIp" )
53- port_mappings = pod_info .get ("portMappings" ) or {}
54- ssh_port = port_mappings .get ("22" ) or port_mappings .get (22 )
55-
56- if public_ip and ssh_port :
57- # Direct SSH via public IP
58- print (f"Pod ready (direct SSH): root@{ public_ip } -p { ssh_port } " )
59- with open ("ssh_info.txt" , "w" ) as f :
60- f .write (f"direct:{ public_ip } :{ ssh_port } " )
61- break
62- elif time .time () - start_time > 30 :
63- # Fall back to basic SSH proxy after 30s
64- print (f"Pod ready (proxy SSH): { pod_host_id } @ssh.runpod.io" )
65- with open ("ssh_info.txt" , "w" ) as f :
66- f .write (f"proxy:{ pod_host_id } " )
67- break
68- else :
69- print (f" Waiting for public IP... ({ int (time .time () - start_time )} s)" )
70-
71- if time .time () - start_time > 120 :
72- print ("ERROR: Pod timeout (2 min)" , file = sys .stderr )
73- sys .exit (1 )
74-
49+ print ("Pod is ready!" )
50+ return
7551 time .sleep (5 )
7652
53+ print ("ERROR: Pod timeout" , file = sys .stderr )
54+ sys .exit (1 )
55+
7756
7857if __name__ == "__main__" :
7958 main ()
0 commit comments