背景
自己用的是nVidia Tesla P40,垃圾佬專屬卡
使用下面的由YanWenKun提供的ComfyUI-3D-Pack預安裝環境,但在本地編譯pytorch3d這一步出錯,后面有出錯信息,如果有和我一樣的卡一樣的問題,參看此文的解決方法
老版本的ComfyUI-3D-Pack預集成包
https://github.com/YanWenKun/ComfyUI-Windows-Portable
2024/12/14后切換到新倉庫
https://github.com/YanWenKun/Comfy3D-WinPortable
我使用的預集成包的版本是2025/1/21
https://github.com/YanWenKun/Comfy3D-WinPortable/releases
解壓后目錄結構如下:
其中的python_standalone目錄就是預安裝完的庫,包括獨立的python環境
對于首次需要本地編譯的TORCH_CUDA_ARCH_LIST的參數,
我的Tesla P40查顯卡根據架構編號查資料需要設置為6.1,和bat文件內默認的設置相同
set TORCH_CUDA_ARCH_LIST=6.1
架構編號查看鏈接如下:
https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
在我的3070上按下面B站UP主啦啦啦的小黃瓜詳細的步驟是可以成功的,但是P40就一直在編譯pytorch3d的部分失敗
3070的根據架構編譯參數是8.6
無奈只能自己用anaconda重新構建一個python環境,這樣可以方便的用于不同python環境版本的環境切換
編譯pytorch3d時的錯誤信息如下:
出錯信息
最終編譯出錯,導致comyui-3d-pack import failed,其他幾個必須本地編譯的庫都可以正常
ComfyUI-3D-Pack節點加載失敗
解決思路
步驟1、獲取預安裝包的python_standalone里的python環境,確定所需要的每一個python庫的版本
方法是在解壓后的預安裝環境中使用 python -m pip list > requirement.txt
導出只有版本號
使用 python -m pip freeze > requirement.txt
導出,還帶有預安裝環境構建時的安裝方式
步驟2、使用anaconda構建一個完全相同的python環境
將所有的python庫分成如下幾種安裝方式,按順序在conda環境中進行安裝:
- 直接pip install 庫==版本號 方式安裝的
- 需要添加cuda版本進行選擇安裝方式 安裝命令最后需要加上相應的torch cuda鏈接的
- 使用預構建包 whl文件安裝的
- 必須本機編譯安裝的(構造包里extra目錄下的除 pytorch3d外的5個)
幾個關鍵的版本號
- Python – 3.12.8
- Pytorch – 2.5.1
- Cuda – 12.4
- xformers – 0.0.29.post1
本文基礎
需要在操作系統中已經成功安裝完成如下環境,這部分內容不在本文討論范圍
-
cuda 12.4
-
cudnn 復制庫函數到上面的cuda目錄
-
VS build環境 包括VC++庫 WinSDK
-
anaconda環境 相當于自動包括了所有的python版本
系統環境需要注意的幾點
-
顯卡驅動cuda版本可以高于用的cuda庫的版本
-
如果需要安裝多個cuda庫的版本,從最低版本的開始安裝
-
cudnn需要驗證郵箱,B站上有提供百度網盤下載,直接目錄覆蓋cuda即可
程序員小袁
https://www.bilibili.com/video/BV1eBRvYKEXS/ -
我使用的是YanWenKun 2025/1/25的版本,git上下載很困難,容易斷線還不能續傳,使用了B站UP
啦啦啦的小黃瓜
https://www.bilibili.com/video/BV1cPPqe6Egb/
提供的夸克盤
https://pan.quark.cn/s/ef8c64027412
使用conda創建環境的步驟
我安裝的是anacoda
https://www.anaconda.com/download
Anaconda3-2025.06-0-Windows-x86_64.exe
conda環境切換,回到上一個環境
conda deactivate
–如果需要刪除舊的conda env
conda env remove -n pytorch3d_replica -y
創建conda env 指定python版本為3.12.8,按照ComfyUI-3D-Pack對python版本的要求一致
python 3.12.8 torch2.5.1 cuda12.4
conda create -n ComfyUI-3D-Pack python=3.12.8 -y
conda activate ComfyUI-3D-Pack
E:
cd E:\ComfyUI-ommh\env\
–安裝可以直接pip install的包,限定特定版本,會沖突的后面再用單獨的命令安裝,兩個命令選一個
pre_requirement.txt 文件是我導出的所有可以直接用pip install 方式安裝的python包
從原始導出包中去掉了含cuda的,使用wheel的,通過git+http://下載的,需要編譯的(尤其是pytorch3d)
pip install -r pre_requirement.txt --force-reinstall -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install -r pre_requirement.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
由預編譯WHL包安裝的 全部共6個 文末有提供下載
其中4個從github下載的whl
dlib @ https://github.com/eddiehe99/dlib-whl/releases/download/v19.24.6-alpha/dlib-19.24.6-cp312-cp312-win_amd64.whl#sha256=69f7cad674c25ab6784d76225a5d3f2f0827528ca228ec3eb3da8f7b8c8e3fd1
texture_baker @ https://github.com/YanWenKun/Comfy3D-WinPortable/releases/download/r7-wheels/texture_baker-0.0.1-cp312-cp312-win_amd64.whl#sha256=e5fe916b25281ec0ef9f8016339bfa32358772253c7b17344b8f38f193afece8
triton @ https://github.com/woct0rdho/triton-windows/releases/download/v3.1.0-windows.post7/triton-3.1.0-cp312-cp312-win_amd64.whl#sha256=d713dfad3672f0ff36bcbe37e73019f95be70de61056b9d178419dba6886f90c
uv_unwrapper @ https://github.com/YanWenKun/Comfy3D-WinPortable/releases/download/r7-wheels/uv_unwrapper-0.0.1-cp312-cp312-win_amd64.whl#sha256=36135e16d051ec44efb1be39f60e1b767faf4550c98848513635410790292519
其中2個從Comfy3D-WinPortable下載預編譯wheel 需要根據python版本 torch版本 cuda版本進行選擇
下載地址
https://github.com/MrForExample/Comfy3D_Pre_Builds/tree/main/_Build_Wheels/_Wheels_win_py312_torch2.5.1_cu124
kiui @ file:///D:/a/Comfy3D-WinPortable/Comfy3D-WinPortable/pt25-cu124/Comfy3D_Pre_Builds/_Build_Wheels/_Wheels_win_py312_torch2.5.1_cu124/kiui-0.2.14-py3-none-any.whl#sha256=6276853933b6f47e0fd3d0c80b3108357dcbd373a3f14766c5485963302825c8
nvdiffrast @ file:///D:/a/Comfy3D-WinPortable/Comfy3D-WinPortable/pt25-cu124/Comfy3D_Pre_Builds/_Build_Wheels/_Wheels_win_py312_torch2.5.1_cu124/nvdiffrast-0.3.3-py3-none-any.whl#sha256=245c0cb214c2502841f5c6f8f269b7850c07b535231e7b23de67ed3ddfe1e395
首先安裝nvdiffrast
nvdiffrast需要的numpy等級高需要先安裝 然后降回1.26.4 重裝別的包
cd .\wheel
pip install --force-reinstall nvdiffrast-0.3.3-py3-none-any.whl
裝完nvdiffrast會報錯,因為0.3.3的nvdiffrast會導致numpy版本升級到2,報錯的信息為部分lib需要numpy版本為1
其次重裝對numpy版本要求為1.26.4的包
pip install --force-reinstall numpy==1.26.4
pip install gpytoolbox==0.3.3
pip install numba==0.61.0
最后安裝剩下的5個預安裝包,通過在預安裝的環境下使用python -m pip freeze > requirements.txt導出
pip install --force-reinstall dlib-19.24.6-cp312-cp312-win_amd64.whl
pip install --force-reinstall kiui-0.2.14-py3-none-any.whl
pip install --force-reinstall texture_baker-0.0.1-cp312-cp312-win_amd64.whl
pip install --force-reinstall triton-3.1.0-cp312-cp312-win_amd64.whl
pip install --force-reinstall uv_unwrapper-0.0.1-cp312-cp312-win_amd64.whl
不需要本地重新編譯的,可以直接從git通過pip install進行安裝
pip install git+https://github.com/WASasquatch/cstr.git@0520c29a18a7a869a6e5983861d6f7a4c86f8e9b
pip install git+https://github.com/WASasquatch/ffmpy.git@f000737698b387ffaeab7cd871b0e9185811230d
pip install git+https://github.com/WASasquatch/img2texture.git@d6159abea44a0b2cf77454d3d46962c8b21eb9d3
pip install git+https://github.com/EasternJournalist/utils3d.git@3e124377f4adde34e443804cd44fb1d4bbb88ac0
–安裝完成后的版本號
cstr 0.1.0 @ git+https://github.com/WASasquatch/cstr@0520c29a18a7a869a6e5983861d6f7a4c86f8e9b
ffmpy 0.3.0 @ git+https://github.com/WASasquatch/ffmpy.git@f000737698b387ffaeab7cd871b0e9185811230d
img2texture 1.0.6 @ git+https://github.com/WASasquatch/img2texture.git@d6159abea44a0b2cf77454d3d46962c8b21eb9d3
utils3d 0.0.2 @ git+https://github.com/EasternJournalist/utils3d.git@3e124377f4adde34e443804cd44fb1d4bbb88ac0
需要命令行選擇CUDA版本進行安裝的 在這里會把torch版本降下來 前面安裝完后 torch是2.8
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 xformers==0.0.29.post1 -f https://mirrors.aliyun.com/pytorch-wheels/cu124pip install torch-scatter -f https://data.pyg.org/whl/torch-2.5.1+cu124.html
pip install torch-scatter -f https://mirrors.tuna.tsinghua.edu.cn/pytorch-geometric/whl/torch-2.5.1+cu124.htmlpip install kaolin==0.17.0 -f https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.5.1_cu124.html
pytorch3d庫
這個庫必須進行編譯安裝的,安裝順序在最后必須在上面2項的torch安裝完成后才能進行,關鍵步驟在此,至少我的P40只能通過這種方式才能順利編譯成功,環境參數里是使用的wheel庫安裝的,但批處理里是最后重編譯安裝的,這里我是通過git clone拉取的pytorch3d包,沒有使用壓縮包里的extra目錄下的
pytorch3d @ file:///D:/a/Comfy3D-WinPortable/Comfy3D-WinPortable/pt25-cu124/Comfy3D_Pre_Builds/_Build_Wheels/_Wheels_win_py312_torch2.5.1_cu124/pytorch3d-0.7.8-cp312-cp312-win_amd64.whl#sha256=656bcf0cb666301b06e1ee9ef52542fea2907b06f711858ba6b974729e4640a5
必須用下面的方法編譯安裝 checkout出的是0.7.8的版本
git clone https://github.com/facebookresearch/pytorch3d.git
cd ..\pytorch3d
git checkout 50f8efaset TORCH_CUDA_ARCH_LIST=6.1
set FORCE_CUDA=1
set CMAKE_ARGS=-DBUILD_opencv_world=ON -DWITH_CUDA=ON -DCUDA_FAST_MATH=ON -DWITH_CUBLAS=ON -DWITH_NVCUVID=ONpip install -e .
– 編譯安裝耗時極長,10幾分鐘
Running setup.py develop for pytorch3d-------------------------- ------------- 2/3 [pytorch3d]
其他5個包必須通過本地編譯安裝,最后安裝,這5個extras的包在extra目錄里直接復制出來使用
cd..
pip install --force-reinstall .\extras\pointnet2_ops
pip install --force-reinstall .\extras\simple-knn
pip install --force-reinstall .\extras\diff-gaussian-rasterization
pip install --force-reinstall .\extras\vox2seq
pip install .\extras\diffoctreerast
該組件用于 Triplane Gaussian
pointnet2_ops 3.0.0 @ file:///E:/ComfyUI-ommh/Comfy3D-WinPortable/20250121/Comfy3D_WinPortable/extras/pointnet2_ops
該組件用于 Gaussian Splatting
simple_knn 0.0.0 @ file:///E:/ComfyUI-ommh/Comfy3D-WinPortable/20250121/Comfy3D_WinPortable/extras/simple-knn
Differential Gaussian Rasterization
diff_gaussian_rasterization 0.0.0 @ file:///E:/ComfyUI-ommh/Comfy3D-WinPortable/20250121/Comfy3D_WinPortable/extras/diff-gaussian-rasterization
vox2seq
vox2seq 0.0.0 @ file:///E:/ComfyUI-ommh/Comfy3D-WinPortable/20250121/Comfy3D_WinPortable/extras/vox2seq
Differential Octree Rasterization
diffoctreerast 0.0.0 @ file:///E:/ComfyUI-ommh/Comfy3D-WinPortable/20250121/Comfy3D_WinPortable/extras/diffoctreerast
確保使用 NumPy 1.26.4的版本
pip install --force-reinstall numpy==1.26.4
修改啟動批處理程序的內容
在原來的啟動bat文件前增加如下:
@echo off
:: 替換為你的 Anaconda 安裝路徑
set ANACONDA_PATH=C:\ProgramData\anaconda3\condabin:: 調用 conda.bat 激活環境
call "%ANACONDA_PATH%\conda.bat" activate ComfyUI-3D-Pack
這里的ComfyUI-3D-Pack是我設置的conda環境的名字
由于使用了anaconda的環境,因此原始目錄里的 python_standalone目錄也可以刪除了
批處理里相應的部分也需要對應修改
還需要在原來的comfyui里增加運行參數:
--disable-cuda-malloc
這個必須增加,不然ComfyUI-3D-Pack依然導入失敗,其他參數看個人
成功加載了ComfyUI-3D-Pack的custom_nodes, 不再是imported failed
復制一個環境
命令行
conda create --name 新環境名稱 --clone 被復制環境名稱
即可,這樣一臺電腦上就可以共存多個python環境了,用于運行不同的需求的工作流變得很方便,可以在不同的端口上啟用對環境要求不相同的工作流
相關下載
文件下載
https://download.csdn.net/download/coldwind811201/91681082