|
71 | 71 | "outputs": [], |
72 | 72 | "source": [ |
73 | 73 | "# \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", |
86 | 108 | "import os\n", |
87 | | - "os.environ['TOKENIZERS_PARALLELISM'] = 'false'\n", |
88 | 109 | "\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" |
90 | 114 | ] |
91 | 115 | }, |
92 | 116 | { |
|
0 commit comments