Alexander Slessor commited on
Commit
a77ffa1
1 Parent(s): edeeba1

cuda device error debug

Browse files
Files changed (2) hide show
  1. README.md +16 -1
  2. handler.py +3 -2
README.md CHANGED
@@ -133,4 +133,19 @@ exact_match = 86.91
133
  biburl = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},
134
  bibsource = {dblp computer science bibliography, https://dblp.org}
135
  }
136
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  biburl = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},
134
  bibsource = {dblp computer science bibliography, https://dblp.org}
135
  }
136
+ ```
137
+
138
+
139
+
140
+ # HF endpoint deployment errors
141
+
142
+ 1
143
+ ```
144
+ {'error': 'Body needs to provide a inputs key, recieved: b\'{"question":"What is my name?","context":"My name is Clara and I live in Berkeley."}\''}
145
+ ```
146
+
147
+ 2
148
+ ```
149
+ {'error': 'Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument index in method wrapper__index_select)'}
150
+ ```
151
+
handler.py CHANGED
@@ -4,7 +4,7 @@ import torch
4
  # from scipy.special import softmax
5
 
6
  # set device
7
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
8
 
9
  # def print_tokens_with_ids(tokenizer, input_ids):
10
  # # BERT only needs the token IDs, but for the purpose of inspecting the
@@ -104,7 +104,8 @@ def get_answer(
104
 
105
  class EndpointHandler:
106
  def __init__(self, path=""):
107
- self.model = BertForQuestionAnswering.from_pretrained(path).to(device)
 
108
  self.tokenizer = BertTokenizer.from_pretrained(path)
109
 
110
  # def __call__(self, data: Dict[str, Any]):
 
4
  # from scipy.special import softmax
5
 
6
  # set device
7
+ # device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
8
 
9
  # def print_tokens_with_ids(tokenizer, input_ids):
10
  # # BERT only needs the token IDs, but for the purpose of inspecting the
 
104
 
105
  class EndpointHandler:
106
  def __init__(self, path=""):
107
+ # self.model = BertForQuestionAnswering.from_pretrained(path).to(device)
108
+ self.model = BertForQuestionAnswering.from_pretrained(path)
109
  self.tokenizer = BertTokenizer.from_pretrained(path)
110
 
111
  # def __call__(self, data: Dict[str, Any]):