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

Update install_env.sh of Comfy #1170

Merged
merged 14 commits into from
Dec 27, 2024
8 changes: 4 additions & 4 deletions onediff_comfy_nodes/benchmarks/scripts/install_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ if [ "$CI" = "1" ]; then
echo "Detected CI environment. Skipping local environment-specific dependencies."
else
echo "Detected local environment. Installing local environment-specific dependencies."
pip install -r $CUSTOM_NODES/ComfyUI_InstantID/requirements.txt
pip install -r $CUSTOM_NODES/PuLID_ComfyUI/requirements.txt
python3 -m pip install --user -r $CUSTOM_NODES/ComfyUI_InstantID/requirements.txt
python3 -m pip install --user -r $CUSTOM_NODES/PuLID_ComfyUI/requirements.txt
Comment on lines +25 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for requirements installation.

The requirements installation commands should include error handling to ensure the script fails gracefully if the requirements files are missing or if installations fail.

Consider this improvement:

-  python3 -m pip install --user -r $CUSTOM_NODES/ComfyUI_InstantID/requirements.txt
-  python3 -m pip install --user -r $CUSTOM_NODES/PuLID_ComfyUI/requirements.txt
+  for node in "ComfyUI_InstantID" "PuLID_ComfyUI"; do
+    req_file="$CUSTOM_NODES/$node/requirements.txt"
+    if [ -f "$req_file" ]; then
+      echo "Installing requirements for $node..."
+      python3 -m pip install --user -r "$req_file" || {
+        echo "Failed to install requirements for $node"
+        exit 1
+      }
+    else
+      echo "Warning: Requirements file not found for $node"
+    fi
+  done
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
python3 -m pip install --user -r $CUSTOM_NODES/ComfyUI_InstantID/requirements.txt
python3 -m pip install --user -r $CUSTOM_NODES/PuLID_ComfyUI/requirements.txt
for node in "ComfyUI_InstantID" "PuLID_ComfyUI"; do
req_file="$CUSTOM_NODES/$node/requirements.txt"
if [ -f "$req_file" ]; then
echo "Installing requirements for $node..."
python3 -m pip install --user -r "$req_file" || {
echo "Failed to install requirements for $node"
exit 1
}
else
echo "Warning: Requirements file not found for $node"
fi
done

fi

echo "Installing common dependencies..."
pip install websocket-client==1.8.0 numpy==1.26.4 scikit-image -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install nexfort
python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i https://pypi.tuna.tsinghua.edu.cn/simple
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Make mirror URL configurable and add CUDA version check

Based on the repository documentation and code analysis:

  1. The project explicitly requires CUDA 11.8 (with 12.1 and 12.2 as alternatives)
  2. The codebase includes GPU-specific optimizations and CUDA dependencies
  3. flash-attn is used in CrossAttention modules with specific dimension requirements

Suggested changes:

+# Check CUDA version
+if ! command -v nvcc &> /dev/null; then
+    echo "Warning: NVCC not found. flash-attn requires CUDA (11.8, 12.1, or 12.2)"
+    exit 1
+fi
+
+# Allow mirror configuration
+PIP_MIRROR=${PIP_MIRROR:-"https://pypi.tuna.tsinghua.edu.cn/simple"}
+
-python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i https://pypi.tuna.tsinghua.edu.cn/simple
+python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i "$PIP_MIRROR"
🔗 Analysis chain

Consider environment-specific mirror selection and verify CUDA compatibility.

The script has two potential improvements:

  1. The Tsinghua mirror is hardcoded, which might not be optimal for users outside China
  2. flash-attn 2.5.8 has specific CUDA requirements that should be verified before installation

Consider making the mirror URL configurable:

-python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i https://pypi.tuna.tsinghua.edu.cn/simple
+PIP_MIRROR=${PIP_MIRROR:-"https://pypi.tuna.tsinghua.edu.cn/simple"}
+python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i "$PIP_MIRROR"

Let's verify CUDA compatibility:


Let me check if there are any CUDA requirements or compatibility notes in the repository documentation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check CUDA version and nvcc availability
if command -v nvcc &> /dev/null; then
    echo "CUDA version:"
    nvcc --version
else
    echo "Warning: NVCC not found. flash-attn might not work without CUDA support"
fi

Length of output: 170


Script:

#!/bin/bash
# Check for CUDA requirements in documentation
rg -i "cuda|gpu" README.md || echo "No CUDA/GPU mentions in README"

# Check for any installation requirements or prerequisites
fd "requirements|install" -e txt -e md -X cat {} || echo "No requirement files found"

# Look for any flash-attn related configuration or setup
rg -i "flash.?attn" -A 3 -B 3

Length of output: 4167

python3 -m pip install --user nexfort
Loading