Skip to content

Split any YouTube song into stems

TypeScript

fix: nvidia guard for GPU engine download, review cleanups

Daniel Ravina82a772667bd1
diff --git a/src/main/env.ts b/src/main/env.ts
index 7d40c94..4c37411 100644
--- a/src/main/env.ts
+++ b/src/main/env.ts
@@ -651,7 +651,10 @@ const GPU_TORCH_INDEX = 'https://download.pytorch.org/whl/cu121'
let gpuEnginePromise: Promise<boolean> | null = null
const gpuProgressListeners = new Set<(pct: number) => void>()
-export function ensureGpuEngine(onProgress?: (pct: number) => void): Promise<boolean> {
+export function ensureGpuEngine(
+ onProgress?: (pct: number) => void,
+ requireNvidia = false
+): Promise<boolean> {
if (onProgress) gpuProgressListeners.add(onProgress)
const detach = (): boolean => {
if (onProgress) gpuProgressListeners.delete(onProgress)
@@ -665,6 +668,10 @@ export function ensureGpuEngine(onProgress?: (pct: number) => void): Promise<boo
gpuEnginePromise = (async () => {
// already swapped in: the venv's torch speaks CUDA, nothing to install
if (await hasGpuAcceleration()) return true
+ // the Settings toggle is gated on NVIDIA detection, but a stale setting
+ // or a failed nvidia-smi probe could still land here — don't pull
+ // ~2.5GB of CUDA torch on a machine that can't use it
+ if (requireNvidia && !(await detectNvidiaGpu())) return false
sendEnvEvent('Downloading the GPU engine (~2.5GB, one time)')
await new Promise<void>((resolve, reject) => {
const child = spawn(
@@ -922,7 +929,7 @@ export async function bootstrap(): Promise<boolean> {
await refreshReady()
sendEnvEvent('Engine ready', 'success')
// no checkpoint prefetch here: the optional engines (~913MB vocals,
- // ~170MB fine-tuned) download only when their settings toggles are on,
+ // ~320MB fine-tuned) download only when their settings toggles are on,
// handled by the app-start prefetch in index.ts
return true
} catch (err) {
diff --git a/src/main/index.ts b/src/main/index.ts
index cdb94af..899344d 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -132,7 +132,7 @@ app.whenReady().then(async () => {
const settings = loadSettings()
if (settings.roformerVocals) void ensureVocalsEngine()
if (settings.htdemucsFt) void ensureFtWeights()
- if (settings.gpuSplit) void ensureGpuEngine()
+ if (settings.gpuSplit) void ensureGpuEngine(undefined, true)
// warm the informational GPU probe so Settings can show it right away
void hasGpuAcceleration()
}
diff --git a/src/main/pipeline.ts b/src/main/pipeline.ts
index e285970..1819909 100644
--- a/src/main/pipeline.ts
+++ b/src/main/pipeline.ts
@@ -253,8 +253,9 @@ export async function startJob(
// download has run (fresh setting, or a failed earlier attempt)
if (useGpu) {
if (
- !(await ensureGpuEngine((pct) =>
- progress(job, 'separate', 0, `Downloading GPU engine: ${pct}%`)
+ !(await ensureGpuEngine(
+ (pct) => progress(job, 'separate', 0, `Downloading GPU engine: ${pct}%`),
+ true
))
) {
bail('Could not prepare the GPU engine — switch back to CPU in Settings and try again')
@@ -356,12 +357,9 @@ export async function startJob(
'--device',
deviceArg()
],
- lineParsers((pct, msg) => {
- if (!msg) return vocalsBase + Math.round((pct / 100) * (roformerSpan - vocalsBase))
- // fallback path: roformer.py downloading the engine itself
- const m = msg.match(/(\d+)%/)
- return m ? Math.round((Number(m[1]) / 100) * downloadSpan) : pct
- })
+ lineParsers((pct) =>
+ vocalsBase + Math.round((pct / 100) * (roformerSpan - vocalsBase))
+ )
)
}
if (otherStems.length > 0) {
diff --git a/src/renderer/src/components/Settings.tsx b/src/renderer/src/components/Settings.tsx
index ff9e2da..e88bb38 100644
--- a/src/renderer/src/components/Settings.tsx
+++ b/src/renderer/src/components/Settings.tsx
@@ -357,7 +357,7 @@ export function Settings({ settings, gpu, nvidiaGpu, onChange, onClose }: Props)
<div className="min-w-0">
<p className="text-[13px] font-medium">Anonymous usage stats</p>
<p className="text-[11.5px] text-white/40 leading-relaxed mt-0.5">
- On by default. Helps improve StemKit with anonymous events (app version, OS,
+ Helps improve StemKit with anonymous events (app version, OS,
actions). Song titles, links and audio never leave your machine.
</p>
</div>
diff --git a/src/renderer/src/lib/thumbs.tsx b/src/renderer/src/lib/thumbs.tsx
index 18690c4..d9f6034 100644
--- a/src/renderer/src/lib/thumbs.tsx
+++ b/src/renderer/src/lib/thumbs.tsx
@@ -39,4 +39,4 @@ export function Thumb({ videoId, className }: { videoId: string; className: stri
const src = useThumb(videoId)
if (!src) return <span className={className} />
return <img src={src} alt="" className={className} draggable={false} />
-}
\ No newline at end of file
+}
diff --git a/website/index.html b/website/index.html
index f533482..1bb1f5b 100644
--- a/website/index.html
+++ b/website/index.html
@@ -368,7 +368,7 @@
</a>
<a class="btn-ghost" href="https://github.com/danvelope/stemkit" target="_blank" rel="noopener" data-ga="github">Star on GitHub</a>
</div>
- <p class="caption-note">no account needed · no data sent anywhere</p>
+ <p class="caption-note">no account needed · fully local processing</p>
</div>
<footer>