hack further
Browse files- app.py +9 -0
- scratchpad.ipynb +6 -5
app.py
CHANGED
|
@@ -1,15 +1,24 @@
|
|
| 1 |
import sys
|
| 2 |
import torch
|
|
|
|
|
|
|
| 3 |
# Hack unsloth to work without GPU
|
|
|
|
|
|
|
| 4 |
def fake_is_available():
|
| 5 |
return True
|
| 6 |
def fake_device_capability():
|
| 7 |
return (8, 0)
|
| 8 |
def fake_current_device():
|
| 9 |
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
sys.modules["torch"].cuda.is_available = fake_is_available
|
| 11 |
sys.modules["torch"].cuda.get_device_capability = fake_device_capability
|
| 12 |
sys.modules["torch"].cuda.current_device = fake_current_device
|
|
|
|
| 13 |
|
| 14 |
import streamlit as st
|
| 15 |
from unsloth.chat_templates import get_chat_template, CHAT_TEMPLATES
|
|
|
|
| 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 |
+
class FakeDeviceProperties:
|
| 15 |
+
major = 7 # Mimic a compatible GPU
|
| 16 |
+
minor = 5
|
| 17 |
+
|
| 18 |
sys.modules["torch"].cuda.is_available = fake_is_available
|
| 19 |
sys.modules["torch"].cuda.get_device_capability = fake_device_capability
|
| 20 |
sys.modules["torch"].cuda.current_device = fake_current_device
|
| 21 |
+
sys.modules["torch._dynamo.device_interface"].Worker.get_device_properties = lambda: FakeDeviceProperties()
|
| 22 |
|
| 23 |
import streamlit as st
|
| 24 |
from unsloth.chat_templates import get_chat_template, CHAT_TEMPLATES
|
scratchpad.ipynb
CHANGED
|
@@ -262,7 +262,7 @@
|
|
| 262 |
},
|
| 263 |
{
|
| 264 |
"cell_type": "code",
|
| 265 |
-
"execution_count":
|
| 266 |
"metadata": {},
|
| 267 |
"outputs": [
|
| 268 |
{
|
|
@@ -271,7 +271,7 @@
|
|
| 271 |
"False"
|
| 272 |
]
|
| 273 |
},
|
| 274 |
-
"execution_count":
|
| 275 |
"metadata": {},
|
| 276 |
"output_type": "execute_result"
|
| 277 |
}
|
|
@@ -279,10 +279,11 @@
|
|
| 279 |
"source": [
|
| 280 |
"import os\n",
|
| 281 |
"os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"\"\n",
|
| 282 |
-
"\n",
|
| 283 |
"import torch\n",
|
| 284 |
-
"
|
| 285 |
-
"
|
|
|
|
| 286 |
]
|
| 287 |
},
|
| 288 |
{
|
|
|
|
| 262 |
},
|
| 263 |
{
|
| 264 |
"cell_type": "code",
|
| 265 |
+
"execution_count": 5,
|
| 266 |
"metadata": {},
|
| 267 |
"outputs": [
|
| 268 |
{
|
|
|
|
| 271 |
"False"
|
| 272 |
]
|
| 273 |
},
|
| 274 |
+
"execution_count": 5,
|
| 275 |
"metadata": {},
|
| 276 |
"output_type": "execute_result"
|
| 277 |
}
|
|
|
|
| 279 |
"source": [
|
| 280 |
"import os\n",
|
| 281 |
"os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"\"\n",
|
| 282 |
+
"# import unsloth\n",
|
| 283 |
"import torch\n",
|
| 284 |
+
"import torch.utils._triton\n",
|
| 285 |
+
"import sys\n",
|
| 286 |
+
"sys.modules[\"torch.utils._triton\"].has_triton()"
|
| 287 |
]
|
| 288 |
},
|
| 289 |
{
|