sasha's picture
sasha HF Staff
adding link to blog
d1dca78
import gradio as gr
import pandas as pd
import plotly.express as px
merged_df = pd.read_csv("data/merged_cloud_data.csv")
options = [
"CPU type",
"CPU TDP",
"Memory",
"GPU Type",
"GPU Cost",
"GPU Total Cost",
"GPU number",
"TDP (W)",
"GPU Year",
"Total TDP (W)",
"$/Hour",
"provider",
"GPU TDP",
"vCPU",
"CPU Type",
"GPU Memory",
"vCPU(s)",
]
### TDP figs
#
tdp_fig = px.scatter(
merged_df,
x="Total TDP (W)",
y="$/Hour",
color="provider",
log_x=True,
log_y=True,
)
tdp_fig_gpu = px.scatter(
merged_df,
x="Total TDP (W)",
y="$/Hour",
color="GPU Type",
log_x=True,
log_y=True,
)
cost_fig = px.scatter(
merged_df,
x="GPU Total Cost",
y="$/Hour",
color="provider",
log_y=True,
log_x=True,
)
cost_fig_gpu = px.scatter(
merged_df,
x="GPU Total Cost",
y="$/Hour",
color="GPU Type",
log_y=True,
log_x=True,
)
def generate_figure(factor1, factor2, color, logx, logy):
fig = px.scatter(
merged_df,
x=factor1,
y=factor2,
color=color,
log_y=logx,
log_x=logy,
)
return fig
with gr.Blocks() as demo:
gr.Markdown("# Cloud Compute ☁️, Energy ⚑ and Cost πŸ’² - Comparison Tool")
gr.Markdown(
"## Explore the data from the blog post ['When we pay for cloud compute, what are we really paying for?'](https://huggingface.co/blog/sasha/energy-cost-compute)"
)
with gr.Accordion("Methodology", open=False):
gr.Markdown(
"""
In order to do our analysis, we gathered data from 5 major cloud compute providers – Microsoft Azure, Amazon Web Services, Google Cloud Platform,
Scaleway Cloud, and OVH Cloud – about the price and nature of their AI-specific compute offerings (i.e. all instances that have GPUs).
For each instance, we looked at its characteristics – the type and number of GPUs and CPUs that it contains, as well as the quantity of memory
it contains and its storage capacity. For each CPU and GPU model, we looked up its **TDP (Thermal Design Potential)** -- its power consumption
under the maximum theoretical load), which is an indicator of the operating expenses required to power it. For GPUs specifically, we also looked
at the **Manufacturer's Suggested Retail Price (MSRP)**, i.e. how much that particular GPU model cost at the time of its launch, as an indicator
of the capital expenditure required for the compute provider to buy the GPUs to begin with.
"""
)
with gr.Row():
with gr.Column():
gr.Markdown("## Energy ⚑ vs Hourly Cost πŸ’²")
gr.Markdown(
"### In our analysis, we found that there is also a strong positive correlation between the two factors, across different compute providers:"
)
with gr.Row():
with gr.Column():
gr.Markdown(
"Double click the names of cloud providers to see the trend per company"
)
plt1 = gr.Plot(tdp_fig)
with gr.Column():
gr.Markdown(
"Double click the names of GPU models to see the trends per GPU"
)
plt1 = gr.Plot(tdp_fig_gpu)
with gr.Row():
with gr.Column():
gr.Markdown("## CapEx πŸ’° vs Hourly Cost πŸ’²")
gr.Markdown(
"### We also found that there is also a strong positive correlation the initial cost of the GPU and its cost per hour:"
)
with gr.Row():
with gr.Column():
gr.Markdown(
"Double click the names of cloud providers to see the trend per company"
)
plt1 = gr.Plot(cost_fig)
with gr.Column():
gr.Markdown(
"Double click the names of GPU models to see the trends per GPU"
)
plt1 = gr.Plot(cost_fig_gpu)
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("## Generate your own plot πŸ“ˆ")
x_choice = gr.Dropdown(
options,
value="Memory",
label="X axis",
info="Pick a characteristic to plot on the X (horizontal) axis",
interactive=True,
allow_custom_value=True,
)
y_choice = gr.Dropdown(
options,
value="$/Hour",
label="Y axis",
info="Pick a characteristic to plot on the Y (vertical) axis",
interactive=True,
allow_custom_value=True,
)
color_choice = gr.Dropdown(
options,
value="provider",
label="Plot color",
info="Pick a characteristic for the colors/labels",
interactive=True,
allow_custom_value=True,
)
logx = gr.Checkbox(
label="Logarithmic X axis",
info="Plot the X (horizontal) axis in logarithmic scale",
value=True,
interactive=True,
)
logy = gr.Checkbox(
label="Logarithmic Y axis",
info="Plot the Y (vertical) axis in logarithmic scale",
value=True,
interactive=True,
)
with gr.Column(scale=3):
gr.Markdown(
"### Choose from the dropdown lists on the left to plot different characteristics and find new trends πŸ•΅πŸ»β€β™‚οΈ"
)
gr.Markdown(
"N.B. Not all combinations are possible -- if you get a blank figure, try another combination!"
)
fig = generate_figure("Memory", "$/Hour", "provider", True, True)
plt = gr.Plot(fig)
x_choice.select(
generate_figure,
inputs=[x_choice, y_choice, color_choice, logx, logy],
outputs=[plt],
)
y_choice.select(
generate_figure,
inputs=[x_choice, y_choice, color_choice, logx, logy],
outputs=[plt],
)
color_choice.select(
generate_figure,
inputs=[x_choice, y_choice, color_choice, logx, logy],
outputs=[plt],
)
logx.select(
generate_figure,
inputs=[x_choice, y_choice, color_choice, logx, logy],
outputs=[plt],
)
logy.select(
generate_figure,
inputs=[x_choice, y_choice, color_choice, logx, logy],
outputs=[plt],
)
demo.launch()