Suitable for: "VS2022" "CUDA126" "Python 3.12" "ComfyUI: - v0.3.40" APEX edited "setup. py" code“
先说明:我是小白一个,在网上看了不少安装教程都没搞定,我试着用 DeepSeek 修改了代码,在我自己的环境中测度通过,暂时没有发现有什么问题!
用法:用这人文件替换原有的 setup.py 文件即可:
随便一个位置打开CMD下载APEX:git clone https://github.com/NVIDIA/apex
然后打开 APEX 文件夹,按住 SHIFT+右键 打开 CMD ,在ComfyUI 的 python_embeded 文件内把 python.exe 拖到 CMD 内 编辑命令:-m pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" .
我自己编辑时,除了VSC++外的问题,在 DeepSeek 的回答中解决了!
这是我在编辑时的依赖错误:
pip._vendor.pyproject_hooks._impl.BackendUnavailable: Cannot import 'flit_core.buildapi' error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully. │ exit code: 2 ╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip. full command: 'F:\ComfyUI_windows_portable\python_embeded\python.exe' 'F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\pip_pip-runner_.py' install --ignore-installed --no-user --prefix 'D:\Temp\pip-build-env-z5e_lo_2\overlay' --no-warn-script-location --disable-pip-version-check --no-compile --target '' -v --no-binary :all: --only-binary :none: -i https://pypi.tuna.tsinghua.edu.cn/simple/ -- setuptools wheel cwd: [inherit] Installing build dependencies ... error error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully. │ exit code: 2 ╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
这个错误表明在安装构建依赖项时出现了问题,特别是与 flit_core.buildapi 相关的导入失败。以下是解决这个问题的步骤:
1.可能的原因和解决方案: pip版本过旧: 运行以下命令升级pip:
python -m pip install --upgrade setuptools wheel
2.缺少构建工具: 确保已安装 setuptools 和 wheel 升级或安装:python -m pip install --upgrade setuptools wheel
3。flit_core包问题: 尝试单独安装 flit_core: python -m pip install flit_core
4.虚拟环境问题:
如果使用虚拟环境,尝试创建一个新的虚拟环境: <BASH> python -m venv new_env source new_env/bin/activate # Linux/Mac new_env\Scripts\activate # Windows
5.使用清华镜像源安装:
明确指定使用清华镜像源: <BASH> python -m pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ --upgrade pip setuptools wheel flit_core 检查Python环境:
-
确保你使用的是正确的Python解释器路径,特别是当系统中有多个Python安装时。 清理缓存并重试:
python -m pip cache purge python -m pip install --force-reinstall --no-cache-dir
7.如果问题仍然存在: 尝试使用 --no-use-pep517 标志:
8.或者直接下载whl文件手动安装:
9.这个错误通常与构建环境配置有关,按照上述步骤操作后应该能够解决问题。如果仍有疑问,可以提供更多上下文信息以便进一步诊断。
it is helpful. it is a way to install apex on windows11