mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-12 03:16:19 +00:00
Say when the processor build landed instead of the Vulkan one
The install falls back to upstream's CPU archive whenever Dikte's own release, the file in it, or its reviewed digest is not there, and until the package is published by hand that is every download. It happened without a word: the window said "Downloaded, version v1.9.3." either way, and a graphics card sitting idle looks exactly like one being used. The install record now carries which of the two builds landed, written only where both were on offer, and the settings window says so on the line that already reports the version.
This commit is contained in:
+36
-6
@@ -284,6 +284,17 @@ def _wanted_assets(program):
|
||||
return (f"bin-ubuntu-{arch}.tar.gz",)
|
||||
|
||||
|
||||
def _managed_whisper(program, tag=""):
|
||||
"""Whether this machine is one Dikte publishes its own whisper-server for.
|
||||
|
||||
Linux x86_64 with a Vulkan loader on it, and no version asked for by hand:
|
||||
a pinned version is upstream's to answer.
|
||||
"""
|
||||
return (not tag and program is WHISPER and sys.platform == "linux"
|
||||
and platform.machine().lower() in ("x86_64", "amd64")
|
||||
and _has_vulkan())
|
||||
|
||||
|
||||
def _install_record(program):
|
||||
return BIN_DIR / program.name / "installed.json"
|
||||
|
||||
@@ -307,6 +318,21 @@ def installed_version(program):
|
||||
return _read_record(program).get("tag") or ""
|
||||
|
||||
|
||||
def vulkan_missing(program):
|
||||
"""Whether what Dikte installed is the processor build on a machine the
|
||||
Vulkan one was fetched for.
|
||||
|
||||
The Vulkan whisper-server is a release of Dikte's own, published by hand
|
||||
once the reviewed archive is built, and the install falls back to the
|
||||
upstream processor build whenever that release, the file in it, or its
|
||||
reviewed digest is not there. Nothing is wrong with the fallback except
|
||||
that it is invisible: a graphics card sitting idle looks exactly like a
|
||||
graphics card being used.
|
||||
"""
|
||||
return (bool(installed_program(program))
|
||||
and _read_record(program).get("backend") == "processor")
|
||||
|
||||
|
||||
def program_path(program, custom=""):
|
||||
"""Which copy of the program to run, or "" when there is none.
|
||||
|
||||
@@ -382,10 +408,8 @@ def install_program(program, tag="", on_progress=None, should_stop=None,
|
||||
"""
|
||||
repo = program.repo
|
||||
release_tag = tag or "latest"
|
||||
managed = (not tag and program is WHISPER and sys.platform == "linux"
|
||||
and platform.machine().lower() in ("x86_64", "amd64")
|
||||
and _has_vulkan())
|
||||
item = None
|
||||
managed = _managed_whisper(program, tag)
|
||||
item, vulkan = None, False
|
||||
if managed:
|
||||
repo = DIKTE_REPO
|
||||
release_tag = MANAGED_WHISPER_RELEASE
|
||||
@@ -398,6 +422,7 @@ def install_program(program, tag="", on_progress=None, should_stop=None,
|
||||
item = next((a for a in assets
|
||||
if a.name.endswith(MANAGED_WHISPER_VULKAN)
|
||||
and a.sha256 == MANAGED_WHISPER_SHA256), None)
|
||||
vulkan = item is not None
|
||||
if item:
|
||||
tag = MANAGED_WHISPER_VERSION
|
||||
|
||||
@@ -476,8 +501,13 @@ def install_program(program, tag="", on_progress=None, should_stop=None,
|
||||
# Found under the sibling, run from the final directory.
|
||||
binary = into / binary.relative_to(fresh)
|
||||
# Written last, so the record never points at anything half-made.
|
||||
_install_record(program).write_text(
|
||||
json.dumps({"tag": tag, "binary": str(binary)}), encoding="utf-8")
|
||||
record = {"tag": tag, "binary": str(binary)}
|
||||
if managed:
|
||||
# Which of the two builds this machine ended up with. Only written
|
||||
# where both were on offer, so an install that never had the
|
||||
# choice is not made to look like a fallback.
|
||||
record["backend"] = "vulkan" if vulkan else "processor"
|
||||
_install_record(program).write_text(json.dumps(record), encoding="utf-8")
|
||||
except OSError as exc:
|
||||
raise LocalError(t("Could not install {name}: {error}",
|
||||
name=program.name, error=exc)) from exc
|
||||
|
||||
@@ -780,6 +780,9 @@ TR = {
|
||||
"Not installed.": "Kurulu değil.",
|
||||
"Installed on the system: {path}": "Sistemde kurulu: {path}",
|
||||
"Downloaded, version {version}.": "İndirildi, sürüm {version}.",
|
||||
"Downloaded, version {version}. There was no Vulkan build, "
|
||||
"so this one runs on the processor.":
|
||||
"İndirildi, sürüm {version}. Vulkan sürümü yoktu, bu sürüm işlemcide çalışıyor.",
|
||||
"Fetching the model list…": "Model listesi çekiliyor…",
|
||||
"Downloading…": "İndiriliyor…",
|
||||
"Downloading: {done} of {total}{share}": "İndiriliyor: {done} / {total}{share}",
|
||||
|
||||
@@ -358,6 +358,13 @@ class LocalModelBox(QGroupBox):
|
||||
# for this machine and may reach the graphics card, while the
|
||||
# released binaries carry processor backends only.
|
||||
self.program_label.setText(t("Installed on the system: {path}", path=path))
|
||||
elif ggml.vulkan_missing(self.program):
|
||||
# The download landed the processor build where the graphics card
|
||||
# one belongs, and nothing else on this window would say so.
|
||||
self.program_label.setText(
|
||||
t("Downloaded, version {version}. There was no Vulkan build, "
|
||||
"so this one runs on the processor.",
|
||||
version=ggml.installed_version(self.program) or "?"))
|
||||
else:
|
||||
self.program_label.setText(
|
||||
t("Downloaded, version {version}.",
|
||||
|
||||
Reference in New Issue
Block a user