Skip to content

Commit

Permalink
Add GPU selection to desktop installer (#1888)
Browse files Browse the repository at this point in the history
* Remove redundant code

* Add GPU picker screen to installer

* Permit jumping installation steps when visited

* Prevent sad girl from covering buttons

* Update gpu options to match availability

* Ensure install screen renders inside bounds

* Pre-select GPU detected by desktop native

* Redesign GPU selection screen

* Prevent text highlight on installer stepper

* Add translations for GPU picker

* Rename for clarity

* Remove unused code

* Update electron types

* Update locales [skip ci]

---------

Co-authored-by: huchenlei <[email protected]>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent a441908 commit 601b739
Show file tree
Hide file tree
Showing 14 changed files with 440 additions and 67 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
},
"dependencies": {
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
"@comfyorg/comfyui-electron-types": "^0.3.32",
"@comfyorg/comfyui-electron-types": "^0.3.34",
"@comfyorg/litegraph": "^0.8.46",
"@primevue/themes": "^4.0.5",
"@vueuse/core": "^11.0.0",
Expand Down
Binary file added public/assets/images/apple-mps-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/assets/images/manual-configuration.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/assets/images/nvidia-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
203 changes: 203 additions & 0 deletions src/components/install/GpuPicker.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<template>
<div class="flex flex-col gap-6 w-[600px] h-[30rem] select-none">
<!-- Installation Path Section -->
<div class="grow flex flex-col gap-4 text-neutral-300">
<h2 class="text-2xl font-semibold text-neutral-100">
{{ $t('install.gpuSelection.selectGpu') }}
</h2>

<p class="m-1 text-neutral-400">
{{ $t('install.gpuSelection.selectGpuDescription') }}:
</p>

<!-- GPU Selection buttons -->
<div
class="flex gap-2 text-center transition-opacity"
:class="{ selected: selected }"
>
<!-- NVIDIA -->
<div
v-if="platform !== 'darwin'"
class="gpu-button"
:class="{ selected: selected === 'nvidia' }"
role="button"
@click="pickGpu('nvidia')"
>
<img
class="m-12"
alt="NVIDIA logo"
width="196"
height="32"
src="/assets/images/nvidia-logo.svg"
/>
</div>
<!-- MPS -->
<div
v-if="platform === 'darwin'"
class="gpu-button"
:class="{ selected: selected === 'mps' }"
role="button"
@click="pickGpu('mps')"
>
<img
class="rounded-lg hover-brighten"
alt="Apple Metal Performance Shaders Logo"
width="292"
ratio
src="/assets/images/apple-mps-logo.png"
/>
</div>
<!-- Manual configuration -->
<div
class="gpu-button"
:class="{ selected: selected === 'unsupported' }"
role="button"
@click="pickGpu('unsupported')"
>
<img
class="m-12"
alt="Manual configuration"
width="196"
src="/assets/images/manual-configuration.svg"
/>
</div>
</div>

<!-- Details on selected GPU -->
<p v-if="selected === 'nvidia'" class="m-1">
<Tag icon="pi pi-check" severity="success" :value="'CUDA'" />
{{ $t('install.gpuSelection.nvidiaDescription') }}
</p>

<p v-if="selected === 'mps'" class="m-1">
<Tag icon="pi pi-check" severity="success" :value="'MPS'" />
{{ $t('install.gpuSelection.mpsDescription') }}
</p>

<div v-if="selected === 'unsupported'" class="text-neutral-300">
<p class="m-1">
<Tag
icon="pi pi-exclamation-triangle"
severity="warn"
:value="t('icon.exclamation-triangle')"
/>
{{ $t('install.gpuSelection.customSkipsPython') }}
</p>

<ul>
<li>
<strong>
{{ $t('install.gpuSelection.customComfyNeedsPython') }}
</strong>
</li>
<li>{{ $t('install.gpuSelection.customManualVenv') }}</li>
<li>{{ $t('install.gpuSelection.customInstallRequirements') }}</li>
<li>{{ $t('install.gpuSelection.customMayNotWork') }}</li>
</ul>
</div>

<div v-if="selected === 'cpu'">
<p class="m-1">
<Tag
icon="pi pi-exclamation-triangle"
severity="warn"
:value="t('icon.exclamation-triangle')"
></Tag>
{{ $t('install.gpuSelection.cpuModeDescription') }}
</p>
<p class="m-1">
{{ $t('install.gpuSelection.cpuModeDescription2') }}
</p>
</div>
</div>

<div
class="transition-opacity flex gap-3 h-0"
:class="{
'opacity-40': selected && selected !== 'cpu'
}"
>
<ToggleSwitch
v-model="cpuMode"
inputId="cpu-mode"
class="-translate-y-40"
/>
<label for="cpu-mode" class="select-none">
{{ $t('install.gpuSelection.enableCpuMode') }}
</label>
</div>
</div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { electronAPI, TorchDeviceType } from '@/utils/envUtil'
import ToggleSwitch from 'primevue/toggleswitch'
import Tag from 'primevue/tag'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const cpuMode = computed({
get: () => selected.value === 'cpu',
set: (value) => {
selected.value = value ? 'cpu' : null
}
})
const selected = defineModel<TorchDeviceType>('device', {
required: true
})
const electron = electronAPI()
const platform = electron.getPlatform()
const pickGpu = (value: typeof selected.value) => {
const newValue = selected.value === value ? null : value
selected.value = newValue
}
</script>

