Feat: CPU inference support
This commit is contained in:
@@ -27,6 +27,8 @@ def get_bert_feature(
|
||||
device = "mps"
|
||||
if not device:
|
||||
device = "cuda"
|
||||
if device == "cuda" and not torch.cuda.is_available():
|
||||
device = "cpu"
|
||||
if device not in models.keys():
|
||||
models[device] = AutoModelForMaskedLM.from_pretrained(LOCAL_PATH).to(device)
|
||||
with torch.no_grad():
|
||||
|
||||
Reference in New Issue
Block a user