Spaces:
Sleeping
Sleeping
Commit
·
b97e59a
1
Parent(s):
c9281d9
Added compile
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import tiktoken
|
|
3 |
import gradio as gr
|
4 |
import torch.nn.functional as F
|
5 |
from model import GPT, GPTConfig
|
|
|
6 |
|
7 |
device = 'cpu'
|
8 |
if torch.cuda.is_available():
|
@@ -14,6 +15,7 @@ model = GPT(GPTConfig())
|
|
14 |
model.load_state_dict(torch.load("gpt2.pt", map_location=torch.device(device)), strict=False)
|
15 |
|
16 |
model.to(device)
|
|
|
17 |
|
18 |
enc = tiktoken.get_encoding('gpt2')
|
19 |
|
@@ -53,7 +55,7 @@ def inference(input_text, num_return_sequences, max_length):
|
|
53 |
|
54 |
title = "GPT-2 trained on Shakespeare Plays dataset"
|
55 |
description = "A simple Gradio interface to generate text from GPT-2 model trained on Shakespeare Plays"
|
56 |
-
examples = [["Please put on these earmuffs because I can't you
|
57 |
["Twin 4-month-olds slept in the shade of the palm tree while the mother tanned in the sun.", 2, 20],
|
58 |
["Happiness can be found in the depths of chocolate pudding.", 2, 20],
|
59 |
["Seek success, but always be prepared for random cats.", 2, 20],
|
|
|
3 |
import gradio as gr
|
4 |
import torch.nn.functional as F
|
5 |
from model import GPT, GPTConfig
|
6 |
+
torch._dynamo.reset()
|
7 |
|
8 |
device = 'cpu'
|
9 |
if torch.cuda.is_available():
|
|
|
15 |
model.load_state_dict(torch.load("gpt2.pt", map_location=torch.device(device)), strict=False)
|
16 |
|
17 |
model.to(device)
|
18 |
+
model = torch.compile(model, fullgraph=True, backend="cudagraphs")
|
19 |
|
20 |
enc = tiktoken.get_encoding('gpt2')
|
21 |
|
|
|
55 |
|
56 |
title = "GPT-2 trained on Shakespeare Plays dataset"
|
57 |
description = "A simple Gradio interface to generate text from GPT-2 model trained on Shakespeare Plays"
|
58 |
+
examples = [["Please put on these earmuffs because I can't hear you.", 2, 20],
|
59 |
["Twin 4-month-olds slept in the shade of the palm tree while the mother tanned in the sun.", 2, 20],
|
60 |
["Happiness can be found in the depths of chocolate pudding.", 2, 20],
|
61 |
["Seek success, but always be prepared for random cats.", 2, 20],
|