Skip to content

Commit

Permalink
Avoid peft import in global scope, loads bitsandbytes and that loads …
Browse files Browse the repository at this point in the history
…cuda and corrupts parent
  • Loading branch information
pseudotensor committed Jun 9, 2023
1 parent 897a0a8 commit 762cdcd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 2 additions & 1 deletion generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import fire
import torch
from peft import PeftModel
from transformers import GenerationConfig, AutoModel, TextIteratorStreamer
from accelerate import init_empty_weights, infer_auto_device_map

Expand Down Expand Up @@ -710,6 +709,7 @@ def get_model(
base_model,
**model_kwargs
)
from peft import PeftModel # loads cuda, so avoid in global scope
model = PeftModel.from_pretrained(
model,
lora_weights,
Expand All @@ -727,6 +727,7 @@ def get_model(
base_model,
**model_kwargs
)
from peft import PeftModel # loads cuda, so avoid in global scope
model = PeftModel.from_pretrained(
model,
lora_weights,
Expand Down
1 change: 0 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import traceback
import zipfile
from datetime import datetime
from enum import Enum

import filelock
import requests, uuid
Expand Down

0 comments on commit 762cdcd

Please sign in to comment.