File size: 773 Bytes
1ced2fe
5eee7c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
import time

def load_model_with_retry(model_name, max_retries=3, delay=5):
    for attempt in range(max_retries):
        try:
            return gr.load(f"models/{model_name}")
        except Exception as e:
            print(f"Attempt {attempt + 1} failed: {str(e)}")
            if attempt < max_retries - 1:
                print(f"Retrying in {delay} seconds...")
                time.sleep(delay)
            else:
                print("Max retries reached. Unable to load model.")
                raise

try:
    model = load_model_with_retry("meta-llama/Meta-Llama-3.1-405B")
    model.launch()
except Exception as e:
    print(f"Failed to load model: {str(e)}")
    print("Consider using a smaller model or checking your network connection.")