Skip to content

Commit 81db13a

Browse files
committed
Use CPU torch for Linux release packaging
1 parent 0b3f3f6 commit 81db13a

2 files changed

Lines changed: 30 additions & 45 deletions

File tree

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,36 @@ jobs:
6464
shell: bash
6565
run: python scripts/real_backend_smoke.py --binary bitloops-embeddings
6666

67+
- name: Switch Linux packaging environment to CPU-only torch
68+
if: runner.os == 'Linux'
69+
shell: bash
70+
run: |
71+
TORCH_VERSION="$(python - <<'PY'
72+
import importlib.metadata
73+
print(importlib.metadata.version("torch"))
74+
PY
75+
)"
76+
77+
mapfile -t GPU_PACKAGES < <(python - <<'PY'
78+
import subprocess
79+
import sys
80+
81+
output = subprocess.check_output([sys.executable, "-m", "pip", "freeze"], text=True)
82+
for line in output.splitlines():
83+
name = line.split("==", 1)[0]
84+
lower = name.lower()
85+
if lower.startswith("nvidia-") or lower == "triton":
86+
print(name)
87+
PY
88+
)
89+
90+
if ((${#GPU_PACKAGES[@]} > 0)); then
91+
python -m pip uninstall -y "${GPU_PACKAGES[@]}"
92+
fi
93+
94+
python -m pip uninstall -y torch
95+
python -m pip install "torch==${TORCH_VERSION}" --index-url https://download.pytorch.org/whl/cpu
96+
6797
- name: Import Apple signing certificate
6898
if: runner.os == 'macOS'
6999
env:

scripts/package_release.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,13 @@
2929
"IPython",
3030
"jedi",
3131
"matplotlib",
32-
"nvidia",
3332
"notebook",
3433
"pandas",
3534
"tensorboard",
3635
"tensorflow",
37-
"triton",
3836
"torchvision",
3937
"torchaudio",
4038
]
41-
LINUX_GPU_LIBRARY_PREFIXES = (
42-
"libc10_cuda",
43-
"libcudart",
44-
"libcudnn",
45-
"libcufft",
46-
"libcupti",
47-
"libcublas",
48-
"libcublasLt",
49-
"libcurand",
50-
"libcusolver",
51-
"libcusparse",
52-
"libcusparseLt",
53-
"libnccl",
54-
"libnvJitLink",
55-
"libnvrtc",
56-
"libnvToolsExt",
57-
"libnpp",
58-
"libtorch_cuda",
59-
)
6039

6140

6241
def main() -> None:
@@ -122,8 +101,6 @@ def build_release(*, version: str, target: str, archive_dir: Path) -> tuple[Path
122101
)
123102

124103
shutil.copytree(pyinstaller_dist / PACKAGE_NAME, bundle_dir)
125-
if target.endswith("unknown-linux-gnu"):
126-
prune_linux_gpu_payload(bundle_dir)
127104
shutil.copy2(ROOT / "README.md", staging_dir / "README.md")
128105
shutil.copy2(ROOT / "LICENSE", staging_dir / "LICENSE")
129106

@@ -232,27 +209,5 @@ def write_github_outputs(output_path: Path, outputs: dict[str, str]) -> None:
232209
file_handle.write(f"{key}={value}\n")
233210

234211

235-
def prune_linux_gpu_payload(bundle_dir: Path) -> None:
236-
removable_directories = []
237-
for pattern in ("**/nvidia", "**/triton"):
238-
removable_directories.extend(
239-
path for path in bundle_dir.glob(pattern) if path.is_dir()
240-
)
241-
242-
for path in sorted(removable_directories, reverse=True):
243-
shutil.rmtree(path, ignore_errors=True)
244-
245-
for path in bundle_dir.rglob("*"):
246-
if not path.is_file():
247-
continue
248-
249-
name = path.name
250-
if name.endswith(".pyc"):
251-
continue
252-
253-
if name.startswith(LINUX_GPU_LIBRARY_PREFIXES):
254-
path.unlink(missing_ok=True)
255-
256-
257212
if __name__ == "__main__":
258213
main()

0 commit comments

Comments
 (0)