-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_spot_pod.py
executable file
·61 lines (55 loc) · 1.66 KB
/
create_spot_pod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
import runpod
import json
NAME = 'stable-diffusion-webui 2.1.0'
IMAGE_NAME = 'ashleykza/stable-diffusion-webui:2.1.0'
GPU_TYPE_ID = 'NVIDIA RTX A5000'
OS_DISK_SIZE_GB = 10
PERSISTENT_DISK_SIZE_GB = 75
BID_PRICE = 0.170
COUNTRY_CODE = ''
MIN_DOWNLOAD = 600
PORTS = '22/tcp,3000/http,3010/http,3020/http,6006/http,8000/http,8888/http'
# PORTS = '22/tcp,8888/http,3000/http,5000/http,5005/http'
if __name__ == '__main__':
runpod = runpod.API()
pod_config = f"""
countryCode: "{COUNTRY_CODE}",
minDownload: {MIN_DOWNLOAD},
bidPerGpu: {BID_PRICE},
gpuCount: 1,
volumeInGb: {PERSISTENT_DISK_SIZE_GB},
containerDiskInGb: {OS_DISK_SIZE_GB},
gpuTypeId: "{GPU_TYPE_ID}",
cloudType: SECURE,
supportPublicIp: true,
name: "{NAME}",
dockerArgs: "",
ports: "{PORTS}",
volumeMountPath: "/workspace",
imageName: "{IMAGE_NAME}",
startJupyter: true,
startSsh: true,
env: [
{{
key: "JUPYTER_PASSWORD",
value: "Jup1t3R!"
}},
{{
key: "ENABLE_TENSORBOARD",
value: "1"
}}
]
"""
response = runpod.create_spot_pod(pod_config)
resp_json = response.json()
if response.status_code == 200:
if 'errors' in resp_json:
print('ERROR:')
for error in resp_json['errors']:
print(error['message'])
else:
print(json.dumps(resp_json, indent=4, default=str))
else:
print(response.status_code)
print(json.dumps(resp_json, indent=4, default=str))