Spaces:
Runtime error
Runtime error
Tim Betz
commited on
Commit
·
7fa395b
1
Parent(s):
a702d2b
hotfix device
Browse files
app.py
CHANGED
|
@@ -4,13 +4,13 @@ from transformers import AutoTokenizer
|
|
| 4 |
|
| 5 |
from model import GPT, GPTConfig
|
| 6 |
|
| 7 |
-
DEVICE =
|
| 8 |
|
| 9 |
|
| 10 |
def setup(model_path: str):
|
| 11 |
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 12 |
if DEVICE == "cpu":
|
| 13 |
-
checkpoint = torch.load(model_path, map_location=torch.device(
|
| 14 |
else:
|
| 15 |
checkpoint = torch.load(model_path)
|
| 16 |
model = GPT(GPTConfig(**checkpoint["model_args"]))
|
|
|
|
| 4 |
|
| 5 |
from model import GPT, GPTConfig
|
| 6 |
|
| 7 |
+
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
|
| 10 |
def setup(model_path: str):
|
| 11 |
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 12 |
if DEVICE == "cpu":
|
| 13 |
+
checkpoint = torch.load(model_path, map_location=torch.device("cpu"))
|
| 14 |
else:
|
| 15 |
checkpoint = torch.load(model_path)
|
| 16 |
model = GPT(GPTConfig(**checkpoint["model_args"]))
|