Skip to content

Commit

Permalink
Add beta support for Intel Arc GPU installation
Browse files Browse the repository at this point in the history
  • Loading branch information
yoland68 committed May 14, 2024
1 parent a898966 commit 28b6d76
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 6 deletions.
29 changes: 25 additions & 4 deletions comfy_cli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ def install(
callback=gpu_exclusivity_callback,
),
] = None,
intel_arc: Annotated[
bool,
typer.Option(
hidden=True,
show_default=False,
help="(Beta support) install for Intel Arc gpu, based on https://github.com/comfyanonymous/ComfyUI/pull/3439",
callback=gpu_exclusivity_callback,
),
] = None,
cpu: Annotated[
bool,
typer.Option(
Expand Down Expand Up @@ -240,8 +249,8 @@ def install(
gpu = GPU_OPTION.AMD
elif m_series:
gpu = GPU_OPTION.M_SERIES
elif cpu:
gpu = None
elif intel_arc:
gpu = GPU_OPTION.INTEL_ARC
else:
if platform == constants.OS.MACOS:
gpu = ui.prompt_select_enum(
Expand All @@ -255,10 +264,22 @@ def install(
)

if gpu == GPU_OPTION.INTEL_ARC:
print("[bold yellow]Installing on Intel ARC is not yet supported[/bold yellow]")
print(
"[bold yellow]Feel free to follow this thread to manually install:\nhttps://github.com/comfyanonymous/ComfyUI/discussions/476[/bold yellow]"
"[bold yellow]Installing on Intel ARC is not yet completely supported[/bold yellow]"
)
env_check = env_checker.EnvChecker()
if env_check.conda_env is None:
print(
"[bold red]Intel ARC support requires conda environment to be activated.[/bold red]"
)
raise typer.Exit(code=1)
if intel_arc is None:
confirm_result = ui.prompt_confirm_action(
"Are you sure you want to try beta install feature on Intel ARC?"
)
if not confirm_result:
raise typer.Exit(code=0)
print("[bold yellow]Installing on Intel ARC is in beta stage.[/bold yellow]")

if gpu is None and not cpu:
print(
Expand Down
28 changes: 27 additions & 1 deletion comfy_cli/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from rich import print
import typer

from comfy_cli import constants, ui
from comfy_cli import constants, ui, utils
from comfy_cli.constants import GPU_OPTION
from comfy_cli.workspace_manager import WorkspaceManager, check_comfy_repo
from comfy_cli.command.custom_nodes.command import update_node_id_cache
Expand Down Expand Up @@ -64,6 +64,32 @@ def install_comfyui_dependencies(
+ pip_url,
check=False,
)
# Beta support for intel arch based on this PR: https://github.com/comfyanonymous/ComfyUI/pull/3439
if gpu == GPU_OPTION.INTEL_ARC:
pip_url = [
"--extra-index-url",
"https://pytorch-extension.intel.com/release-whl/stable/xpu/us/",
]
utils.install_conda_package("libuv")
# TODO: wrap pip install in a function
subprocess.run(
[sys.executable, "-m", "pip", "install", "mkl", "mkl-dpcpp"],
check=True,
)
result = subprocess.run(
[
sys.executable,
"-m",
"pip",
"install",
"torch==2.1.0.post2",
"torchvision==0.16.0.post2",
"torchaudio==2.1.0.post2",
"intel-extension-for-pytorch==2.1.30",
]
+ pip_url,
check=False,
)
if result and result.returncode != 0:
print(
"Failed to install PyTorch dependencies. Please check your environment (`comfy env`) and try again"
Expand Down
16 changes: 15 additions & 1 deletion comfy_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
Module for utility functions.
"""

import subprocess
import sys
from comfy_cli import constants

import psutil
from rich import print
import typer

from comfy_cli import constants


def singleton(cls):
Expand Down Expand Up @@ -36,6 +41,15 @@ def get_os():
return constants.OS.LINUX


def install_conda_package(package_name):
try:
subprocess.check_call(["conda", "install", "-y", package_name])
print(f"[bold green] Successfully installed {package_name} [/bold green]")
except subprocess.CalledProcessError as e:
print(f"[bold red] Failed to install {package_name}. Error: {e} [/bold red]")
raise typer.Exit(code=1)


def get_not_user_set_default_workspace():
return constants.DEFAULT_COMFY_WORKSPACE[get_os()]

Expand Down

0 comments on commit 28b6d76

Please sign in to comment.