mirror of
https://github.com/debpalash/VoiceStudio.git
synced 2026-12-05 01:48:19 +00:00
* feat(gpu): add opt-in native Windows ROCm installation Use one pinned Windows recipe for source and Electron setup, verify native packages before reuse, and preserve explicit opt-in and sidecar compatibility boundaries. * docs(rocm): drop agent-instruction plan files; move the entry to a changelog fragment * fix(rocm): hash-pin every AMD artifact and keep dependencies at their locked versions Each repo.radeon.com wheel/sdist now carries a sha256 in the recipe, the loader refuses one without it, and the installer installs from a --hash requirements file (uv verifies; UV_NO_VERIFY_HASHES is stripped). A constraints file pins every installed package except the overlay (torch family, rocm*, triton*, ctranslate2), so transitive deps no longer resolve fresh from the index. The rocm sdist builds with the locked setuptools. * fix(rocm): ask before switching an existing runtime to Windows ROCm OMNIVOICE_TORCH_VARIANT=rocm used to be ignored on Windows; with this PR it would fail readiness on update and auto-repair into a multi-GB download from new hosts. A successful install now records its torch build (.runtime-torch); a runtime never installed with Windows ROCm goes to the setup screen instead of auto-repair. ROCm on Windows ARM64 reports not-ready instead of rejecting readiness, and the setup screen names repo.radeon.com as the Windows ROCm torch source. * fix(rocm): resolve ROCm packages from site-packages and remember a failed GPU probe package_root() finds torch, ctranslate2 and the ROCm SDK packages through their distribution records in this interpreter's site-packages, so a stray folder in the working directory of a -m child can't choose the DLL directories. A failed HIP CT2 probe (up to 90 s) is remembered for the process instead of 5 s, so catalogue refreshes don't re-run it; a restart, recipe or package change runs it again. * docs(rocm): record the owner-approved Windows ROCm endpoints and how setup checks them * docs(structure): count the pyannote compat service module * test(rocm): pin the host architecture in the setup-reuse readiness test * fix(repo): untrack the committed .venv symlink and ignore symlinked envs; follow the new ROCm copy in the GPU panel test .gitignore's '.venv/' only matches directories, so a worktree's symlinked .venv was committed and CI's uv sync failed on it. Ignore '.venv' without the slash and add a guard that no local environment path is ever tracked. * test(audio-io): allow the pyannote torchaudio shim, which applies the gate's own fix to third-party calls --------- Co-authored-by: debpalash <4178343+debpalash@users.noreply.github.com>
114 lines
4.0 KiB
JavaScript
114 lines
4.0 KiB
JavaScript
import { execFile } from 'node:child_process';
|
|
import { existsSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
|
|
/**
|
|
* Whether an NVIDIA driver is installed. File checks only (no subprocess), and
|
|
* deliberately generous: a false positive costs one avoidable GPU-wheel
|
|
* download, a false negative would silently strand a GPU host on CPU torch.
|
|
*/
|
|
export function nvidiaDriverPresent(
|
|
platform = process.platform,
|
|
exists = existsSync,
|
|
env = process.env,
|
|
) {
|
|
if (platform === 'win32') {
|
|
const root = env.SystemRoot || env.windir || 'C:\\Windows';
|
|
return (
|
|
['nvcuda.dll', 'nvml.dll', 'nvidia-smi.exe'].some((name) =>
|
|
exists(join(root, 'System32', name)),
|
|
) || exists('C:\\Program Files\\NVIDIA Corporation\\NVSMI\\nvidia-smi.exe')
|
|
);
|
|
}
|
|
if (platform !== 'linux') return false;
|
|
return [
|
|
'/proc/driver/nvidia/version',
|
|
'/dev/nvidiactl',
|
|
'/usr/lib/wsl/lib/libcuda.so.1',
|
|
'/usr/lib/x86_64-linux-gnu/libcuda.so.1',
|
|
'/usr/lib64/libcuda.so.1',
|
|
'/usr/lib/libcuda.so.1',
|
|
'/lib/x86_64-linux-gnu/libcuda.so.1',
|
|
'/usr/local/nvidia/lib64/libcuda.so.1',
|
|
'/usr/bin/nvidia-smi',
|
|
].some((path) => exists(path));
|
|
}
|
|
|
|
/** Probe the driver before installing torch; no Python or GPU libraries needed. */
|
|
export async function hasNvidiaGpu({
|
|
env = process.env,
|
|
platform = process.platform,
|
|
exists = existsSync,
|
|
run = execFile,
|
|
} = {}) {
|
|
if (nvidiaDriverPresent(platform, exists, env)) return true;
|
|
return new Promise((resolve) => {
|
|
run(
|
|
'nvidia-smi',
|
|
['--query-gpu=name', '--format=csv,noheader'],
|
|
{ env, timeout: 5_000, windowsHide: true, maxBuffer: 64 * 1024 },
|
|
(error, stdout) => resolve(!error && Boolean(stdout.trim())),
|
|
);
|
|
});
|
|
}
|
|
|
|
export function requestedTorchVariant(env = process.env) {
|
|
const raw = (env.OMNIVOICE_TORCH_VARIANT || 'auto').trim().toLowerCase() || 'auto';
|
|
const variant = raw === 'default' ? 'cuda' : raw;
|
|
if (!['auto', 'cpu', 'cuda', 'rocm'].includes(variant)) {
|
|
throw new Error('OMNIVOICE_TORCH_VARIANT must be auto, cpu, cuda, or rocm.');
|
|
}
|
|
return variant;
|
|
}
|
|
|
|
/** Explicit wheel choices win; Apple keeps its native MPS-capable distribution. */
|
|
export async function selectTorchVariant({
|
|
env = process.env,
|
|
platform = process.platform,
|
|
arch = process.arch,
|
|
nvidiaAvailable = () => hasNvidiaGpu({ env, platform }),
|
|
} = {}) {
|
|
const requested = requestedTorchVariant(env);
|
|
if (requested === 'rocm' && platform === 'win32') {
|
|
if (arch !== 'x64') throw new Error('Windows ROCm requires Windows x64 Python 3.12 (cp312).');
|
|
return 'rocm';
|
|
}
|
|
if (platform === 'darwin') return 'native';
|
|
if (requested === 'rocm' && platform === 'linux') return 'rocm';
|
|
const cpuWheelsApply =
|
|
(platform === 'linux' && arch === 'x64') ||
|
|
(platform === 'win32' && (arch === 'x64' || arch === 'arm64'));
|
|
// Linux ARM keeps the lock's PyPI wheels, including explicit CPU requests.
|
|
if (!cpuWheelsApply) return 'native';
|
|
if (requested === 'cpu' || requested === 'cuda') return requested;
|
|
if (platform === 'win32' && arch === 'arm64') return 'cpu';
|
|
if ((env.OMNIVOICE_DEVICE || '').trim().toLowerCase() === 'cpu') return 'cpu';
|
|
return (await nvidiaAvailable()) ? 'cuda' : 'cpu';
|
|
}
|
|
|
|
/** Both variants are frozen in uv.lock; never download CUDA before swapping to CPU. */
|
|
export function torchSyncArgs(variant) {
|
|
return variant === 'cpu' ? ['--no-group', 'cuda', '--group', 'cpu'] : [];
|
|
}
|
|
|
|
/** The lock's CUDA runtime packages, excluding the hardware metadata binding. */
|
|
export function cudaOnlyPackages(lockText) {
|
|
return [
|
|
...new Set(
|
|
[...lockText.matchAll(/^name = "(nvidia-[a-z0-9-]+)"$/gm)]
|
|
.map((match) => match[1])
|
|
.filter((name) => name !== 'nvidia-ml-py'),
|
|
),
|
|
].sort();
|
|
}
|
|
|
|
/** Preserve SDK packages on repair; never lay locked CUDA/CT2 over the HIP overlay. */
|
|
export function windowsRocmSyncArgs(lockText) {
|
|
return [
|
|
'--inexact',
|
|
...['torch', 'torchaudio', 'torchvision', 'ctranslate2', ...cudaOnlyPackages(lockText)].flatMap(
|
|
(name) => ['--no-install-package', name],
|
|
),
|
|
];
|
|
}
|