Skip to content

Commit 3109afa

Browse files
committed
Fix comfy-cli install --cpu still installs CUDA version of PyTorch
1 parent c5986e6 commit 3109afa

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

comfy_cli/command/install.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,27 @@ def pip_install_comfyui_dependencies(
123123
+ pip_url,
124124
check=False,
125125
)
126+
127+
# install torch for CPU
128+
if gpu is None: # Currently, when install for CPU, gpu is None
129+
pip_url = [
130+
"--extra-index-url",
131+
"https://download.pytorch.org/whl/cpu",
132+
]
133+
result = subprocess.run(
134+
[
135+
sys.executable,
136+
"-m",
137+
"pip",
138+
"install",
139+
"torch",
140+
"torchvision",
141+
"torchaudio",
142+
]
143+
+ pip_url,
144+
check=False,
145+
)
146+
126147
if result and result.returncode != 0:
127148
rprint("Failed to install PyTorch dependencies. Please check your environment (`comfy env`) and try again")
128149
sys.exit(1)

0 commit comments

Comments
 (0)