<style lang="postcss">
:root {
--p-tag-gap: 0.5rem;
}
.hover-brighten {
@apply transition-colors;
transition-property: filter, box-shadow;
&:hover {
filter: brightness(107%) contrast(105%);
box-shadow: 0 0 0.25rem #ffffff79;
}
}
.p-accordioncontent-content {
@apply bg-neutral-900 rounded-lg transition-colors;
}
div.selected {
.gpu-button:not(.selected) {
@apply opacity-50 hover:opacity-100;
}
}
.gpu-button {
@apply w-1/2 m-0 cursor-pointer rounded-lg flex flex-col items-center justify-around bg-neutral-800 bg-opacity-50 hover:bg-opacity-75 transition-colors;
&.selected {
@apply opacity-100 bg-neutral-700 bg-opacity-50 hover:bg-opacity-60;
}
}
.disabled {
@apply pointer-events-none opacity-40;
}
.p-card-header {
@apply text-center grow;
}
.p-card-body {
@apply text-center pt-0;
}
</style>
19 changes: 18 additions & 1 deletion src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"file": "File",
"inbox": "Inbox",
"box": "Box",
"briefcase": "Briefcase"
"briefcase": "Briefcase",
"exclamation-triangle": "Warning"
},
"welcome": {
"title": "Welcome to ComfyUI",
Expand Down Expand Up @@ -129,6 +130,22 @@
"migrationOptional": "Migration is optional. If you don't have an existing installation, you can skip this step.",
"desktopAppSettings": "Desktop App Settings",
"desktopAppSettingsDescription": "Configure how ComfyUI behaves on your desktop. You can change these settings later.",
"gpu": "GPU",
"gpuSelection": {
"selectGpu": "Select GPU",
"selectGpuDescription": "Select the type of GPU you have",
"cpuMode": "CPU Mode",
"cpuModeDescription": "CPU mode is intended for developers and rare edge cases only.",
"cpuModeDescription2": "If you are not absolutely certain you need this, please ignore this box and select your GPU above.",
"enableCpuMode": "Enable CPU Mode",
"nvidiaDescription": "NVIDIA devices are directly supported using pytorch CUDA builds.",
"mpsDescription": "Apple Metal Performance Shaders are supported using pytorch nightly.",
"customSkipsPython": "This option skips the normal python setup.",
"customComfyNeedsPython": "ComfyUI will not work until python is setup",
"customManualVenv": "Manually configure python venv",
"customInstallRequirements": "Install all requirements and dependencies (e.g. custom torch)",
"customMayNotWork": "This is entirely unsupported, and may simply not work"
},
"settings": {
"autoUpdate": "Automatic Updates",
"allowMetrics": "Crash Reports",
Expand Down
17 changes: 17 additions & 0 deletions src/locales/ja/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"bookmark": "ブックマーク",
"box": "ボックス",
"briefcase": "ブリーフケース",
"exclamation-triangle": "警告",
"file": "ファイル",
"folder": "フォルダー",
"heart": "ハート",
Expand All @@ -157,6 +158,22 @@
"desktopAppSettingsDescription": "ComfyUIのデスクトップでの動作を設定します。これらの設定は後で変更可能です。",
"desktopSettings": "デスクトップ設定",
"failedToSelectDirectory": "ディレクトリの選択に失敗しました",
"gpu": "GPU",
"gpuSelection": {
"cpuMode": "CPUモード",
"cpuModeDescription": "CPUモードは開発者やまれなエッジケースのみを対象としています。",
"cpuModeDescription2": "これが絶対に必要であることが確定していない場合は、このボックスを無視して上でGPUを選択してください。",
"customComfyNeedsPython": "ComfyUIはpythonがセットアップされるまで動作しません",
"customInstallRequirements": "すべての要件と依存関係をインストールする(例:カスタムtorch)",
"customManualVenv": "python venvを手動で設定する",
"customMayNotWork": "これは完全にサポートされておらず、単純に動作しない場合があります。",
"customSkipsPython": "このオプションは通常のpythonセットアップをスキップします。",
"enableCpuMode": "CPUモードを有効にする",
"mpsDescription": "Apple Metal Performance Shadersは、pytorch nightlyを使用してサポートされています。",
"nvidiaDescription": "NVIDIAデバイスは、pytorch CUDAビルドを使用して直接サポートされています。",
"selectGpu": "GPUを選択",
"selectGpuDescription": "所有しているGPUのタイプを選択してください"
},
"installLocation": "インストール先",
"installLocationDescription": "ComfyUIのユーザーデータを保存するディレクトリを選択してください。Python環境が選択した場所にインストールされます。選択したディスクに約15GBの空き容量が必要です。",
"installLocationTooltip": "ComfyUIのユーザーデータディレクトリ。保存内容:\n- Python環境\n- モデル\n- カスタムノード\n",
Expand Down
Loading

0 comments on commit 601b739

Please sign in to comment.