akshaytrikha commited on
Commit
71eba68
1 Parent(s): 8cce078

use cuda if available

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -1,7 +1,8 @@
1
  import gradio as gr
2
  from transformers import GPT2LMHeadModel, pipeline
 
3
 
4
- device = 'cuda' if args.cuda else 'cpu'
5
 
6
  # load pretrained + finetuned GPT2
7
  model = GPT2LMHeadModel.from_pretrained("./model/pytorch_model.bin", from_pt=True)
 
1
  import gradio as gr
2
  from transformers import GPT2LMHeadModel, pipeline
3
+ import torch
4
 
5
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
6
 
7
  # load pretrained + finetuned GPT2
8
  model = GPT2LMHeadModel.from_pretrained("./model/pytorch_model.bin", from_pt=True)