Skip to content

Commit

Permalink
osx
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekkrthakur committed Oct 5, 2023
1 parent cea8675 commit 69eceb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/autotrain/cli/run_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,16 @@ def __init__(self, args):
break
print(f"Bot: {tgi.chat(prompt)}")

if not torch.cuda.is_available():
raise ValueError("No GPU found. Please install CUDA and try again.")
cuda_available = torch.cuda.is_available()
mps_available = torch.mps.is_available()

self.num_gpus = torch.cuda.device_count()
if not cuda_available and not mps_available:
raise ValueError("No GPU/MPS device found. LLM training requires an accelerator")

if cuda_available:
self.num_gpus = torch.cuda.device_count()
elif mps_available:
self.num_gpus = 1

def run(self):
from autotrain.backend import EndpointsRunner, SpaceRunner
Expand Down
1 change: 1 addition & 0 deletions src/autotrain/trainers/clm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def train(config):
trust_remote_code=True,
use_flash_attention_2=config.use_flash_attention_2,
)

else:
model = AutoModelForCausalLM.from_pretrained(
config.model,
Expand Down

0 comments on commit 69eceb5

Please sign in to comment.