setup: install the CUDA Toolkit on Debian 12/13 too, not Ubuntu only
The CUDA apt repo keyring and cuda-toolkit-13-x packages exist for debian12/debian13 as well as ubuntu2204/ubuntu2404, so derive the repo name from /etc/os-release instead of hardcoding ubuntu. Debian 13's repo carries no cuda-toolkit-13-0, so try 13-0..13-5 in order (Ubuntu still gets 13-0 first, same as before). Checked with tools/test_setup_cuda_repo.py (4 tests, no GPU or network needed): repo mapping for ubuntu/debian/other and the minor-version fallback.
This commit is contained in:
1 parent
d8a49433e3
commit
fb7ee72471
5 files changed
+104
-8
No files matched your search
+1
-1
@@ -50,7 +50,7 @@ Requirements (details: [INSTALL.md](INSTALL.md#what-you-need)):
|
||||
driver. If the driver is missing or too old, tell the user to update it (NVIDIA App / nvidia.com/drivers, or AMD
|
||||
Software) and restart; do not install drivers yourself unless they ask.
|
||||
- **RAM:** 32 GB or more (see step 3). **Disk:** ~80 GB free, ideally on an NVMe SSD. **CPU:** x86-64 with AVX2. Without AVX2 (Xeon E5 v1/v2 and older) setup still installs, as an experimental and slow build it compiles on the PC (10-20 minutes): tell the user that before starting ([INSTALL.md](INSTALL.md#older-cpus-experimental)).
|
||||
- **OS:** Windows 10/11 or Linux (Ubuntu 22.04/24.04 are fully automatic).
|
||||
- **OS:** Windows 10/11 or Linux (Ubuntu 22.04/24.04 and Debian 12/13 are fully automatic; Debian 13 gets the oldest CUDA 13 its NVIDIA repo has, currently 13.1).
|
||||
|
||||
If the PC does not meet them, say which part is missing and stop.
|
||||
|
||||
|
||||
+1
-1
@@ -418,7 +418,7 @@ Everything else is installed for you the first time.
|
||||
| RAM | **64 GB** recommended (see the table above). |
|
||||
| CPU | x86-64 with AVX2 (any Intel/AMD desktop CPU from the last ~8 years). AVX-512 (Ryzen 7000/9000) is a bit faster. Older CPUs without AVX2 are experimental and slow: [Older CPUs](INSTALL.md#older-cpus-experimental). |
|
||||
| Disk | ~70-80 GB free for the model, ~6 GB for the MTP layer (+1 GB with images). **Q2_0 on an AVX-512 CPU** also writes a one-time ~40 GB pack for the fast CPU kernel (34 GB of experts in its layout, plus the dense weights). An NVMe SSD is strongly recommended. |
|
||||
| OS | Windows 10/11, or Linux (Ubuntu 22.04/24.04 get everything installed automatically). |
|
||||
| OS | Windows 10/11, or Linux (Ubuntu 22.04/24.04 and Debian 12/13 get everything installed automatically). |
|
||||
|
||||
What the first start installs: in this folder `.venv/`, `engine/` and `third_party/`; the model files (`models/`,
|
||||
`packs/`, `mtp/`, 70-120 GB) in **`Strata-data` next to this folder**, so a new copy of Strata (an update unzipped
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ this for you with [AI_SETUP.md](AI_SETUP.md).
|
||||
| **RAM** | Enough for the size you pick ([which model](MODELS.md#pick-by-ram)); **64 GB** runs every size. A big GPU makes up for less RAM - the [low-RAM mode](MODELS.md#a-big-graphics-card-and-little-ram). |
|
||||
| **CPU** | x86-64 with AVX2 (any Intel/AMD desktop CPU from the last ~8 years). AVX-512 (Ryzen 7000/9000) is a bit faster. Older CPUs without AVX2 are experimental and slow: [Older CPUs](#older-cpus-experimental). |
|
||||
| **Disk** | ~70-80 GB free for the model, ~6 GB for the MTP layer (+1 GB with images). **Q2_0 on an AVX-512 CPU** also writes a one-time ~40 GB copy of its experts for the fast CPU kernel. On Linux with an AMD card, ROCm takes ~10 GB more when setup installs it. An NVMe SSD is strongly recommended: it makes the first start much faster. |
|
||||
| **OS** | Windows 10/11, or Linux (Ubuntu 22.04/24.04 get everything installed automatically). |
|
||||
| **OS** | Windows 10/11, or Linux (Ubuntu 22.04/24.04 and Debian 12/13 get everything installed automatically). |
|
||||
| **Driver** | **NVIDIA:** a current driver, version 580 or newer ([nvidia.com/drivers](https://www.nvidia.com/drivers) or the NVIDIA App). **AMD:** on Linux the kernel's amdgpu driver (no ROCm install needed); on Windows a current AMD Software: Adrenalin Edition driver ([amd.com/support](https://www.amd.com/en/support)). |
|
||||
|
||||
The driver is the only thing you install yourself. Everything else - Python, the engine, the model - is set up for
|
||||
|
||||
@@ -3212,6 +3212,14 @@ def sm120_nvcc(nvcc, cuda_v, archs):
|
||||
return nvcc, cuda_v
|
||||
|
||||
|
||||
def cuda_apt_repo(osr):
|
||||
"""The NVIDIA apt repo for this distribution ("ubuntu2404", "debian13") from /etc/os-release, or None when it is
|
||||
not one setup adds the CUDA keyring for. Both families publish cuda-keyring and CUDA 13.x."""
|
||||
ver = osr.get("VERSION_ID", "").strip('"').replace(".", "")
|
||||
repo = {"ubuntu": "ubuntu", "debian": "debian"}.get(osr.get("ID", ""), "") + ver
|
||||
return repo if repo in ("ubuntu2204", "ubuntu2404", "debian12", "debian13") else None
|
||||
|
||||
|
||||
def install_build_tools(gpu, yes):
|
||||
"""The compiler and the CUDA toolkit, installed for the user (asks once). Returns (nvcc, vcvars)."""
|
||||
archs = [int(x) for x in gpu.get("archs", [gpu["arch"]])]
|
||||
@@ -3270,16 +3278,19 @@ def install_build_tools(gpu, yes):
|
||||
run(["sudo", "apt-get", "install", "-y", "build-essential"])
|
||||
if nvcc is None or cuda_v < need_cuda:
|
||||
osr = dict(line.split("=", 1) for line in open("/etc/os-release").read().splitlines() if "=" in line)
|
||||
ver = osr.get("VERSION_ID", "").strip('"').replace(".", "")
|
||||
if osr.get("ID") != "ubuntu" or ver not in ("2204", "2404"):
|
||||
fail("the CUDA Toolkit can be installed automatically on Ubuntu 22.04 / 24.04 only",
|
||||
repo = cuda_apt_repo(osr)
|
||||
if repo is None:
|
||||
fail("the CUDA Toolkit can be installed automatically on Ubuntu 22.04 / 24.04 and Debian 12 / 13 only",
|
||||
"install it from https://developer.nvidia.com/cuda-downloads and run it again")
|
||||
deb = Path("/tmp/cuda-keyring.deb")
|
||||
download(f"https://developer.download.nvidia.com/compute/cuda/repos/ubuntu{ver}/x86_64/cuda-keyring_1.1-1_all.deb",
|
||||
download(f"https://developer.download.nvidia.com/compute/cuda/repos/{repo}/x86_64/cuda-keyring_1.1-1_all.deb",
|
||||
deb, "CUDA repository key")
|
||||
run(["sudo", "dpkg", "-i", str(deb)])
|
||||
run(["sudo", "apt-get", "update"])
|
||||
run(["sudo", "apt-get", "install", "-y", "cuda-toolkit-13-0"])
|
||||
# Debian 13's CUDA repo carries no 13.0 package: take the oldest 13.x minor it has (Ubuntu still gets 13.0).
|
||||
for minor in range(5):
|
||||
if run(["sudo", "apt-get", "install", "-y", f"cuda-toolkit-13-{minor}"], check=False).returncode == 0:
|
||||
break
|
||||
nvcc, cuda_v = find_nvcc(below=(13, 0)) if old else find_nvcc()
|
||||
if (WIN and find_vcvars(cuda_v) is None) or (not WIN and shutil.which("g++") is None):
|
||||
fail("the C++ build tools did not install", "install them by hand (README.md) and run it again")
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
"""The CUDA Toolkit apt install: which distros it covers and which 13.x package it picks
|
||||
(Debian 13's repo has no cuda-toolkit-13-0). No GPU, downloads or installs are used.
|
||||
|
||||
python -m unittest tools.test_setup_cuda_repo
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import sys
|
||||
import types
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
import setup # noqa: E402
|
||||
|
||||
|
||||
class AptRepo(unittest.TestCase):
|
||||
def test_known_and_unknown_distros(self):
|
||||
for osr, want in ({"ID": "ubuntu", "VERSION_ID": '"22.04"'}, "ubuntu2204"), \
|
||||
({"ID": "ubuntu", "VERSION_ID": '"24.04"'}, "ubuntu2404"), \
|
||||
({"ID": "debian", "VERSION_ID": '"12"'}, "debian12"), \
|
||||
({"ID": "debian", "VERSION_ID": '"13"'}, "debian13"), \
|
||||
({"ID": "debian", "VERSION_ID": '"11"'}, None), \
|
||||
({"ID": "fedora", "VERSION_ID": '"42"'}, None), \
|
||||
({}, None):
|
||||
with self.subTest(osr=osr):
|
||||
self.assertEqual(setup.cuda_apt_repo(osr), want)
|
||||
|
||||
def test_debian_13_falls_back_to_the_oldest_13_x_it_has(self):
|
||||
# the repo has no 13-0: apt fails on it, setup must try 13-1 and stop there (not install 13-2+)
|
||||
installed = []
|
||||
|
||||
def fake_run(cmd, **kw):
|
||||
installed.append(cmd[-1])
|
||||
return types.SimpleNamespace(returncode=100 if cmd[-1] == "cuda-toolkit-13-0" else 0)
|
||||
|
||||
with mock.patch.object(setup, "WIN", False), \
|
||||
mock.patch.object(setup, "find_nvcc", side_effect=[(None, (0, 0)), ("/usr/local/cuda-13.1/bin/nvcc", (13, 1))]), \
|
||||
mock.patch.object(setup.shutil, "which", lambda n: "/usr/bin/" + n), \
|
||||
mock.patch("builtins.open", mock.mock_open(read_data='ID=debian\nVERSION_ID="13"\n')), \
|
||||
mock.patch.object(setup, "download") as download, \
|
||||
mock.patch.object(setup, "run", side_effect=fake_run), \
|
||||
contextlib.redirect_stdout(io.StringIO()):
|
||||
nvcc, _ = setup.install_build_tools({"arch": "86", "archs": [86]}, True)
|
||||
self.assertEqual(nvcc, "/usr/local/cuda-13.1/bin/nvcc")
|
||||
self.assertIn("repos/debian13/x86_64/cuda-keyring_1.1-1_all.deb", download.call_args[0][0])
|
||||
self.assertEqual(installed[-2:], ["cuda-toolkit-13-0", "cuda-toolkit-13-1"])
|
||||
|
||||
def test_ubuntu_still_installs_exactly_13_0(self):
|
||||
installed = []
|
||||
|
||||
def fake_run(cmd, **kw):
|
||||
if cmd[0:2] == ["sudo", "apt-get"] and cmd[2] == "install":
|
||||
installed.append(cmd[-1])
|
||||
return types.SimpleNamespace(returncode=0)
|
||||
|
||||
with mock.patch.object(setup, "WIN", False), \
|
||||
mock.patch.object(setup, "find_nvcc", side_effect=[(None, (0, 0)), ("/usr/local/cuda-13.0/bin/nvcc", (13, 0))]), \
|
||||
mock.patch.object(setup.shutil, "which", lambda n: "/usr/bin/" + n), \
|
||||
mock.patch("builtins.open", mock.mock_open(read_data='ID=ubuntu\nVERSION_ID="24.04"\n')), \
|
||||
mock.patch.object(setup, "download"), \
|
||||
mock.patch.object(setup, "run", side_effect=fake_run), \
|
||||
contextlib.redirect_stdout(io.StringIO()):
|
||||
setup.install_build_tools({"arch": "86", "archs": [86]}, True)
|
||||
self.assertEqual(installed, ["cuda-toolkit-13-0"])
|
||||
|
||||
def test_unknown_distro_stops_with_guidance(self):
|
||||
out = io.StringIO()
|
||||
with mock.patch.object(setup, "WIN", False), \
|
||||
mock.patch.object(setup, "find_nvcc", return_value=(None, (0, 0))), \
|
||||
mock.patch.object(setup.shutil, "which", lambda n: "/usr/bin/" + n), \
|
||||
mock.patch("builtins.open", mock.mock_open(read_data='ID=fedora\nVERSION_ID="42"\n')), \
|
||||
mock.patch.object(setup, "download", side_effect=AssertionError("download started")), \
|
||||
contextlib.redirect_stdout(out):
|
||||
with self.assertRaises(SystemExit):
|
||||
setup.install_build_tools({"arch": "86", "archs": [86]}, True)
|
||||
self.assertIn("Debian 12 / 13", out.getvalue())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user