Spaces:
Build error
Build error
Du Mingzhe commited on
Commit ·
6fa9c13
1
Parent(s): a15af3c
Update
Browse files
app.py
CHANGED
|
@@ -1,28 +1,121 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
st.title("GCP Resource Alloctor")
|
| 4 |
|
| 5 |
-
|
| 6 |
# GPU Type
|
| 7 |
gpu_type = st.selectbox(
|
| 8 |
-
'
|
| 9 |
(
|
| 10 |
-
'
|
| 11 |
-
'
|
| 12 |
-
'
|
| 13 |
-
'
|
| 14 |
-
'
|
| 15 |
-
'
|
| 16 |
-
'
|
| 17 |
-
'
|
| 18 |
)
|
| 19 |
)
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
import streamlit as st
|
| 3 |
|
| 4 |
st.title("GCP Resource Alloctor")
|
| 5 |
|
|
|
|
| 6 |
# GPU Type
|
| 7 |
gpu_type = st.selectbox(
|
| 8 |
+
'GPU Type',
|
| 9 |
(
|
| 10 |
+
'H100 80GB',
|
| 11 |
+
'A100 80GB',
|
| 12 |
+
'A100 40GB',
|
| 13 |
+
'V100 16GB',
|
| 14 |
+
'P100 16GB',
|
| 15 |
+
'L4 24GB',
|
| 16 |
+
'T4 16GB',
|
| 17 |
+
'P4 8GB',
|
| 18 |
)
|
| 19 |
)
|
| 20 |
|
| 21 |
+
# Number of GPUs
|
| 22 |
+
gpu_number_mapping = {
|
| 23 |
+
'H100 80GB': [8],
|
| 24 |
+
'A100 80GB': [1,2,4,8],
|
| 25 |
+
'A100 40GB': [1,2,4,8,16],
|
| 26 |
+
'V100 16GB': [1,2,4,8],
|
| 27 |
+
'P100 16GB': [1,2,4],
|
| 28 |
+
'L4 24GB': [1,2,4,8],
|
| 29 |
+
'T4 16GB': [1,2,4],
|
| 30 |
+
'P4 8GB': [1,2,4],
|
| 31 |
+
}
|
| 32 |
+
gpu_number = st.selectbox('Number of GPUs', gpu_number_mapping[gpu_type])
|
| 33 |
+
|
| 34 |
+
# Instance Type
|
| 35 |
+
gpu_type_mapping = {
|
| 36 |
+
'H100 80GB': ["A3"],
|
| 37 |
+
'A100 80GB': ["A2"],
|
| 38 |
+
'A100 40GB': ["A2"],
|
| 39 |
+
'V100 16GB': ["N1", "CUSTOM"],
|
| 40 |
+
'P100 16GB': ["N1", "CUSTOM"],
|
| 41 |
+
'L4 24GB': ["G2", "CUSTOM"],
|
| 42 |
+
'T4 16GB': ["N1", "CUSTOM"],
|
| 43 |
+
'P4 8GB': ["N1", "CUSTOM"],
|
| 44 |
+
}
|
| 45 |
+
instance_type = st.selectbox('Instance Type', gpu_type_mapping[gpu_type])
|
| 46 |
+
|
| 47 |
+
# CPU Cores
|
| 48 |
+
cpu_cores_mapping = {
|
| 49 |
+
"A3": [208],
|
| 50 |
+
"A2": [12*gpu_number],
|
| 51 |
+
"G2": [12*gpu_number] if gpu_number > 1 else [4,8,12,16,32],
|
| 52 |
+
"N1": [1,2,4,8,16,32,96],
|
| 53 |
+
"CUSTOM": [1] + [i for i in range(2, 96+1, 2)]
|
| 54 |
+
}
|
| 55 |
+
if gpu_type != "CUSTOM":
|
| 56 |
+
cpu_cores = st.selectbox('Cores (vCPU)', cpu_cores_mapping[instance_type])
|
| 57 |
+
else:
|
| 58 |
+
cpu_cores = st.select_slider('Cores (vCPU)', cpu_cores_mapping[instance_type])
|
| 59 |
+
|
| 60 |
+
# Memory Size
|
| 61 |
+
memory_size_mapping = {
|
| 62 |
+
"A3": [1872],
|
| 63 |
+
"A2": [170*gpu_number],
|
| 64 |
+
"G2": [4*cpu_cores] if gpu_number > 1 else [48*gpu_number],
|
| 65 |
+
"N1": [cpu_cores*3.75],
|
| 66 |
+
"CUSTOM": [i for i in np.arange(cpu_cores, cpu_cores*6.5+1, 1)]
|
| 67 |
+
}
|
| 68 |
+
if gpu_type != "CUSTOM":
|
| 69 |
+
memory_size = st.selectbox('Memory (GB)', memory_size_mapping[instance_type])
|
| 70 |
+
else:
|
| 71 |
+
memory_size = st.select_slider('Memory (GB)', memory_size_mapping[instance_type])
|
| 72 |
+
|
| 73 |
+
# Balanced Disk
|
| 74 |
+
balanced_disk_size = st.select_slider('Balanced Disk (GB)', [i for i in range(10, 65536, 10)])
|
| 75 |
+
|
| 76 |
+
# SSD Disk
|
| 77 |
+
ssd_disk_size = st.select_slider('SSD Disk (GB)', [i * 375 for i in [1,2,3,4,5,6,7,8,16,24]])
|
| 78 |
+
|
| 79 |
+
# Pricing Estimate
|
| 80 |
+
serivces_mapping = {
|
| 81 |
+
"Core": {
|
| 82 |
+
"A3": 0.029917642,
|
| 83 |
+
"A2": 0.017880447,
|
| 84 |
+
"G2": 0.016626389,
|
| 85 |
+
"N1": 0.007834495,
|
| 86 |
+
"CUSTOM": 0.00782101,
|
| 87 |
+
},
|
| 88 |
+
"RAM": {
|
| 89 |
+
"A3": 0.002605197,
|
| 90 |
+
"A2": 0.002396196,
|
| 91 |
+
"G2": 0.00194851,
|
| 92 |
+
"N1": 0.001049094,
|
| 93 |
+
"CUSTOM": 0.001047746,
|
| 94 |
+
},
|
| 95 |
+
"GPU": {
|
| 96 |
+
'H100 80GB': 12.112232328,
|
| 97 |
+
'A100 80GB': 2.61383548,
|
| 98 |
+
'A100 40GB': 1.67288707,
|
| 99 |
+
'V100 16GB': 0.997853,
|
| 100 |
+
'P100 16GB': 0.5798335,
|
| 101 |
+
'L4 24GB': 0.279501996,
|
| 102 |
+
'T4 16GB': 0.1483295,
|
| 103 |
+
'P4 8GB': 0.29800745,
|
| 104 |
+
},
|
| 105 |
+
"PD": 0.1483295 / 30 / 24,
|
| 106 |
+
"SSD": 0.108550225 / 30 / 24,
|
| 107 |
+
}
|
| 108 |
|
| 109 |
+
core_price = serivces_mapping['Core'][instance_type] * cpu_cores
|
| 110 |
+
memory_price = serivces_mapping['RAM'][instance_type] * memory_size
|
| 111 |
+
gpu_price = serivces_mapping['GPU'][gpu_type] * gpu_number
|
| 112 |
+
balanced_disk_price = serivces_mapping['PD'] * balanced_disk_size
|
| 113 |
+
ssd_disk_price = serivces_mapping['SSD'] * ssd_disk_size
|
| 114 |
+
total_price = core_price + memory_price + gpu_price + balanced_disk_price + ssd_disk_price
|
| 115 |
|
| 116 |
+
st.write(core_price)
|
| 117 |
+
st.write(memory_price)
|
| 118 |
+
st.write(gpu_price)
|
| 119 |
+
st.write(balanced_disk_price)
|
| 120 |
+
st.write(ssd_disk_price)
|
| 121 |
+
st.write(total_price)
|