noumanjavaid commited on
Commit
de0ab5e
·
verified ·
1 Parent(s): 4262dbe

Rename app.py to gpu_calculator.py

Browse files
Files changed (2) hide show
  1. app.py +0 -64
  2. gpu_calculator.py +99 -0
app.py DELETED
@@ -1,64 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
-
4
- def calculate_cost(num_pairs, gpu_type):
5
- if gpu_type == "Nvidia A100":
6
- daily_rate = 28
7
- time_per_pair = 1 # minute
8
- elif gpu_type == "H100 80GB PCIe":
9
- daily_rate = 78.96
10
- time_per_pair = 0.5 # assuming it's twice as fast
11
- else: # AWS p4d.24xlarge
12
- daily_rate = 786.48
13
- time_per_pair = 0.25 # assuming it's four times as fast due to 8 GPUs
14
-
15
- total_time_minutes = num_pairs * time_per_pair
16
- total_time_hours = total_time_minutes / 60
17
- hourly_rate = daily_rate / 24
18
- total_cost = total_time_hours * hourly_rate
19
-
20
- return total_cost
21
-
22
- st.set_page_config(page_title="GPU Cost Calculator", page_icon="🧮", layout="wide")
23
-
24
- st.title("GPU Cost Calculator")
25
-
26
- # Input for number of pairs
27
- num_pairs = st.number_input("Enter the number of pairs to process:", min_value=1, value=5)
28
-
29
- # Input for shirt size
30
- shirt_size = st.text_input("Enter shirt size (e.g., S, M, L, XL):")
31
-
32
- # Input for bottom wear size
33
- bottom_wear_size = st.text_input("Enter bottom wear size (e.g., S, M, L, XL):")
34
-
35
- # Select GPU type
36
- gpu_type = st.selectbox(
37
- "Select GPU type:",
38
- ("Nvidia A100", "H100 80GB PCIe", "AWS p4d.24xlarge (8x A100)")
39
- )
40
-
41
- # Calculate button
42
- if st.button("Calculate Cost"):
43
- cost = calculate_cost(num_pairs, gpu_type)
44
- st.write(f"Estimated cost for processing {num_pairs} pairs on {gpu_type}: ${cost:.4f}")
45
-
46
- # Display GPU information
47
- st.subheader("GPU Information")
48
- gpu_data = {
49
- "Provider": ["H100 80GB PCIe", "AWS (p4d.24xlarge)", "GPU Mart"],
50
- "GPU": ["Nvidia H100", "Nvidia A100 (8 GPUs)", "Nvidia A100"],
51
- "vCPUs": [16, 96, "Dual 18-Core E5-2697v4"],
52
- "RAM": ["125 GB", "1152 GiB", "256 GB"],
53
- "GPU Memory": ["80 GB", "320 GB (8 x 40 GB)", "40 GB HBM2e"],
54
- "Instance Storage": ["Network Storage: 10Pb+", "8 x 1000 GB NVMe SSD", "240 GB SSD + 2TB NVMe + 8TB SATA"],
55
- "Network Bandwidth": ["Not Specified", "400 Gbps", "100Mbps - 1Gbps"],
56
- "On-Demand Price/hr": ["$3.29", "$32.77", "N/A"],
57
- "Daily Price": ["$78.96", "$786.48", "$28.00"],
58
- "Monthly Price": ["$2,368.80", "$23,594.40", "$799.00"],
59
- "1-Year Reserved (Hourly)": ["N/A", "$19.22", "N/A"],
60
- "3-Year Reserved (Hourly)": ["N/A", "$11.57", "N/A"]
61
- }
62
-
63
- df = pd.DataFrame(gpu_data)
64
- st.table(df)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
gpu_calculator.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import time
4
+ import random
5
+
6
+ def calculate_cost(num_pairs, num_shirts, num_pants, gpu_type):
7
+ if gpu_type == "Nvidia A100":
8
+ daily_rate = 28
9
+ time_per_pair = 1 # minute
10
+ elif gpu_type == "H100 80GB PCIe":
11
+ daily_rate = 78.96
12
+ time_per_pair = 0.5 # assuming it's twice as fast
13
+ else: # AWS p4d.24xlarge
14
+ daily_rate = 786.48
15
+ time_per_pair = 0.25 # assuming it's four times as fast due to 8 GPUs
16
+
17
+ total_items = num_pairs + num_shirts + num_pants
18
+ total_time_minutes = total_items * (time_per_pair / 2) # Divide by 2 as per the new logic
19
+ total_time_hours = total_time_minutes / 60
20
+ hourly_rate = daily_rate / 24
21
+ total_cost = total_time_hours * hourly_rate
22
+
23
+ return total_cost
24
+
25
+ def generate_random_case(gpu_type):
26
+ new_case = {
27
+ 'pairs': random.randint(0, 9),
28
+ 'shirts': random.randint(0, 19),
29
+ 'pants': random.randint(0, 19)
30
+ }
31
+ new_case['price'] = calculate_cost(new_case['pairs'], new_case['shirts'], new_case['pants'], gpu_type)
32
+ return new_case
33
+
34
+ def main():
35
+ st.set_page_config(page_title="Automated GPU Cost Calculator", page_icon="🧮", layout="wide")
36
+
37
+ st.title("Automated GPU Cost Calculator")
38
+
39
+ col1, col2 = st.columns(2)
40
+
41
+ with col1:
42
+ is_automated = st.toggle("Automate case generation")
43
+ gpu_type = st.selectbox(
44
+ "Select GPU type:",
45
+ ("Nvidia A100", "H100 80GB PCIe", "AWS p4d.24xlarge (8x A100)")
46
+ )
47
+
48
+ with col2:
49
+ if not is_automated:
50
+ num_pairs = st.number_input("Number of pairs:", min_value=0, value=0)
51
+ num_shirts = st.number_input("Number of shirts:", min_value=0, value=0)
52
+ num_pants = st.number_input("Number of pants:", min_value=0, value=0)
53
+ if st.button("Calculate Cost"):
54
+ cost = calculate_cost(num_pairs, num_shirts, num_pants, gpu_type)
55
+ st.write(f"Estimated cost: ${cost:.4f}")
56
+ else:
57
+ num_pairs = num_shirts = num_pants = 0
58
+ cases = []
59
+ cost_placeholder = st.empty()
60
+ cases_placeholder = st.empty()
61
+
62
+ while is_automated:
63
+ new_case = generate_random_case(gpu_type)
64
+ cases.append(new_case)
65
+ num_pairs += new_case['pairs']
66
+ num_shirts += new_case['shirts']
67
+ num_pants += new_case['pants']
68
+
69
+ total_cost = calculate_cost(num_pairs, num_shirts, num_pants, gpu_type)
70
+ cost_placeholder.write(f"Total cost: ${total_cost:.4f}")
71
+
72
+ cases_text = "**Generated Cases**\n"
73
+ for i, case in enumerate(cases[-10:], 1): # Show only the last 10 cases
74
+ cases_text += f"* Case {i}: {case['pairs']} pairs, {case['shirts']} shirts, {case['pants']} pants = ${case['price']:.4f}\n"
75
+ cases_placeholder.markdown(cases_text)
76
+
77
+ time.sleep(5) # Generate a new case every 5 seconds
78
+
79
+ st.subheader("GPU Information")
80
+ gpu_data = {
81
+ "Provider": ["H100 80GB PCIe", "AWS (p4d.24xlarge)", "GPU Mart"],
82
+ "GPU": ["Nvidia H100", "Nvidia A100 (8 GPUs)", "Nvidia A100"],
83
+ "vCPUs": [16, 96, "Dual 18-Core E5-2697v4"],
84
+ "RAM": ["125 GB", "1152 GiB", "256 GB"],
85
+ "GPU Memory": ["80 GB", "320 GB (8 x 40 GB)", "40 GB HBM2e"],
86
+ "Instance Storage": ["Network Storage: 10Pb+", "8 x 1000 GB NVMe SSD", "240 GB SSD + 2TB NVMe + 8TB SATA"],
87
+ "Network Bandwidth": ["Not Specified", "400 Gbps", "100Mbps - 1Gbps"],
88
+ "On-Demand Price/hr": ["$3.29", "$32.77", "N/A"],
89
+ "Daily Price": ["$78.96", "$786.48", "$28.00"],
90
+ "Monthly Price": ["$2,368.80", "$23,594.40", "$799.00"],
91
+ "1-Year Reserved (Hourly)": ["N/A", "$19.22", "N/A"],
92
+ "3-Year Reserved (Hourly)": ["N/A", "$11.57", "N/A"]
93
+ }
94
+
95
+ df = pd.DataFrame(gpu_data)
96
+ st.table(df)
97
+
98
+ if __name__ == "__main__":
99
+ main()