Skip to content

Commit

Permalink
Add script files
Browse files Browse the repository at this point in the history
  • Loading branch information
YanWenKun committed Oct 28, 2024
1 parent 254901e commit de441ec
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 16 deletions.
13 changes: 10 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ that download model files on the first run (may cause freezing for users with ba
3. Place SD models in `ComfyUI\models\checkpoints`.
** Subdirectories can be created for better organization.

4. Run `run_nvidia_gpu.bat` to start ComfyUI.
4. Edit and run `run_nvidia_gpu.bat` to start ComfyUI.

** If you don't want the browser to open automatically, add `--disable-auto-launch` to the startup arguments.

** If you're using 40/Ada series or newer GPU, you can try adding `--fast` to the startup arguments.
https://github.com/comfyanonymous/ComfyUI/commit/9953f22fce0ba899da0676a0b374e5d1f72bf259[It has magic].


5. After starting, the program will automatically open a browser, or you can visit: http://localhost:8188/
** If you don't want the browser to open automatically, edit `run_nvidia_gpu.bat` and add the startup parameter `--disable-auto-launch`.

== Important Prerequisites For 3D-Pack Users

Expand All @@ -66,6 +71,8 @@ Only link:docs/cuda-toolkit-install-selection.webp[Libraries and Compilers] are
https://github.com/ashawkey/stable-dreamfusion/issues/360#issuecomment-2292510049[GPU arch],
to save your time on JIT compiling.

After successfully launching ComfyUI and loading the ComfyUI-3D-Pack, it is recommended to first run the *TripoSR* workflow, as the model files required for this workflow are smaller, execute faster, and have a high success rate.

== Tips for Usage

1. Model Path: If model files are already saved in another location and you don't want to move them, you can configure the program to load them:
Expand Down Expand Up @@ -187,7 +194,7 @@ on my repository page.
4. Wait about 20~40 minutes until the workflow run complete.
5. Go to the *releases* page of your repository, where you'll find the newly generated draft for download or publish.

== Security
== Temp Files

image::docs/sandboxie.avif["file diff",width=40%]

Expand Down
19 changes: 13 additions & 6 deletions README.zh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ https://github.com/ltdrdata/ComfyUI-Impact-Pack[Impact Pack]
3. 将 SD 模型放到 `ComfyUI\models\checkpoints`
** 可以随意建立子目录,便于分类
4. *运行 `run_nvidia_gpu.bat` 即可启动程序。*
4. 编辑启动脚本
** 大陆地区用户推荐先将 `中文脚本` 目录下的文件复制到主目录,并编辑 `run_cn.bat`
** 如用户可直接访问 GitHub,编辑 `run_nvidia_gpu.bat` 即可
** 如果不想自动打开浏览器,在启动脚本中添加启动参数 `--disable-auto-launch`
** 如果正在用 40 系及未来的 GPU,可尝试添加启动参数 `--fast`,有
https://github.com/comfyanonymous/ComfyUI/commit/9953f22fce0ba899da0676a0b374e5d1f72bf259[魔法]
5. 启动后程序会自动打开浏览器,也可手动访问: http://localhost:8188/
** 如果不想自动打开浏览器,编辑 `run_nvidia_gpu.bat` 加上启动参数 `--disable-auto-launch`
6. 点击 ComfyUI 页面右上角的 齿轮(⚙)图标可修改设置,找到 *AGLTranslation* 可以修改语言(默认 English)。
5. 执行启动脚本。启动后程序会自动打开浏览器,也可手动访问: http://localhost:8188/
6. 点击 ComfyUI 页面右上角的 齿轮(⚙)图标可修改设置,找到 *AGL* 可以修改语言(默认 English)。
== 运行 3D-Pack 前置条件

Expand All @@ -64,7 +69,9 @@ https://developer.nvidia.com/cuda-12-4-1-download-archive?target_os=Windows&targ
https://github.com/ashawkey/stable-dreamfusion/issues/360#issuecomment-2292510049[GPU 架构]
来精简 `TORCH_CUDA_ARCH_LIST`,以节约运行时的 JIT 编译耗时。

此外请注意,Comfy3D 还会在执行各节点时下载所需模型,而访问 HuggingFace 可能需要挂代理。
在成功启动 ComfyUI 并加载 ComfyUI-3D-Pack 后,推荐先执行 *TripoSR* 工作流,该工作流所需模型文件较小,执行较快,且成功率高。

此外请注意,Comfy3D 还会在执行各节点时下载所需模型,而访问 HuggingFace 可能需要挂代理。中文脚本默认走国内代理。

## 使用技巧

Expand Down Expand Up @@ -186,7 +193,7 @@ https://github.com/YanWenKun/ComfyUI-Windows-Portable/actions/workflows/build.ym
4. 等待执行完毕(20~40分钟)
5. 找到仓库的 *releases* 页面,里面会有刚生成的草稿,即可下载或编辑发布。

## 安全
## 临时文件

image::docs/sandboxie.avif["file diff",width=50%]

Expand Down
30 changes: 30 additions & 0 deletions attachments/force-update-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# You need to install Git for Windows and select Git Bash (Default)
# https://git-scm.com/download/win

set -e

# If you don't want a FORCE update, remove "git reset" line
function change_url_or_pull () {
git_remote_url=$(git -C "$1" remote get-url origin) ;

if [[ $git_remote_url =~ ^(https:\/\/github\.com\/)(.*)(\.git)$ ]]; then
echo "Updating: $1" ;
git -C "$1" reset --hard ;
git -C "$1" pull --ff-only ;
echo "Done Updating: $1" ;
fi ;
}

change_url_or_pull ComfyUI

cd ./ComfyUI/custom_nodes
for D in *; do
if [ -d "${D}" ]; then
change_url_or_pull "${D}" &
fi
done

wait $(jobs -p)

exit 0
7 changes: 0 additions & 7 deletions attachments/run_nvidia_gpu.bat
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
@REM To set proxy, edit and uncomment the two lines below (remove 'rem ' in the beginning of line).
@REM 如需配置代理,编辑下两行命令,并取消注释(移除行首的 'rem ')。
rem set HTTP_PROXY=http://localhost:1081
rem set HTTPS_PROXY=http://localhost:1081

@REM To set mirror site for PIP & HuggingFace Hub, uncomment and edit the two lines below.
@REM 如需配置 PIP 与 HuggingFace Hub 镜像,取消注释并编辑下两行。
rem set PIP_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
rem set HF_ENDPOINT=https://hf-mirror.com

@REM In order to save your time on compiling PyTorch JIT CPP extensions, edit this line according to your GPU arch.
@REM 依照下表,修改为你的 GPU 对应架构,以节约 JIT 编译 PyTorch C++ 扩展的时间:
@REM Ref: https://github.com/ashawkey/stable-dreamfusion/issues/360#issuecomment-2292510049
set TORCH_CUDA_ARCH_LIST=5.2+PTX;6.0;6.1+PTX;7.5;8.0;8.6;8.9+PTX

@REM This command will set PATH environment variable.
@REM 该行命令会配置 PATH 环境变量。
set PATH=%PATH%;%~dp0\python_embeded\Scripts

@REM This command will let the .pyc files to be stored in one place.
@REM 该行命令会使 .pyc 文件集中保存在一处。
set PYTHONPYCACHEPREFIX=%~dp0\pycache

@REM This command will copy u2net.onnx to user's home path, to skip download at first start.
@REM 该行命令会复制 u2net.onnx 到用户主目录下,以免启动时还需下载。
IF NOT EXIST "%USERPROFILE%\.u2net\u2net.onnx" (
IF EXIST ".\extras\u2net.onnx" (
mkdir "%USERPROFILE%\.u2net" 2>nul
Expand All @@ -31,7 +25,6 @@ IF NOT EXIST "%USERPROFILE%\.u2net\u2net.onnx" (
)

@REM If you don't want the browser to open automatically, add " --disable-auto-launch" (without quotation marks) to the end of the line below.
@REM 如果不想要 ComfyUI 启动后自动打开浏览器,添加" --disable-auto-launch"(不含引号)到下行末尾。
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build

pause
Empty file.
38 changes: 38 additions & 0 deletions attachments/中文脚本/run_cn.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@REM 如需配置代理,编辑下两行命令,并取消注释(移除行首的 'rem ')。
rem set HTTP_PROXY=http://localhost:1081
rem set HTTPS_PROXY=http://localhost:1081

@REM 如需配置 PIP 与 HuggingFace Hub 镜像,编辑下两行。
set PIP_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
set HF_ENDPOINT=https://hf-mirror.com

@REM 依照下表,修改为你的 GPU 对应架构,以节约 JIT 编译 PyTorch C++ 扩展的时间:
@REM 'Pascal', '6.0;6.1+PTX'
@REM 'Volta+Tegra', '7.2'
@REM 'Volta', '7.0+PTX'
@REM 'Turing', '7.5+PTX'
@REM 'Ampere+Tegra', '8.7'
@REM 'Ampere', '8.0;8.6+PTX'
@REM 'Ada', '8.9+PTX'
@REM 'Hopper', '9.0+PTX'
set TORCH_CUDA_ARCH_LIST=5.2+PTX;6.0;6.1+PTX;7.5;8.0;8.6;8.9+PTX

@REM 该行命令会配置 PATH 环境变量。
set PATH=%PATH%;%~dp0\python_embeded\Scripts

@REM 该行命令会使 .pyc 文件集中保存在一处。
set PYTHONPYCACHEPREFIX=%~dp0\pycache

@REM 该命令会复制 u2net.onnx 到用户主目录下,以免启动时还需下载。
IF NOT EXIST "%USERPROFILE%\.u2net\u2net.onnx" (
IF EXIST ".\extras\u2net.onnx" (
mkdir "%USERPROFILE%\.u2net" 2>nul
copy ".\extras\u2net.onnx" "%USERPROFILE%\.u2net\u2net.onnx"
)
)

@REM 如果不想要 ComfyUI 启动后自动打开浏览器,添加" --disable-auto-launch"(不含引号)到下行末尾。
@REM 如果用 40 系显卡,可添加" --fast"
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build

pause
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
# 注意:Windows 下运行需要安装 Git 并在安装时选择 Git Bash(默认)

set -e

# 如果希望“尝试更新但不强制”,删除 git reset 行以避免还原本地变更
function change_url_or_pull () {
git_remote_url=$(git -C "$1" remote get-url origin) ;

if [[ $git_remote_url =~ ^(https:\/\/ghp\.ci\/)(.*)(\.git)$ ]]; then
echo "正在更新: $1" ;
git -C "$1" reset --hard ;
git -C "$1" pull --ff-only ;
echo "更新完成: $1" ;
elif [[ $git_remote_url =~ ^(https:\/\/github\.com\/)(.*)(\.git)$ ]]; then
echo "正在修改URL并更新: $1" ;
git -C "$1" reset --hard ;
git -C "$1" remote set-url origin "https://ghp.ci/$git_remote_url" ;
git -C "$1" pull --ff-only ;
echo "更新完成: $1" ;
fi ;
}

change_url_or_pull ComfyUI

# 这里使用 & 将任务置入后台,以实现多线程,并等待全部任务完成
cd ./ComfyUI/custom_nodes
for D in *; do
if [ -d "${D}" ]; then
change_url_or_pull "${D}" &
fi
done

wait $(jobs -p)

exit 0

0 comments on commit de441ec

Please sign in to comment.