Skip to content

Commit f7f30e3

Browse files
committed
Complete fix
1 parent d97a985 commit f7f30e3

1 file changed

Lines changed: 38 additions & 14 deletions

File tree

google_colab.ipynb

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,46 @@
7171
"outputs": [],
7272
"source": [
7373
"# \u2500\u2500 Install dependencies (Google Colab) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n",
74-
"# unsloth[colab-new] is designed for Colab; installs should be clean here.\n",
75-
"# If you see resolver warnings (e.g. fsspec/s3fs), they are safe to ignore.\n",
76-
"# --no-deps was skipping unsloth_zoo and breaking `import unsloth` / `import train`\n",
77-
"!pip install \"unsloth[colab-new]@git+https://github.com/unslothai/unsloth.git\" --quiet\n",
78-
"!pip install -U unsloth_zoo --quiet\n",
79-
"!pip install trl openenv transformers datasets accelerate matplotlib --quiet\n",
80-
"!pip install --upgrade bitsandbytes --quiet\n",
81-
"\n",
82-
"# Colab-specific: ensure we have the latest huggingface_hub\n",
83-
"!pip install --upgrade huggingface_hub --quiet\n",
84-
"\n",
85-
"# Suppress tokenizer parallelism warning\n",
74+
"# Use sys.executable so packages land in *this* kernel (plain !pip can target another Python).\n",
75+
"# Order: generic stack first, then Unsloth, then unsloth_zoo last (pip resolver won\u2019t strip it).\n",
76+
"\n",
77+
"import subprocess\n",
78+
"import sys\n",
79+
"\n",
80+
"\n",
81+
"def pip(*args: str) -> None:\n",
82+
" cmd = [sys.executable, \"-m\", \"pip\", *args]\n",
83+
" print(\" \", \" \".join(cmd))\n",
84+
" subprocess.check_call(cmd)\n",
85+
"\n",
86+
"\n",
87+
"pip(\"install\", \"-q\", \"trl\", \"openenv\", \"transformers\", \"datasets\", \"accelerate\", \"matplotlib\")\n",
88+
"pip(\"install\", \"-q\", \"--upgrade\", \"bitsandbytes\", \"huggingface_hub\")\n",
89+
"\n",
90+
"pip(\n",
91+
" \"install\",\n",
92+
" \"-q\",\n",
93+
" \"unsloth[colab-new]@git+https://github.com/unslothai/unsloth.git\",\n",
94+
")\n",
95+
"pip(\"install\", \"-q\", \"-U\", \"unsloth_zoo>=2026.4.8\")\n",
96+
"\n",
97+
"import importlib.metadata as _im\n",
98+
"\n",
99+
"try:\n",
100+
" _z = _im.version(\"unsloth_zoo\")\n",
101+
"except _im.PackageNotFoundError:\n",
102+
" print(\"\u26a0\ufe0f PyPI metadata missing; installing unsloth_zoo from GitHub\u2026\")\n",
103+
" pip(\"install\", \"-q\", \"-U\", \"git+https://github.com/unslothai/unsloth-zoo.git\")\n",
104+
" _z = _im.version(\"unsloth_zoo\")\n",
105+
"\n",
106+
"print(f\"\u2705 unsloth_zoo {_z} (importlib metadata OK)\")\n",
107+
"\n",
86108
"import os\n",
87-
"os.environ['TOKENIZERS_PARALLELISM'] = 'false'\n",
88109
"\n",
89-
"print('\u2705 Dependencies installed')\n"
110+
"os.environ[\"TOKENIZERS_PARALLELISM\"] = \"false\"\n",
111+
"\n",
112+
"print(\"\u2705 Dependencies installed.\")\n",
113+
"print(\" If a later cell still errors on unsloth, use: Runtime \u2192 Restart session, then re-run this cell.\")\n"
90114
]
91115
},
92116
{

0 commit comments

Comments
 (0)