├── .gitignore ├── Makefile ├── README.md ├── app.py └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .venv 2 | .env 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VENV = .venv 2 | PYTHON = $(VENV)/bin/python3 3 | PIP = $(VENV)/bin/pip3 4 | STREAMLIT= $(VENV)/bin/streamlit 5 | 6 | 7 | # Need to use python 3.9 for aws lambda 8 | $(VENV)/bin/activate: requirements.txt 9 | python3 -m venv $(VENV) 10 | $(PIP) install -r requirements.txt 11 | 12 | init: $(VENV)/bin/activate 13 | 14 | app: $(VENV)/bin/activate 15 | $(STREAMLIT) run app.py --server.port 1808 16 | 17 | 18 | clean: 19 | rm -rf __pycache__ 20 | rm -rf $(VENV) 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # llm_gpu_cal 2 | Simple GPU calculator for your LLM pre-training and fine-tuning 3 | 4 | Demo: https://gpu.sung.devstage.ai/ 5 | 6 | image 7 | 8 | 9 | ## Contributions 10 | We welcome your PR and comments 11 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | import math 3 | 4 | # Function to calculate the number of GPUs needed 5 | def calculate_gpus(tokens, hours, epochs, model_size): 6 | A = math.ceil((tokens * epochs * model_size * 13.3) / hours) 7 | H = math.ceil(A / 2) 8 | st.markdown(f'**Number of A100 (80G) GPUs needed: {A}**') 9 | st.markdown(f'**Number of H100 (80G) GPUs needed: {H}**') 10 | 11 | def calculate_gpus_inference(throughput, qpm, output_tokens): 12 | A = math.ceil(output_tokens / throughput * qpm / 60) 13 | H = math.ceil(A / 2) 14 | st.markdown(f'**Number of A100 (80G) GPUs needed: {A}**') 15 | st.markdown(f'**Number of H100 (80G) GPUs needed: {H}**') 16 | 17 | # Streamlit app 18 | page_title = "LLM GPU Calculator" 19 | st.set_page_config(page_title=page_title, page_icon="🔮") 20 | st.title('🔮 ' + page_title) 21 | 22 | # Create a form 23 | st.markdown('## Training GPUs') 24 | with st.form(key='gpu_calculator_training'): 25 | 26 | # Input fields 27 | tokens = st.number_input('Enter the number of tokens (in billions)', value=1, format="%i") 28 | hours = st.number_input('Enter the time to finish (in hours)', value=40, format="%i") 29 | epochs = st.number_input('Enter the number of epochs', value=2, format="%i") 30 | model_size = st.number_input('Enter the model size (in billions)', value=30, format="%i") 31 | 32 | # Calculate button 33 | st.form_submit_button('Calculate Training GPUs', on_click=calculate_gpus(tokens, hours, epochs, model_size)) 34 | 35 | st.markdown('## Inference GPUs') 36 | with st.form(key='gpu_calculator_inference'): 37 | 38 | # Input fields 39 | throughput = st.number_input('Enter the model throughput (in tokens/sec)', value=30, format="%i") 40 | qpm = st.number_input('Enter the max number queries per minute', value=10, format="%i") 41 | output_tokens = st.number_input('Enter the average number of output tokens', value=300, format="%i") 42 | 43 | # Calculate button 44 | st.form_submit_button('Calculate Inference GPUs', on_click=calculate_gpus_inference(throughput, qpm, output_tokens)) 45 | 46 | # Put github link at the bottom https://github.com/hunkim/llm_gpt_cal 47 | st.markdown('**Github:** https://github.com/hunkim/llm_gpu_cal') -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | streamlit 2 | pdf2image 3 | git+https://github.com/hunkimForks/ocr_client.git 4 | --------------------------------------------------------------------------------