DipeshChaudhary commited on
Commit
0d58086
1 Parent(s): 54e6955

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -1,3 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from unsloth import FastLanguageModel
2
 
3
  import torch
 
1
+ try: import torch
2
+ except: raise ImportError("Install torch via `pip install torch`")
3
+ from packaging.version import Version as V
4
+ v = V(torch.__version__)
5
+ cuda = str(torch.version.cuda)
6
+ is_ampere = torch.cuda.get_device_capability()[0] >= 8
7
+ if cuda != "12.1" and cuda != "11.8": raise RuntimeError(f"CUDA = {cuda} not supported!")
8
+ if v <= V('2.1.0'): raise RuntimeError(f"Torch = {v} too old!")
9
+ elif v <= V('2.1.1'): x = 'cu{}{}-torch211'
10
+ elif v <= V('2.1.2'): x = 'cu{}{}-torch212'
11
+ elif v < V('2.3.0'): x = 'cu{}{}-torch220'
12
+ elif v < V('2.4.0'): x = 'cu{}{}-torch230'
13
+ elif v < V('2.5.0'): x = 'cu{}{}-torch240'
14
+ else: raise RuntimeError(f"Torch = {v} too new!")
15
+ x = x.format(cuda.replace(".", ""), "-ampere" if is_ampere else "")
16
+ print(f'pip install --upgrade pip && pip install "unsloth[{x}] @ git+https://github.com/unslothai/unsloth.git"')
17
+
18
+ nvcc
19
+ python -m xformers.info
20
+ python -m bitsandbytes
21
  from unsloth import FastLanguageModel
22
 
23
  import torch