Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,38 @@ needs lives in `shell/packaging/`.
installed when `nvidia-smi` finds a device. `<APPID>_GPU=0|1` overrides the
probe either way.

**torch.** A lock holds one torch build, and which build a machine needs
depends on its GPU. Setup tells three cases apart from the lock, and the setup
window shows the PyTorch step for the last two only:

* *No torch* (Ground Crew): an exact `uv sync`, as for any app.
* *Locked* (SpyDE): the lock pins torch. On Windows and Linux, setup syncs
everything else exactly, then installs that release with
`--torch-backend=auto`.
* *Per machine* (Autopilot): name torch as a dependency and leave it out of
the lock with `[tool.uv] exclude-dependencies = ["torch"]`, which uv records
in `uv.lock`. Both are needed: torch merely absent from the lock means no
torch.
Setup syncs with `--inexact`, so a torch already installed survives an
upgrade. It then installs the newest torch the app's specifier allows, built
for this machine, but only when torch is missing, does not load, or has no
kernels for the GPU. A failed install is reported in the setup overlay, the
app starts without torch, and the next launch tries again. From a
wheelhouse, torch comes from the wheelhouse folder or not at all: the
wheelhouse builder works from the lock, so a site that needs torch offline
adds the torch wheels to the folder itself.

**Which torch build.** Setup chooses `--torch-backend` before it downloads
anything. uv's `auto` looks only at the driver version, so a recent driver on
a card older than sm_70 (Pascal, Maxwell) would get a build with no kernels
for it. Setup therefore reads the compute capability from `nvidia-smi` first:
below 7.0 it installs cu126, the newest build that still supports those cards,
and otherwise `auto`. `<APPID>_TORCH_BACKEND` (for example `cu126` or `cpu`)
overrides the choice.

A "Fix PyTorch" button calls `installTorchPerMachine` with `{ reinstall: true }`
for a locked torch, or `{ upgrade: true }` per machine.

**Offline sites.** Unzip the release's wheelhouse into the install
folder (next to the app's `.exe`) or into `userData/wheelhouse`, or let the
user choose it with "Install from a folder…" when the online install fails. The first launch then installs with no network:
Expand Down
5 changes: 5 additions & 0 deletions de_shell/js/main/envProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export function parseUvLine(raw: string): EnvProgressEvent | null {
if (/two-step|full locked|uv sync|deferred/i.test(msg)) {
return { phase: 'resolving', step: 'Preparing the analysis environment', percent: null }
}
// A torch line that is not the install itself (checking, keeping, why it
// failed) is news for the operator: show it as written.
if (/torch/i.test(msg) && !/^installing\b|install complete/i.test(msg)) {
return { phase: 'torch', step: capitalize(msg), percent: null }
}
if (/torch/i.test(msg)) {
return { phase: 'torch', step: 'Installing PyTorch for your GPU', percent: null }
}
Expand Down
4 changes: 2 additions & 2 deletions de_shell/js/main/envSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { app, dialog, ipcMain } from 'electron'
import { channel, shellConfig } from './config'
import { runEnvSetupMachine } from './envSetupMachine'
import type { EnvSetupAnswer } from './envSetupMachine'
import { readLockedTorchVersion, resolvePythonEnv } from './pythonEnv'
import { resolvePythonEnv, setupHasTorchStep } from './pythonEnv'
import type { EnsureOptions, ResolvedPython } from './pythonEnv'
import type { ShellWindow } from './window'

Expand Down Expand Up @@ -58,7 +58,7 @@ export function runEnvSetup(
listenForAnswers()
return runEnvSetupMachine<ResolvedPython>({
initialWheelhouse: opts.wheelhouse ?? null,
torch: readLockedTorchVersion(join(opts.resourcesPath, 'python')) !== null,
torch: setupHasTorchStep(join(opts.resourcesPath, 'python')),
run: (wheelhouse, onProgress) => resolvePythonEnv({
...opts,
wheelhouse,
Expand Down
3 changes: 2 additions & 1 deletion de_shell/js/main/envSetupMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ export interface MachineDeps<R> {
/** Native folder picker; null when cancelled. */
pickFolder: () => Promise<string | null>
quit: () => void
/** False when the app's lock has no torch, so the overlay drops that step. */
/** False when the app has no torch (`setupHasTorchStep`), so the overlay
* drops that step. */
torch?: boolean
/** Wheelhouse to start with (an app that already knows the machine is offline). */
initialWheelhouse?: string | null
Expand Down
4 changes: 3 additions & 1 deletion de_shell/js/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ export type { BackendHandlers } from './backendProcess'
export {
resolvePythonEnv, managedEnvPaths, venvPython, readLockedTorchVersion,
installTorchPerMachine, hasNvidiaGpu, readWheelhouse, findWheelhouse,
wheelhouseCandidates, lockStamp, buildSyncArgs, offlinePlan,
wheelhouseCandidates, lockStamp, buildSyncArgs, offlinePlan, readTorchSetup, setupHasTorchStep,
torchInstallArgs, probeTorch, ensureTorchPerMachine, torchBackend,
} from './pythonEnv'
export type {
ResolvedPython, EnsureOptions, WheelhouseManifest, CommandRunner, OfflinePlan,
TorchSetup, TorchStatus, UvCall,
} from './pythonEnv'

export { parseUvLine } from './envProgress'
Expand Down
Loading
Loading