Some checks failed
Windows / verify (push) Has been cancelled
- preload_on_start(기본값)에서 모델 로드가 GPU 오류를 내면 ERROR 로 끝나던 것을, CPU 로 바꿔 다시 올리게 했다. - cuBLAS 를 받는 중에 정지하면 받기는 계속되고, 끝난 뒤 캡처가 켜져 상태가 다시 RUNNING 이 되던 것을 고쳤다. 시작 작업마다 전용 정지 이벤트를 넘기고, 받기는 그 이벤트를 보고 멈추며, 시작 작업은 정지된 뒤에는 캡처·상태를 건드리지 않는다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.6 KiB
Python
77 lines
2.6 KiB
Python
"""cuBLAS 내려받기·꺼내기 (Windows exe 에서 GPU 로 받아 적는 데 필요)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import zipfile
|
|
|
|
import pytest
|
|
|
|
from livesub.models import cuda_runtime
|
|
|
|
|
|
def _fake_wheel(tmp_path):
|
|
wheel = tmp_path / "fake.whl"
|
|
with zipfile.ZipFile(wheel, "w") as zf:
|
|
zf.writestr("nvidia/cublas/bin/cublasLt64_12.dll", b"LT" * 1000)
|
|
zf.writestr("nvidia/cublas/bin/cublas64_12.dll", b"BLAS" * 1000)
|
|
zf.writestr("nvidia/cublas/bin/nvblas64_12.dll", b"unused")
|
|
zf.writestr("nvidia/cublas/include/cublas.h", b"header")
|
|
data = wheel.read_bytes()
|
|
return wheel.as_uri(), hashlib.sha256(data).hexdigest(), len(data)
|
|
|
|
|
|
def test_download_extracts_only_the_two_dlls(tmp_path):
|
|
url, sha, size = _fake_wheel(tmp_path)
|
|
target = tmp_path / "runtime"
|
|
seen = []
|
|
|
|
cuda_runtime.download(target, lambda msg, pct: seen.append(pct), url, sha, size)
|
|
|
|
assert cuda_runtime.installed(target)
|
|
assert (target / "cublasLt64_12.dll").read_bytes() == b"LT" * 1000
|
|
assert (target / "cublas64_12.dll").read_bytes() == b"BLAS" * 1000
|
|
assert sorted(p.name for p in target.iterdir()) == ["cublas64_12.dll", "cublasLt64_12.dll"]
|
|
assert seen and seen[-1] == 1.0
|
|
|
|
|
|
def test_corrupted_download_leaves_nothing_behind(tmp_path):
|
|
url, _sha, size = _fake_wheel(tmp_path)
|
|
target = tmp_path / "runtime"
|
|
|
|
with pytest.raises(RuntimeError, match="손상"):
|
|
cuda_runtime.download(target, None, url, "0" * 64, size)
|
|
|
|
assert not cuda_runtime.installed(target)
|
|
assert list(target.iterdir()) == []
|
|
|
|
|
|
def test_pinned_wheel_is_the_blackwell_capable_cublas():
|
|
# RTX 50 계열(sm_120)은 cuBLAS 12.8 부터 지원한다.
|
|
major, minor = (int(x) for x in cuda_runtime.WHEEL_VERSION.split(".")[:2])
|
|
assert (major, minor) >= (12, 8)
|
|
assert cuda_runtime.WHEEL_VERSION in cuda_runtime.WHEEL_URL
|
|
assert cuda_runtime.WHEEL_URL.endswith("win_amd64.whl")
|
|
|
|
|
|
def test_ensure_is_a_no_op_off_windows_or_on_cpu(monkeypatch):
|
|
monkeypatch.setattr(cuda_runtime.sys, "platform", "linux")
|
|
assert cuda_runtime.ensure(device="cuda") is False
|
|
monkeypatch.setattr(cuda_runtime.sys, "platform", "win32")
|
|
assert cuda_runtime.ensure(device="cpu") is False
|
|
|
|
|
|
def test_download_stops_when_cancelled(tmp_path):
|
|
import threading
|
|
|
|
url, sha, size = _fake_wheel(tmp_path)
|
|
target = tmp_path / "runtime"
|
|
cancel = threading.Event()
|
|
cancel.set()
|
|
|
|
with pytest.raises(cuda_runtime.DownloadCancelled):
|
|
cuda_runtime.download(target, None, url, sha, size, cancel=cancel)
|
|
|
|
assert not cuda_runtime.installed(target)
|
|
assert list(target.iterdir()) == []
|