Skip to content

Commit

Permalink
Changed to use Macbook MPS device
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyOverby committed Sep 16, 2024
1 parent afc0918 commit c5748ed
Show file tree
Hide file tree
Showing 11 changed files with 1,564 additions and 14 deletions.
9 changes: 7 additions & 2 deletions kohya_gui/blip2_caption_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@


def load_model():
# Set the device to GPU if available, otherwise use CPU
device = "cuda" if torch.cuda.is_available() else "cpu"
# Set the device to GPU if available, MPS if available, otherwise use CPU
if torch.cuda.is_available():
device = torch.device("cuda")
elif torch.backends.mps.is_available():
device = torch.device("mps")
else:
device = torch.device("cpu")

# Initialize the BLIP2 processor
processor = Blip2Processor.from_pretrained("Salesforce/blip2-opt-2.7b")
Expand Down
1 change: 1 addition & 0 deletions kohya_gui/extract_lora_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def change_sdxl(sdxl):
choices=[
"cpu",
"cuda",
"mps"
],
value="cuda",
interactive=True,
Expand Down
1 change: 1 addition & 0 deletions kohya_gui/extract_lycoris_locon_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def list_save_to(path):
choices=[
"cpu",
"cuda",
"mps"
],
value="cuda",
interactive=True,
Expand Down
Loading

0 comments on commit c5748ed

Please sign in to comment.