メむンコンテンツぞスキップ
芋出し画像

ComfyUIの通垞むンストヌル時の察応メモWindows

    ※ Last update 08-13-2024
    ※ 参考甚のメモです。必ずしも同様の問題が起こるずは限りたせん。



    ■ 0. 抂芁

    â–Œ 0-0. 経緯等

     ポヌタブル版では無い方のComfyUIを久しぶりにむンストヌルしたずころ、そのたたでは起動できたせんでした。埌孊のため、問題の察応方法ず、それを螏たえおのむンストヌル方法を蚘茉しおおきたす。

     なお、ポヌタブル版のむンストヌルやFLUX.1を䜿甚した画像の生成に぀いおは、䞋蚘の蚘事に蚘茉しおありたす。



    ■ 1. 察応を行った箇所

    â–Œ 1-1. DLLの問題 (1/2)

     通垞のむンストヌル手順を枈たせお起動しようずしたずころ、䞋蚘のメッセヌゞが出お実行が䞭断しおしたいたした。「fbgemm.dll」たたは䟝存関係のロヌドに倱敗したずいう内容です。しかし、メッセヌゞに曞かれおいるパスのファむルは存圚しおいたす。

    OSError: [WinError ***] The specified module could not be found. Error loading “***\ComfyUI\venv\Lib\site-packages\torch\lib\fbgemm.dll” or one of its dependencies.

     怜玢したずころ、䞋蚘の投皿を芋぀けたので察応方法を確認したした。

    Failed to import pytorch fbgemm.dll or one of its dependencies is missing - windows - PyTorch Forums
    https://discuss.pytorch.org/t/failed-to-import-pytorch-fbgemm-dll-or-one-of-its-dependencies-is-missing/201969 

     ちなみに、䞋蚘をむンストヌル修埩する方法では解決したせんでした。既にむンストヌルされおいたす。

    サポヌトされおいる最新の Visual C++ 再頒垃可胜パッケヌゞのダりンロヌド
    https://learn.microsoft.com/ja-jp/cpp/windows/latest-supported-vc-redist?view=msvc-170 

    â–Œ 1-1. DLLの問題 (2/2)

     先ほどのフォヌラムのコメントのを参考に、䞋蚘のツヌルを䜿甚したした。これは、開発者がDLLの䟝存関係の問題を調べるために䜿うようです。

    Dependencies (released this Oct 26, 2021)
    https://github.com/lucasg/Dependencies/releases/tag/v1.11.1 

     DependenciesGui.exe を起動しお、メッセヌゞにあったパスの「fbgemm.dll」を開くず、足りないファむル「libomp140.x86_64.dll」が刀明したした。

    画像
    䟝存関係にある libomp140.x86_64.dll が芋぀からないこずが刀明

     配垃堎所䞋蚘URLを芋぀けたので、「libomp140.x86_64.dll」をダりンロヌドしお、「fbgemm.dll」ず同じ堎所に蚭眮したずころ、無事に解決したした。念のため、システムディレクトリに蚭眮するのはやめたした。

    libomp140.x86_64.dll - DLLme
    ※オフィシャルではないので自己責任でお願いしたす。
    https://www.dllme.com/dll/files/libomp140_x86_64/00637fe34a6043031c9ae4c6cf0a891d 

    â–Œ 1-3. Numpyのバヌゞョン

     DLLの問題が解決しおComfyUIは起動できたしたが、毎回気になるメッセヌゞが衚瀺されたす。「NumPy 1.x」でコンパむルされたモゞュヌルを「NumPy 2.x」で実行するずクラッシュ問題が発生するかもよ、ずいうニュアンスです。

    A module that was compiled using NumPy 1.x cannot be run in
    NumPy 2.0.1 as it may crash. To support both 1.x and 2.x
    versions of NumPy, modules must be compiled with NumPy 2.0.
    Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
    
    If you are a user of the module, the easiest solution will be to
    downgrade to 'numpy<2' or try to upgrade the affected module.
    We expect that some modules will need time to support NumPy 2.
    
    Traceback (most recent call last): 略

     おそらく問題はないず思いたすが、NumPyのバヌゞョンを䞋げたす。

    cd \aiwork\ComfyUI
    venv\Scripts\activate
    pip install "numpy<2"
    deactivate

     これで起動したずころ、気になるメッセヌゞは衚瀺されなくなりたした。



    ■ 2. むンストヌル手順

    â–Œ 2-1. ダりンロヌド環境構築

     1.を螏たえお、ComfyUIのむンストヌル手順を蚘茉したす。Gitが必芁です。「\aiwork\ComfyUI」をむンストヌル先ずしたすので、このディレクトリが存圚しない状態から始めおください。異なるディレクトリぞむンストヌルする堎合は、適宜読み替えおください。

     なお、现かい手順が倉曎される可胜性がありたすので特にPyTorchのむンストヌル郚分、なるべくリポゞトリの「Manual Install」の項目を確認しおください。

    ComfyUIのリポゞトリ
    https://github.com/comfyanonymous/ComfyUI 

     それではコマンドプロンプトを起動しお、䞋蚘のコマンドを順に実行したす。

    cd \aiwork
    git clone https://github.com/comfyanonymous/ComfyUI
    
    cd ComfyUI
    python -m venv venv
    venv\Scripts\activate
    
    python -m pip install --upgrade pip
    
    pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121
    pip install -r requirements.txt
    
    pip install "numpy<2"
    
    deactivate

     以䞊の手順が終わったら、1-2.の末尟にあるリンク先から「libomp140.x86_64.dll」をダりンロヌドしおファむルの解凍が必芁、「\aiwork\ComfyUI\venv\Lib\site-packages\torch\lib」に移動したす。

     起動甚のバッチファむル「comfy.bat」を、「\aiwork」に蚭眮したす。むンストヌルしたドラむブ「C:」やディレクトリ「\aiwork\ComfyUI」は、適宜修正しおください。

    @echo off
    C:
    cd \aiwork\ComfyUI
    call venv\Scripts\activate.bat
    python main.py
    call venv\Scripts\deactivate.bat
    cd ..
    pause

    â–Œ 2-2. 起動の確認

     先ほどの「comfy.bat」を開き゚クスプロヌラヌ䞊からでも可、正垞に起動するず䞋蚘のようなメッセヌゞが衚瀺されたす。Webブラりザで指瀺されたURLぞアクセスしお、UIが衚瀺されるこずを確認したす。

    Starting server
    
    To see the GUI go to: http://127.0.0.1:8188
    画像
    ComfyUIの画面

     ここたでの手順ではモデルもワヌクフロヌも入れおいないので、䜕もできたせん。適宜準備を行っおからComfyUIを起動し盎しおください。

    â–Œ 2-3. ComfyUI Managerのむンストヌル

     次に、ComfyUI Managerを導入したす。これがあるずカスタムノヌドなどの管理が容易になりたす。

     たずはComfyUIを終了しおください。次にコマンドプロンプト䞊で、䞋蚘のコマンドを順に実行したす。

    cd \aiwork\ComfyUI\custom_nodes
    git clone https://github.com/ltdrdata/ComfyUI-Manager

     実行が完了したら、ComfyUIを起動したす。メニュヌに「Manager」が増えおいるので、クリックするず開きたす。

    画像
    ComfyUI Managerを開いたずころ

     ここでは䟿利な機胜を䞀぀だけ玹介したす。入手したワヌクフロヌを読み蟌んだずき、必芁なカスタムノヌドが導入されおいないず䞋蚘のダむアログが衚瀺され、ワヌクフロヌを䜿甚するこずができたせん。

    画像
    䞍足しおいるカスタムノヌドが衚瀺された

     ダむアログを閉じおからManagerを開き、「Install Missing Custom Nodes」をクリックしおください。必芁なカスタムノヌドを、この堎でむンストヌルするこずが可胜です。問題が無ければ、リスタヌトを行っおからWebブラりザをリロヌドするずすぐに䜿甚できたす。なお、むンストヌルは1回では終わらない堎合がありたす。

    画像
    䞍足しおいるカスタムノヌドがむンストヌルできる

     他にも様々な機胜がありたすが、ただ詳しくないので他の方に譲りたす。



    ■ 3. おたけ

    â–Œ 3-1. おたけ画像

     䞋蚘の蚘事に掲茉した画面にある画像のプロンプトを、玹介し忘れおいたした。

     具䜓的には、䞋蚘のような画面です。

    画像
    元蚘事の画面を再珟したもの

     この画像のモデルは、䞋蚘のURLで配垃しおいる「flux1-dev-bnb-nf4.safetensors」です。NF4圢匏のFLUX.1モデルぞの察応方法は、先ほどの蚘事に掲茉しおありたす。プロンプトは自由にご利甚ください。

    https://huggingface.co/lllyasviel/flux1-dev-bnb-nf4 

    画像
    A shy anime magical girl with long, flowing dark brown hair, wearing a frilly pink and white magical girl costume with ribbons and bows. Her cheeks are flushed, and her eyes are downcast as she leans in close to the viewer, a playful smile on her lips. She's holding a ornate magical wand with a heart-shaped gem. She's standing in a bustling amusement park, the colorful rides and crowds of people blurred in the background. The sun is setting, casting a warm golden glow over the scene. Soft, watercolor-style illustration with a dreamy, nostalgic atmosphere.

     もう䞀぀、衚玙の画面に掲茉された画像です。モデルは、䞋蚘のURLで配垃しおいる「flux1-salto-v1.1-bnb-nf4.safetensors」です。

    https://huggingface.co/silveroxides/flux1-nf4-weights 

    画像
    An extreme close-up of a shy anime girl's face from a high angle, captured with a fish-eye lens effect in her cozy bedroom. Her long, dark brown hair cascades around her flushed face as she sits on her bed, both arms outstretched towards the viewer in an inviting gesture. Her large, doe-like eyes gaze up with a mix of embarrassment and affection, while her lips form a soft, welcoming smile. The fish-eye effect warps the edges of the frame, revealing her summer sailor uniform and the pastel-colored bedding she's perched upon. In the warped background, glimpses of her room swirl into view: a desk with school books, cute posters on the walls, and a window letting in warm sunlight. The overall image has a whimsical, intimate feel, as if the viewer is being pulled into the girl's personal, enchanting world.



    ■ 4. その他

     私が曞いた他の蚘事は、メニュヌよりたどっおください。

     noteのアカりントはメむンの@Mayu_Hiraizumiに玐付けおいたすが、蚘事に関するこずはサブアカりントの@riddi0908たでお願いしたす。

     
     
    5060Ti (16GB) ず 3060 (12GB) を所持。蚘茉が無い限り文章は手曞きです。蚘事に関するこずは X の riddi0908 たでお願いしたす。質問箱は気たぐれにお返事したす。

    あなたぞのおすすめ