fix: use unsloth[huggingfacenotorch] instead of --no-deps in no-torch mode (#4647)

The previous --no-deps approach skipped ALL dependencies, not just
torch. This left safetensors, transformers, datasets, accelerate, etc.
missing, causing PackageNotFoundError at runtime.

Fix: in no-torch mode, install unsloth[huggingfacenotorch] (which pulls
all runtime deps except torch), then install unsloth-zoo with --no-deps
(since zoo's published metadata still declares torch as a hard dep).
This gives a working no-torch environment with all non-torch packages.

Applied to all three installer files: install.sh, install.ps1, and
studio/install_python_stack.py.
This commit is contained in:
Daniel Han 2026-03-27 02:38:11 -07:00 committed by GitHub
parent 2ffc8d2cea
commit 3c9f0ed149
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 57 additions and 22 deletions

View file

@ -620,8 +620,14 @@ shell.Run cmd, 0, False
# Migrated env: force-reinstall unsloth+unsloth-zoo to ensure clean state
# in the new venv location, while preserving existing torch/CUDA
Write-Host "==> Upgrading unsloth in migrated environment..."
$noDepsArg = if ($SkipTorch) { "--no-deps" } else { $null }
uv pip install --python $VenvPython $noDepsArg --reinstall-package unsloth --reinstall-package unsloth-zoo "unsloth>=2026.3.14" unsloth-zoo
if ($SkipTorch) {
# No-torch: install runtime deps via [huggingfacenotorch] extras,
# then unsloth-zoo with --no-deps to avoid pulling torch.
uv pip install --python $VenvPython --reinstall-package unsloth "unsloth[huggingfacenotorch]>=2026.3.14"
uv pip install --python $VenvPython --no-deps --reinstall-package unsloth-zoo unsloth-zoo
} else {
uv pip install --python $VenvPython --reinstall-package unsloth --reinstall-package unsloth-zoo "unsloth>=2026.3.14" unsloth-zoo
}
if ($StudioLocalInstall) {
Write-Host "==> Overlaying local repo (editable)..."
uv pip install --python $VenvPython -e $RepoRoot --no-deps
@ -639,13 +645,21 @@ shell.Run cmd, 0, False
}
Write-Host "==> Installing unsloth (this may take a few minutes)..."
$noDepsArg = if ($SkipTorch) { "--no-deps" } else { $null }
if ($StudioLocalInstall) {
uv pip install --python $VenvPython $noDepsArg --upgrade-package unsloth "unsloth>=2026.3.14" unsloth-zoo
if ($SkipTorch) {
# No-torch: install runtime deps via [huggingfacenotorch] extras,
# then unsloth-zoo with --no-deps to avoid pulling torch.
uv pip install --python $VenvPython --upgrade-package unsloth "unsloth[huggingfacenotorch]>=2026.3.14"
uv pip install --python $VenvPython --no-deps --upgrade-package unsloth-zoo unsloth-zoo
if ($StudioLocalInstall) {
Write-Host "==> Overlaying local repo (editable)..."
uv pip install --python $VenvPython -e $RepoRoot --no-deps
}
} elseif ($StudioLocalInstall) {
uv pip install --python $VenvPython --upgrade-package unsloth "unsloth>=2026.3.14" unsloth-zoo
Write-Host "==> Overlaying local repo (editable)..."
uv pip install --python $VenvPython -e $RepoRoot --no-deps
} else {
uv pip install --python $VenvPython $noDepsArg --upgrade-package unsloth "$PackageName"
uv pip install --python $VenvPython --upgrade-package unsloth "$PackageName"
}
} else {
# Fallback: GPU detection failed to produce a URL -- let uv resolve torch

View file

@ -863,13 +863,19 @@ if [ "$_MIGRATED" = true ]; then
# Migrated env: force-reinstall unsloth+unsloth-zoo to ensure clean state
# in the new venv location, while preserving existing torch/CUDA
echo "==> Upgrading unsloth in migrated environment..."
_no_deps_arg=""
if [ "$SKIP_TORCH" = true ]; then
_no_deps_arg="--no-deps"
# No-torch: install runtime deps via [huggingfacenotorch] extras,
# then unsloth-zoo with --no-deps to avoid pulling torch.
uv pip install --python "$_VENV_PY" \
--reinstall-package unsloth \
"unsloth[huggingfacenotorch]>=2026.3.14"
uv pip install --python "$_VENV_PY" --no-deps \
--reinstall-package unsloth-zoo unsloth-zoo
else
uv pip install --python "$_VENV_PY" \
--reinstall-package unsloth --reinstall-package unsloth-zoo \
"unsloth>=2026.3.14" unsloth-zoo
fi
uv pip install --python "$_VENV_PY" $_no_deps_arg \
--reinstall-package unsloth --reinstall-package unsloth-zoo \
"unsloth>=2026.3.14" unsloth-zoo
if [ "$STUDIO_LOCAL_INSTALL" = true ]; then
echo "==> Overlaying local repo (editable)..."
uv pip install --python "$_VENV_PY" -e "$_REPO_ROOT" --no-deps
@ -885,17 +891,25 @@ elif [ -n "$TORCH_INDEX_URL" ]; then
fi
# Fresh: Step 2 - install unsloth, preserving pre-installed torch
echo "==> Installing unsloth (this may take a few minutes)..."
_no_deps_arg=""
if [ "$SKIP_TORCH" = true ]; then
_no_deps_arg="--no-deps"
fi
if [ "$STUDIO_LOCAL_INSTALL" = true ]; then
uv pip install --python "$_VENV_PY" $_no_deps_arg \
# No-torch: install runtime deps via [huggingfacenotorch] extras,
# then unsloth-zoo with --no-deps to avoid pulling torch.
uv pip install --python "$_VENV_PY" \
--upgrade-package unsloth \
"unsloth[huggingfacenotorch]>=2026.3.14"
uv pip install --python "$_VENV_PY" --no-deps \
--upgrade-package unsloth-zoo unsloth-zoo
if [ "$STUDIO_LOCAL_INSTALL" = true ]; then
echo "==> Overlaying local repo (editable)..."
uv pip install --python "$_VENV_PY" -e "$_REPO_ROOT" --no-deps
fi
elif [ "$STUDIO_LOCAL_INSTALL" = true ]; then
uv pip install --python "$_VENV_PY" \
--upgrade-package unsloth "unsloth>=2026.3.14" unsloth-zoo
echo "==> Overlaying local repo (editable)..."
uv pip install --python "$_VENV_PY" -e "$_REPO_ROOT" --no-deps
else
uv pip install --python "$_VENV_PY" $_no_deps_arg \
uv pip install --python "$_VENV_PY" \
--upgrade-package unsloth "$PACKAGE_NAME"
fi
else

View file

@ -440,17 +440,24 @@ def install_python_stack() -> int:
if skip_base:
print(_green(f"{package_name} already installed — skipping base packages"))
elif NO_TORCH:
# No-torch mode: install unsloth + unsloth-zoo without torch deps
# No-torch mode: install runtime deps via [huggingfacenotorch] extras
# (safetensors, transformers, datasets, etc.), then unsloth-zoo with
# --no-deps to avoid pulling torch.
_progress("base packages (no torch)")
pip_install(
"Updating base packages (no-torch mode)",
"Installing unsloth runtime deps (no-torch mode)",
"--no-cache-dir",
"--upgrade-package",
"unsloth",
"unsloth[huggingfacenotorch]>=2026.3.14",
)
pip_install(
"Installing unsloth-zoo (no-torch mode)",
"--no-cache-dir",
"--no-deps",
"--upgrade-package",
"unsloth",
"--upgrade-package",
"unsloth-zoo",
req = REQ_ROOT / "base.txt",
"unsloth-zoo",
)
if local_repo:
pip_install(