44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
#!/bin/env python3
|
|
import vast_start as vs
|
|
|
|
|
|
print("Searching cheapest 39GB+ GPU...")
|
|
offers = vs.get_cheapest_gpus()
|
|
instance_id=0
|
|
for offer in offers:
|
|
offer_id = offer["id"]
|
|
print("Offer:", offer_id, "GPU:", offer["gpu_name"], "Price:", offer["dph_total"])
|
|
|
|
print("Creating instance...")
|
|
try:
|
|
for k in offer:
|
|
v=offer[k]
|
|
print(f"{k}: {v}")
|
|
instance_id = vs.create_instance(offer_id)
|
|
break
|
|
except:
|
|
print(f"failed to claim offer {offer_id}")
|
|
data=[]
|
|
if instance_id > 0 :
|
|
print("Instance:", instance_id)
|
|
data = vs.wait_until_ready(instance_id)
|
|
ip = data["ssh_host"]
|
|
port = data["ssh_port"]
|
|
user = "root"
|
|
#password = data["ssh_pwd"]
|
|
|
|
print("Instance ready:", ip)
|
|
|
|
|
|
pub_ip=data["public_ipaddr"]
|
|
pub_port=data['ports']['22/tcp'][0]['HostPort']
|
|
|
|
vs.ssh_and_setup(ip, port, user, "")
|
|
print(f"ssh root@{pub_ip} -p {pub_port}")
|
|
ollama_port=data['ports']['11434/tcp'][0]['HostPort']
|
|
print(f"ollama up at http://{pub_ip}:{ollama_port} with mode {model}")
|
|
|
|
cmd2=["ssh","-t","-p",str(pub_port),f"{user}@{pub_ip}","ollama","run",model]
|
|
print(' '.join(cmd2))
|
|
subprocess.run(cmd2)
|