File size: 16,697 Bytes
9da4649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
076f378
9da4649
 
 
 
 
 
 
 
82e95d2
9da4649
 
 
 
71eee6c
9da4649
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from pydantic import BaseModel
from fastapi.staticfiles import StaticFiles


# Create FastAPI instance
app = FastAPI()

# Request model
class InputData(BaseModel):
    text: str

# Mount the static folder
#app.mount("/static", StaticFiles(directory="static"), name="static")

# Home Route with HTML page and description
@app.get("/", response_class=HTMLResponse)
async def home():
    html_content = """
    <html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>About the AI Model GPU Recommender</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary-color: #4361ee;
            --primary-dark: #3a56d4;
            --secondary-color: #7209b7;
            --accent-color: #f72585;
            --light-bg: #f8f9fa;
            --card-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
            --section-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            --header-gradient: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
        }
        
        body {
            padding-top: 20px;
            padding-bottom: 40px;
            background-color: var(--light-bg);
            color: #333;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        .content-container {
            background: white;
            padding: 30px;
            border-radius: 16px;
            box-shadow: var(--card-shadow);
            margin-bottom: 30px;
        }
        
        .header {
            margin-bottom: 40px;
            padding: 40px 20px;
            border-radius: 16px;
            background: var(--header-gradient);
            color: white;
            box-shadow: var(--card-shadow);
        }
        
        .header h1 {
            font-weight: 700;
            font-size: 2.8rem;
            margin-bottom: 10px;
        }
        
        .header .lead {
            font-size: 1.3rem;
            opacity: 0.9;
        }
        
        .section {
            margin-bottom: 40px;
        }
        
        .section-title {
            color: var(--primary-color);
            font-weight: 600;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--primary-color);
        }
        
        .section-content {
            line-height: 1.7;
        }
        
        .benefit-card {
            background-color: var(--light-bg);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 20px;
            border-left: 4px solid var(--primary-color);
            box-shadow: var(--section-shadow);
            transition: transform 0.2s, box-shadow 0.2s;
        }
        
        .benefit-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
        }
        
        .benefit-card h5 {
            color: var(--primary-color);
            font-weight: 600;
            margin-bottom: 15px;
            display: flex;
            align-items: center;
        }
        
        .benefit-card h5 i {
            margin-right: 10px;
        }
        
        .highlight {
            background-color: rgba(67, 97, 238, 0.1);
            padding: 3px 6px;
            border-radius: 4px;
            font-weight: 500;
            color: var(--primary-dark);
        }
        
        .footer {
            text-align: center;
            padding: 15px;
            color: #6c757d;
            font-size: 0.9rem;
        }
        
        .btn-primary {
            background-color: var(--primary-color);
            border-color: var(--primary-color);
            padding: 12px 25px;
            border-radius: 8px;
            font-weight: 600;
            letter-spacing: 0.5px;
            box-shadow: 0 4px 10px rgba(67, 97, 238, 0.3);
            transition: all 0.3s;
        }
        
        .btn-primary:hover {
            background-color: var(--primary-dark);
            border-color: var(--primary-dark);
            box-shadow: 0 6px 15px rgba(67, 97, 238, 0.4);
            transform: translateY(-2px);
        }
        
        /* Animation */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .animate-fade-in {
            animation: fadeIn 0.5s ease-out forwards;
        }
        
        .delay-1 { animation-delay: 0.1s; }
        .delay-2 { animation-delay: 0.2s; }
        .delay-3 { animation-delay: 0.3s; }
        .delay-4 { animation-delay: 0.4s; }
    </style>
</head>
<body>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-10">
                <div class="header text-center animate-fade-in">
                    <h1><i class="fas fa-microchip"></i> AI Model GPU Recommender</h1>
                    <p class="lead">A Critical Tool for AI Hardware Planning</p>
                </div>
                
                <div class="content-container animate-fade-in delay-1">
                    <div class="section">
                        <h2 class="section-title">Why Accurate Hardware Estimation Matters</h2>
                        <div class="section-content">
                            <p>The AI Model GPU Recommender provides essential guidance for one of the most challenging aspects of machine learning development: hardware planning. As AI models grow increasingly complex, selecting appropriate GPU hardware has become a critical but difficult decision with significant financial implications.</p>
                            
                            <h3 class="mt-5 mb-4">Precision in Technical Requirements</h3>
                            
                            <p>Our estimator brings precision to hardware planning through:</p>
                            
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-memory"></i> Accurate VRAM Calculation</h5>
                                        <p>The tool employs sophisticated algorithms that consider model architecture, size, batch size, and precision to calculate memory requirements with high accuracy. For large language models (10B+ parameters), our calculations account for KV cache scaling, attention matrices, and architecture-specific memory patterns.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-brain"></i> Architecture-Specific Considerations</h5>
                                        <p>Different model types (Transformers, CNNs, etc.) have vastly different memory access patterns and compute requirements. Our tool adjusts estimates based on architecture, recognizing that transformers with their attention mechanisms have different scaling properties than convolutional networks.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-cogs"></i> Training vs. Inference Optimization</h5>
                                        <p>The recommender distinguishes between training and inference requirements, accounting for the additional memory needed during training for gradients, optimizer states, and activations. This prevents under-provisioning hardware for training workloads.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-calculator"></i> Precision-Aware Calculations</h5>
                                        <p>By factoring in different numerical precision options (FP32, FP16, INT8), the tool provides realistic memory estimates that can help developers make informed trade-offs between accuracy and efficiency.</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="section">
                        <h2 class="section-title">Financial Impact and Cost Optimization</h2>
                        <div class="section-content">
                            <p>Accurate hardware estimation directly translates to significant cost savings:</p>
                            
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-dollar-sign"></i> Capital Expenditure Reduction</h5>
                                        <p>By recommending appropriately sized GPUs, the tool helps organizations avoid over-provisioning, which can save thousands to millions of dollars in hardware costs. For instance, purchasing an A100 ($10,000+) when an RTX 4090 (~$1,600) would suffice represents an <span class="highlight">84% cost reduction</span>.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-bolt"></i> Operational Cost Management</h5>
                                        <p>Power consumption varies dramatically between GPU models (from 70W for a T4 to 700W for an H100). Our recommendations include power efficiency considerations that can result in substantial electricity savings over time.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-balance-scale"></i> Budget-Constrained Optimization</h5>
                                        <p>The tool factors in budget constraints to find the most suitable GPU option within financial limitations, maximizing performance per dollar.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-expand-arrows-alt"></i> Scaling Guidance</h5>
                                        <p>For very large models (20B+ parameters), the recommender provides guidance on multi-GPU setups and distributed training strategies, helping organizations plan their infrastructure scaling approach.</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="section">
                        <h2 class="section-title">Real-World Value Proposition</h2>
                        <div class="section-content">
                            <p>The tangible benefits of the AI Model GPU Recommender include:</p>
                            
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-shield-alt"></i> Risk Mitigation</h5>
                                        <p>Failed training runs due to out-of-memory errors represent wasted time and resources. Our accurate VRAM calculations help developers avoid these costly setbacks.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-rocket"></i> Time-to-Market Acceleration</h5>
                                        <p>By quickly identifying the optimal hardware configuration, the tool eliminates lengthy trial-and-error processes that would otherwise delay development cycles.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-chart-line"></i> Hardware Utilization Optimization</h5>
                                        <p>The suitability score helps identify GPUs that will achieve high utilization rates without waste, maximizing return on hardware investment.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-compass"></i> Strategic Planning Support</h5>
                                        <p>The detailed analysis provides organizations with insights for long-term infrastructure planning, helping them prepare for model growth and evolution.</p>
                                    </div>
                                </div>
                                
                                <div class="col-md-12">
                                    <div class="benefit-card">
                                        <h5><i class="fas fa-users"></i> Democratization of AI Development</h5>
                                        <p>By making hardware requirements more transparent, the tool helps smaller teams and organizations with limited AI experience make informed decisions about hardware investments.</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="section">
                        <h2 class="section-title">Conclusion</h2>
                        <div class="section-content">
                            <p>In an era where AI model sizes are growing exponentially and hardware costs represent a significant portion of AI development budgets, the AI Model GPU Recommender serves as an invaluable planning tool. Its accuracy in technical requirements estimation and focus on cost-efficiency makes it essential for organizations seeking to optimize their AI hardware investments while ensuring their models have the resources needed to perform effectively.</p>
                            
                            <div class="text-center mt-5 mb-3">
                                <a href="" class="btn btn-primary btn-lg">
                                    <i class="fas fa-tools me-2"></i> Try the GPU Recommender
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="footer">
                    <p>AI GPU Recommender Tool &copy; 2025 | <a href="">Home</a> | <a href="Coming Soon">About</a></p>
                </div>
            </div>
        </div>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

    """
    return HTMLResponse(content=html_content)

# Prediction Route
@app.post("/predict")
async def predict(data: InputData):
    # Example: Simple text length prediction
    result = {"prediction": len(data.text)}
    return result