Buckets:
| # ComponentsManager | |
| > [!WARNING] | |
| > [ComponentsManager](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager) は現在も開発が進行中で、API が変更される可能性があります。 | |
| [ComponentsManager](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager) は、Modular Diffusers 向けのモデルレジストリおよび管理システムです。モデルの追加と追跡を行い、有用なメタデータ(モデルサイズ、デバイス配置、アダプター)を保存し、オフローディングをサポートします。 | |
| このガイドでは、[ComponentsManager](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager)を使用してコンポーネントとデバイスメモリを管理する方法について説明します。 | |
| ## パイプラインに接続 | |
| Create a [ComponentsManager](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager) and pass it to a [ModularPipeline](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline#diffusers.ModularPipeline) with either [from_pretrained()](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline#diffusers.ModularPipeline.from_pretrained) or [init_pipeline()](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline_blocks#diffusers.ModularPipelineBlocks.init_pipeline). | |
| ```py | |
| from diffusers import ModularPipeline, ComponentsManager | |
| import torch | |
| manager = ComponentsManager() | |
| pipe = ModularPipeline.from_pretrained("Tongyi-MAI/Z-Image-Turbo", components_manager=manager) | |
| pipe.load_components(dtype=torch.bfloat16) | |
| ``` | |
| ```py | |
| from diffusers import ModularPipelineBlocks, ComponentsManager | |
| import torch | |
| manager = ComponentsManager() | |
| blocks = ModularPipelineBlocks.from_pretrained("diffusers/Florence2-image-Annotator", trust_remote_code=True) | |
| pipe= blocks.init_pipeline(components_manager=manager) | |
| pipe.load_components(dtype=torch.bfloat16) | |
| ``` | |
| pipeline によって読み込まれるコンポーネントは、マネージャーに自動的に登録されます。すぐにそれらをインスペクトできます。 | |
| ## コンポーネントの検査 | |
| [ComponentsManager](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager) を出力すると、クラス、デバイス配置、dtype、メモリサイズ、ロード ID を含む、登録されたすべてのコンポーネントを確認できます。 | |
| 以下の出力は、上記の`from_pretrained`の例に対応しています。 | |
| ```py | |
| Components: | |
| ============================================================================================================================= | |
| Models: | |
| ----------------------------------------------------------------------------------------------------------------------------- | |
| Name_ID | Class | Device: act(exec) | Dtype | Size (GB) | Load ID | |
| ----------------------------------------------------------------------------------------------------------------------------- | |
| text_encoder_140458257514752 | Qwen3Model | cpu | torch.bfloat16 | 7.49 | Tongyi-MAI/Z-Image-Turbo|text_encoder|null|null | |
| vae_140458257515376 | AutoencoderKL | cpu | torch.bfloat16 | 0.16 | Tongyi-MAI/Z-Image-Turbo|vae|null|null | |
| transformer_140458257515616 | ZImageTransformer2DModel | cpu | torch.bfloat16 | 11.46 | Tongyi-MAI/Z-Image-Turbo|transformer|null|null | |
| ----------------------------------------------------------------------------------------------------------------------------- | |
| Other Components: | |
| ----------------------------------------------------------------------------------------------------------------------------- | |
| ID | Class | Collection | |
| ----------------------------------------------------------------------------------------------------------------------------- | |
| scheduler_140461023555264 | FlowMatchEulerDiscreteScheduler | N/A | |
| tokenizer_140458256346432 | Qwen2Tokenizer | N/A | |
| ----------------------------------------------------------------------------------------------------------------------------- | |
| ``` | |
| このテーブルでは、モデル(デバイス、dtype、メモリ情報を含む)と、スケジューラーやトークナイザーなどの他のコンポーネントを別々に表示しています。モデルに LoRA アダプター、IP-Adapter、または量子化が適用されている場合、その情報は下部の追加セクションに表示されます。 | |
| ## オフローディング | |
| [enable_auto_cpu_offload()](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.enable_auto_cpu_offload) メソッドは、どのパイプラインがモデルを使用しているかに関係なく、すべてのモデルで機能するグローバルなオフロード戦略です。有効化後は、コンポーネントの追加や削除時にデバイスの配置を気にする必要はありません。 | |
| ```py | |
| manager.enable_auto_cpu_offload(device="cuda") # or "mps", "xpu", "cpu" | |
| ``` | |
| すべてのモデルはCPU上で開始され、[ComponentsManager](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager)はモデルが必要になる直前に適切なデバイスへ移動し、GPUメモリが不足している場合は他のモデルをCPUへ戻します。 | |
| オフロードを無効にするには、[disable_auto_cpu_offload()](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.disable_auto_cpu_offload)を呼び出します。 | |
| ```py | |
| manager.disable_auto_cpu_offload() | |
| ``` | |
Xet Storage Details
- Size:
- 5.87 kB
- Xet hash:
- 6759e87eec35283be9ba8c49f6fe9acc2a8526eb6333463c0ff15412d5837036
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.