import streamlit as st import pandas as pd import time import random def calculate_cost(num_pairs, num_shirts, num_pants, gpu_type): if gpu_type == "Nvidia A100": daily_rate = 28 time_per_pair = 1 # minute elif gpu_type == "H100 80GB PCIe": daily_rate = 78.96 time_per_pair = 0.5 # assuming it's twice as fast else: # AWS p4d.24xlarge daily_rate = 786.48 time_per_pair = 0.25 # assuming it's four times as fast due to 8 GPUs total_items = num_pairs + num_shirts + num_pants total_time_minutes = total_items * (time_per_pair / 2) # Divide by 2 as per the new logic total_time_hours = total_time_minutes / 60 hourly_rate = daily_rate / 24 total_cost = total_time_hours * hourly_rate return total_cost def generate_random_case(gpu_type): new_case = { 'pairs': random.randint(0, 9), 'shirts': random.randint(0, 19), 'pants': random.randint(0, 19) } new_case['price'] = calculate_cost(new_case['pairs'], new_case['shirts'], new_case['pants'], gpu_type) return new_case def main(): st.set_page_config(page_title="Automated GPU Cost Calculator", page_icon="🧮", layout="wide") st.title("Automated GPU Cost Calculator") col1, col2 = st.columns(2) with col1: is_automated = st.toggle("Automate case generation") gpu_type = st.selectbox( "Select GPU type:", ("Nvidia A100", "H100 80GB PCIe", "AWS p4d.24xlarge (8x A100)") ) with col2: if not is_automated: num_pairs = st.number_input("Number of pairs:", min_value=0, value=0) num_shirts = st.number_input("Number of shirts:", min_value=0, value=0) num_pants = st.number_input("Number of pants:", min_value=0, value=0) if st.button("Calculate Cost"): cost = calculate_cost(num_pairs, num_shirts, num_pants, gpu_type) st.write(f"Estimated cost: ${cost:.4f}") else: num_pairs = num_shirts = num_pants = 0 cases = [] cost_placeholder = st.empty() cases_placeholder = st.empty() while is_automated: new_case = generate_random_case(gpu_type) cases.append(new_case) num_pairs += new_case['pairs'] num_shirts += new_case['shirts'] num_pants += new_case['pants'] total_cost = calculate_cost(num_pairs, num_shirts, num_pants, gpu_type) cost_placeholder.write(f"Total cost: ${total_cost:.4f}") cases_text = "**Generated Cases**\n" for i, case in enumerate(cases[-10:], 1): # Show only the last 10 cases cases_text += f"* Case {i}: {case['pairs']} pairs, {case['shirts']} shirts, {case['pants']} pants = ${case['price']:.4f}\n" cases_placeholder.markdown(cases_text) time.sleep(5) # Generate a new case every 5 seconds st.subheader("GPU Information") gpu_data = { "Provider": ["H100 80GB PCIe", "AWS (p4d.24xlarge)", "GPU Mart"], "GPU": ["Nvidia H100", "Nvidia A100 (8 GPUs)", "Nvidia A100"], "vCPUs": [16, 96, "Dual 18-Core E5-2697v4"], "RAM": ["125 GB", "1152 GiB", "256 GB"], "GPU Memory": ["80 GB", "320 GB (8 x 40 GB)", "40 GB HBM2e"], "Instance Storage": ["Network Storage: 10Pb+", "8 x 1000 GB NVMe SSD", "240 GB SSD + 2TB NVMe + 8TB SATA"], "Network Bandwidth": ["Not Specified", "400 Gbps", "100Mbps - 1Gbps"], "On-Demand Price/hr": ["$3.29", "$32.77", "N/A"], "Daily Price": ["$78.96", "$786.48", "$28.00"], "Monthly Price": ["$2,368.80", "$23,594.40", "$799.00"], "1-Year Reserved (Hourly)": ["N/A", "$19.22", "N/A"], "3-Year Reserved (Hourly)": ["N/A", "$11.57", "N/A"] } df = pd.DataFrame(gpu_data) st.table(df) if __name__ == "__main__": main()