Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install nightly pytorch for macos. #334

Merged
merged 2 commits into from
Nov 23, 2024
Merged
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
24 changes: 18 additions & 6 deletions src/virtualEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,17 @@ export class VirtualEnvironment {
}

public async installRequirements(callbacks?: ProcessCallbacks): Promise<void> {
const installCmd = ['pip', 'install', '-r', this.requirementsCompiledPath, '--index-strategy', 'unsafe-best-match'];
if (process.platform === 'darwin') {
return this.manualInstall(callbacks);
}

const installCmd = ['pip', 'install', '-r', this.requirementsCompiledPath, '--index-strategy', 'unsafe-best-match'];
const { exitCode } = await this.runUvCommandAsync(installCmd, callbacks);
if (exitCode !== 0) {
if (exitCode == 0) {
log.error(
`Failed to install requirements.compiled: exit code ${exitCode}. Falling back to installing requirements.txt`
);

await this.installComfyUIRequirements(callbacks);
await this.installComfyUIManagerRequirements(callbacks);
return this.manualInstall(callbacks);
}
}

Expand Down Expand Up @@ -270,7 +271,13 @@ export class VirtualEnvironment {
});
}

private async installComfyUIRequirements(callbacks?: ProcessCallbacks): Promise<void> {
private async manualInstall(callbacks?: ProcessCallbacks): Promise<void> {
await this.installPytorch(callbacks);
await this.installComfyUIRequirements(callbacks);
await this.installComfyUIManagerRequirements(callbacks);
}

private async installPytorch(callbacks?: ProcessCallbacks): Promise<void> {
if (process.platform === 'win32') {
log.info('Installing PyTorch CUDA 12.1');
await this.runUvCommandAsync(
Expand All @@ -293,6 +300,9 @@ export class VirtualEnvironment {
[
'pip',
'install',
'-U',
'--prerelease',
'allow',
'torch',
'torchvision',
'torchaudio',
Expand All @@ -302,6 +312,8 @@ export class VirtualEnvironment {
callbacks
);
}
}
private async installComfyUIRequirements(callbacks?: ProcessCallbacks): Promise<void> {
log.info(`Installing ComfyUI requirements from ${this.comfyUIRequirementsPath}`);
const installCmd = ['pip', 'install', '-r', this.comfyUIRequirementsPath];
const { exitCode } = await this.runUvCommandAsync(installCmd, callbacks);
Expand Down
Loading