Zeel commited on
Commit
6cb37fc
·
1 Parent(s): 85ac5ad

fix tested on colab CPU

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -1,31 +1,30 @@
1
  import sys
2
  import torch
3
- import torch._dynamo.device_interface
 
4
 
5
  # Hack unsloth to work without GPU
6
  def fake_triton_check():
7
  return False # Prevents `bitsandbytes` from requiring GPU
8
  def fake_is_available():
9
  return True
10
- def fake_device_capability():
11
  return (8, 0)
12
  def fake_current_device():
13
  return 0
14
-
15
- class Worker:
16
- def __init__(self):
17
- pass
18
-
19
- def get_device_properties(self):
20
- return FakeDeviceProperties()
21
- class FakeDeviceProperties:
22
- major = 7 # Mimic a compatible GPU
23
- minor = 5
24
 
25
  sys.modules["torch"].cuda.is_available = fake_is_available
26
  sys.modules["torch"].cuda.get_device_capability = fake_device_capability
27
  sys.modules["torch"].cuda.current_device = fake_current_device
28
- sys.modules["torch._dynamo.device_interface"].Worker = Worker()
 
 
29
 
30
  import streamlit as st
31
  from unsloth.chat_templates import get_chat_template, CHAT_TEMPLATES
 
1
  import sys
2
  import torch
3
+ # import torch._dynamo.device_interface
4
+ import torch.utils._triton
5
 
6
  # Hack unsloth to work without GPU
7
  def fake_triton_check():
8
  return False # Prevents `bitsandbytes` from requiring GPU
9
  def fake_is_available():
10
  return True
11
+ def fake_device_capability(*args, **kwargs):
12
  return (8, 0)
13
  def fake_current_device():
14
  return 0
15
+ def fake_device_count():
16
+ return 1
17
+ def has_triton():
18
+ return False
19
+ def get_fake_stream(*args, **kwargs):
20
+ return 0
 
 
 
 
21
 
22
  sys.modules["torch"].cuda.is_available = fake_is_available
23
  sys.modules["torch"].cuda.get_device_capability = fake_device_capability
24
  sys.modules["torch"].cuda.current_device = fake_current_device
25
+ sys.modules["torch"].cuda.device_count = fake_device_count
26
+ sys.modules["torch.utils._triton"].has_triton = has_triton
27
+ sys.modules["torch._C"]._cuda_getCurrentRawStream = get_fake_stream
28
 
29
  import streamlit as st
30
  from unsloth.chat_templates import get_chat_template, CHAT_TEMPLATES