mirror of
https://github.com/wassname/Clover-Edition.git
synced 2026-09-09 11:13:26 +08:00
uses gpu by default
This commit is contained in:
+2
-2
@@ -35,7 +35,7 @@ console-bell = on
|
||||
# Not sure of a good default but 80 was considered an ideal standard number of columns in old PCs.
|
||||
text-wrap-width = 80
|
||||
|
||||
cpu = off
|
||||
force-cpu = off
|
||||
|
||||
log-level = 20
|
||||
|
||||
@@ -88,7 +88,7 @@ loading-message = 7;34
|
||||
message=7;35
|
||||
title = 31
|
||||
subtitle = 36
|
||||
subsubtitle = 35
|
||||
subsubtitle = 36;7
|
||||
instructions = 33
|
||||
selection-prompt = 7;32
|
||||
selection-value = 35
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@ from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
||||
from getconfig import settings, logger
|
||||
from story.utils import cut_trailing_sentence
|
||||
|
||||
CPU = torch.cuda.is_available() and not settings.getboolean('force-cpu')
|
||||
|
||||
# warnings.filterwarnings("ignore")
|
||||
MODEL_CLASSES = {
|
||||
"gpt2": (GPT2LMHeadModel, GPT2Tokenizer),
|
||||
@@ -104,7 +106,7 @@ class GPT2Generator:
|
||||
self.top_p = top_p
|
||||
self.censor = censor
|
||||
self.samples = 1
|
||||
self.dtype = torch.float32 if settings.getboolean('cpu') else torch.float16
|
||||
self.dtype = torch.float32 if CPU else torch.float16
|
||||
self.repetition_penalty = repetition_penalty
|
||||
self.batch_size = 1
|
||||
self.stop_token = None
|
||||
@@ -112,7 +114,7 @@ class GPT2Generator:
|
||||
self.model_name = "pytorch-gpt2-xl-aid2-v5"
|
||||
self.model_dir = "models"
|
||||
self.checkpoint_path = os.path.join(self.model_dir, self.model_name)
|
||||
self.device = torch.device("cuda" if torch.cuda.is_available() and not settings.getboolean('cpu') else "cpu")
|
||||
self.device = torch.device("cuda" if not CPU else "cpu")
|
||||
logger.info("Using device={}, checkpoint={}".format(self.device, self.checkpoint_path))
|
||||
|
||||
# Load tokenizer and model
|
||||
|
||||
Reference in New Issue
Block a user