Created
December 17, 2022 13:33
-
-
Save ynagatomo/b483bfe15b520724c55eaa6ec6ceef62 to your computer and use it in GitHub Desktop.
Console-output during converting CoreML-Stable-Diffusion models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Converting Stable Diffusion v2 models to CoreML models, Dec 17,2022 | |
# | |
# MacBook Air/M1/8GB memory, macOS 13.2 beta, Python 3.8 | |
# apple/ml-stable-diffusion v0.1.0 | |
# | |
(base) ynaga@YasuhitonoMacBook-Air ~ % conda activate coremlsd2_38 | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ~ % cd Temp | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air Temp % mkdir SD2ModelConvChunked | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air Temp % cd SD2ModelConvChunked | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air SD2ModelConvChunked % git clone https://github.com/apple/ml-stable-diffusion | |
Cloning into 'ml-stable-diffusion'... | |
remote: Enumerating objects: 142, done. | |
remote: Counting objects: 100% (45/45), done. | |
remote: Compressing objects: 100% (33/33), done. | |
remote: Total 142 (delta 19), reused 12 (delta 12), pack-reused 97 | |
Receiving objects: 100% (142/142), 9.08 MiB | 3.41 MiB/s, done. | |
Resolving deltas: 100% (42/42), done. | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air SD2ModelConvChunked % cd ml-stable-diffusion | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % pip install -e . | |
Obtaining file:///Users/ynaga/Temp/SD2ModelConvChunked/ml-stable-diffusion | |
Preparing metadata (setup.py) ... done | |
Requirement already satisfied: coremltools>=6.1 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from python-coreml-stable-diffusion==0.1.0) (6.1) | |
Requirement already satisfied: diffusers[torch] in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from python-coreml-stable-diffusion==0.1.0) (0.9.0) | |
Requirement already satisfied: torch in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from python-coreml-stable-diffusion==0.1.0) (1.13.0) | |
Requirement already satisfied: transformers in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from python-coreml-stable-diffusion==0.1.0) (4.25.1) | |
Requirement already satisfied: scipy in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from python-coreml-stable-diffusion==0.1.0) (1.9.3) | |
Requirement already satisfied: packaging in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from coremltools>=6.1->python-coreml-stable-diffusion==0.1.0) (21.3) | |
Requirement already satisfied: sympy in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from coremltools>=6.1->python-coreml-stable-diffusion==0.1.0) (1.11.1) | |
Requirement already satisfied: tqdm in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from coremltools>=6.1->python-coreml-stable-diffusion==0.1.0) (4.64.1) | |
Requirement already satisfied: protobuf<=4.0.0,>=3.1.0 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from coremltools>=6.1->python-coreml-stable-diffusion==0.1.0) (3.20.3) | |
Requirement already satisfied: numpy>=1.14.5 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from coremltools>=6.1->python-coreml-stable-diffusion==0.1.0) (1.23.5) | |
Requirement already satisfied: filelock in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (3.8.0) | |
Requirement already satisfied: huggingface-hub>=0.10.0 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (0.11.1) | |
Requirement already satisfied: regex!=2019.12.17 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (2022.10.31) | |
Requirement already satisfied: Pillow in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (9.3.0) | |
Requirement already satisfied: requests in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (2.28.1) | |
Requirement already satisfied: importlib-metadata in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (5.1.0) | |
Requirement already satisfied: accelerate>=0.11.0 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (0.15.0) | |
Requirement already satisfied: typing-extensions in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from torch->python-coreml-stable-diffusion==0.1.0) (4.4.0) | |
Requirement already satisfied: pyyaml>=5.1 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from transformers->python-coreml-stable-diffusion==0.1.0) (6.0) | |
Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from transformers->python-coreml-stable-diffusion==0.1.0) (0.13.2) | |
Requirement already satisfied: psutil in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from accelerate>=0.11.0->diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (5.9.4) | |
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from packaging->coremltools>=6.1->python-coreml-stable-diffusion==0.1.0) (3.0.9) | |
Requirement already satisfied: zipp>=0.5 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from importlib-metadata->diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (3.11.0) | |
Requirement already satisfied: charset-normalizer<3,>=2 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from requests->diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (2.1.1) | |
Requirement already satisfied: certifi>=2017.4.17 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from requests->diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (2022.9.24) | |
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from requests->diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (1.26.13) | |
Requirement already satisfied: idna<4,>=2.5 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from requests->diffusers[torch]->python-coreml-stable-diffusion==0.1.0) (3.4) | |
Requirement already satisfied: mpmath>=0.19 in /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages (from sympy->coremltools>=6.1->python-coreml-stable-diffusion==0.1.0) (1.2.1) | |
Installing collected packages: python-coreml-stable-diffusion | |
Running setup.py develop for python-coreml-stable-diffusion | |
Successfully installed python-coreml-stable-diffusion-0.1.0 | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % huggingface-cli login | |
_| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_| | |
_| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| | |
_|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_| | |
_| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| | |
_| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_| | |
To login, `huggingface_hub` now requires a token generated from https://huggingface.co/settings/tokens . | |
Token: | |
Add token as git credential? (Y/n) Y | |
Traceback (most recent call last): | |
File "/Users/ynaga/miniforge3/envs/coremlsd2_38/bin/huggingface-cli", line 8, in <module> | |
sys.exit(main()) | |
File "/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/huggingface_hub/commands/huggingface_cli.py", line 47, in main | |
service.run() | |
File "/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/huggingface_hub/commands/user.py", line 117, in run | |
login() | |
File "/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/huggingface_hub/_login.py", line 91, in login | |
interpreter_login() | |
File "/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/huggingface_hub/_login.py", line 137, in interpreter_login | |
_login(token=token, add_to_git_credential=add_to_git_credential) | |
File "/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/huggingface_hub/_login.py", line 227, in _login | |
raise ValueError("Invalid token passed!") | |
ValueError: Invalid token passed! | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker -o sd2CoremlChunked --model-version stabilityai/stable-diffusion-2-base --bundle-resources-for-swift-cli --chunk-unet --attention-implementation SPLIT_EINSUM --compute-unit CPU_AND_NE | |
Torch version 1.13.0 has not been tested with coremltools. You may run into unexpected errors. Torch 1.12.1 is the most recent version that has been tested. | |
INFO:__main__:Initializing StableDiffusionPipeline with stabilityai/stable-diffusion-2-base.. | |
Fetching 12 files: 100%|█████████████████████████████████████████████████████████████████████████████████████| 12/12 [00:08<00:00, 1.41it/s] | |
INFO:__main__:Done. | |
INFO:__main__:Converting vae_decoder | |
/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/diffusers/models/resnet.py:109: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! | |
assert hidden_states.shape[1] == self.channels | |
/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/diffusers/models/resnet.py:122: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! | |
if hidden_states.shape[0] >= 64: | |
INFO:__main__:Converting vae_decoder to CoreML.. | |
Converting PyTorch Frontend ==> MIL Ops: 0%| | 0/353 [00:00<?, ? ops/s]WARNING:__main__:Casted the `beta`(value=0.0) argument of `baddbmm` op from int32 to float32 dtype for conversion! | |
Converting PyTorch Frontend ==> MIL Ops: 100%|████████████████████████████████████████████████████████▊| 352/353 [00:00<00:00, 2572.96 ops/s] | |
Running MIL Common passes: 100%|████████████████████████████████████████████████████████████████████████| 39/39 [00:00<00:00, 76.72 passes/s] | |
Running MIL FP16ComputePrecision pass: 100%|██████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1.79 passes/s] | |
Running MIL Clean up passes: 100%|██████████████████████████████████████████████████████████████████████| 11/11 [00:02<00:00, 4.53 passes/s] | |
INFO:__main__:Saved vae_decoder model to sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_vae_decoder.mlpackage | |
INFO:__main__:Saved vae_decoder into sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_vae_decoder.mlpackage | |
INFO:__main__:Converted vae_decoder | |
INFO:__main__:Converting unet | |
INFO:__main__:Attention implementation in effect: AttentionImplementations.SPLIT_EINSUM | |
INFO:__main__:Sample inputs spec: {'sample': (torch.Size([2, 4, 64, 64]), torch.float32), 'timestep': (torch.Size([2]), torch.float32), 'encoder_hidden_states': (torch.Size([2, 1024, 1, 77]), torch.float32)} | |
WARNING:python_coreml_stable_diffusion.unet:`use_linear_projection=True` is ignored! | |
INFO:__main__:JIT tracing.. | |
/Users/ynaga/Temp/SD2ModelConvChunked/ml-stable-diffusion/python_coreml_stable_diffusion/layer_norm.py:61: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! | |
assert inputs.size(1) == self.num_channels | |
INFO:__main__:Done. | |
INFO:__main__:Converting unet to CoreML.. | |
WARNING:coremltools:Tuple detected at graph output. This will be flattened in the converted model. | |
Converting PyTorch Frontend ==> MIL Ops: 0%| | 0/10456 [00:00<?, ? ops/s]WARNING:coremltools:Saving value type of int64 into a builtin type of int32, might lose precision! | |
Converting PyTorch Frontend ==> MIL Ops: 100%|████████████████████████████████████████████████████▉| 10454/10456 [00:01<00:00, 5229.09 ops/s] | |
Running MIL Common passes: 100%|████████████████████████████████████████████████████████████████████████| 39/39 [00:25<00:00, 1.54 passes/s] | |
Running MIL FP16ComputePrecision pass: 100%|██████████████████████████████████████████████████████████████| 1/1 [00:51<00:00, 51.62s/ passes] | |
Running MIL Clean up passes: 100%|██████████████████████████████████████████████████████████████████████| 11/11 [04:41<00:00, 25.56s/ passes] | |
AINFO:__main__:Saved unet model to sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage | |
INFO:__main__:Saved unet into sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage | |
INFO:__main__:Chunking unet in two approximately equal MLModels | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Loading model from sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Loading sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage took 8.0 seconds | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Loading MLModel object into a MIL Program object (including the weights).. | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Program loaded in 38.5 seconds | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage will chunked into two pieces. | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:The incision op: name=conv_128, type=conv, index=5519/11870 | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:First chunk size = 852.18 MB | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Second chunk size = 799.70 MB | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Loading MLModel object into a MIL Program object (including the weights).. | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Program loaded in 41.2 seconds | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Converting the two programs | |
Running MIL Common passes: 100%|████████████████████████████████████████████████████████████████████████| 39/39 [00:04<00:00, 7.96 passes/s] | |
Running MIL FP16ComputePrecision pass: 100%|██████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 21.63 passes/s] | |
Running MIL Clean up passes: 100%|██████████████████████████████████████████████████████████████████████| 11/11 [00:01<00:00, 6.61 passes/s] | |
zsh: killed python -m python_coreml_stable_diffusion.torch2coreml --convert-unet -o | |
/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown | |
warnings.warn('resource_tracker: There appear to be %d ' | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker -o sd2CoremlChunked --model-version stabilityai/stable-diffusion-2-base --bundle-resources-for-swift-cli --chunk-unet --attention-implementation SPLIT_EINSUM --compute-unit CPU_AND_NE | |
Torch version 1.13.0 has not been tested with coremltools. You may run into unexpected errors. Torch 1.12.1 is the most recent version that has been tested. | |
INFO:__main__:Initializing StableDiffusionPipeline with stabilityai/stable-diffusion-2-base.. | |
Fetching 12 files: 100%|██████████████████████████████████████████████████████████████████████████████████| 12/12 [00:00<00:00, 11607.85it/s] | |
INFO:__main__:Done. | |
INFO:__main__:Converting vae_decoder | |
INFO:__main__:`vae_decoder` already exists at sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_vae_decoder.mlpackage, skipping conversion. | |
INFO:__main__:Converted vae_decoder | |
INFO:__main__:Converting unet | |
INFO:__main__:`unet` already exists at sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage, skipping conversion. | |
INFO:__main__:Chunking unet in two approximately equal MLModels | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Loading model from sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Loading sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage took 7.5 seconds | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Loading MLModel object into a MIL Program object (including the weights).. | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Program loaded in 40.1 seconds | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage will chunked into two pieces. | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:The incision op: name=conv_128, type=conv, index=5519/11870 | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:First chunk size = 852.18 MB | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Second chunk size = 799.70 MB | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Loading MLModel object into a MIL Program object (including the weights).. | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Program loaded in 40.0 seconds | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Converting the two programs | |
Running MIL Common passes: 100%|████████████████████████████████████████████████████████████████████████| 39/39 [00:04<00:00, 8.14 passes/s] | |
Running MIL FP16ComputePrecision pass: 100%|██████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 23.76 passes/s] | |
Running MIL Clean up passes: 100%|██████████████████████████████████████████████████████████████████████| 11/11 [00:01<00:00, 5.88 passes/s] | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Conversion of first chunk done. | |
Running MIL Common passes: 100%|████████████████████████████████████████████████████████████████████████| 39/39 [00:04<00:00, 8.88 passes/s] | |
Running MIL FP16ComputePrecision pass: 100%|██████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 19.95 passes/s] | |
Running MIL Clean up passes: 100%|██████████████████████████████████████████████████████████████████████| 11/11 [00:01<00:00, 6.56 passes/s] | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Conversion of second chunk done. | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Saved chunks in sd2CoremlChunked with the suffix _chunk1.mlpackage and _chunk2.mlpackage | |
INFO:python_coreml_stable_diffusion.chunk_mlprogram:Done. | |
INFO:__main__:Converted unet | |
INFO:__main__:Converting text_encoder | |
INFO:__main__:Sample inputs spec: {'input_ids': (torch.Size([1, 77]), torch.float32)} | |
INFO:__main__:JIT tracing text_encoder.. | |
/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py:280: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! | |
if attn_weights.size() != (bsz * self.num_heads, tgt_len, src_len): | |
/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py:288: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! | |
if causal_attention_mask.size() != (bsz, 1, tgt_len, src_len): | |
/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py:320: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! | |
if attn_output.size() != (bsz * self.num_heads, tgt_len, self.head_dim): | |
INFO:__main__:Done. | |
INFO:__main__:Converting text_encoder to CoreML.. | |
WARNING:coremltools:Tuple detected at graph output. This will be flattened in the converted model. | |
Converting PyTorch Frontend ==> MIL Ops: 84%|██████████████████████████████████████████████▍ | 1225/1450 [00:00<00:00, 3455.08 ops/s]WARNING:coremltools:Saving value type of int64 into a builtin type of int32, might lose precision! | |
Converting PyTorch Frontend ==> MIL Ops: 100%|██████████████████████████████████████████████████████▉| 1448/1450 [00:00<00:00, 3068.93 ops/s] | |
Running MIL Common passes: 100%|████████████████████████████████████████████████████████████████████████| 39/39 [00:01<00:00, 35.27 passes/s] | |
Running MIL FP16ComputePrecision pass: 100%|██████████████████████████████████████████████████████████████| 1/1 [00:03<00:00, 3.15s/ passes] | |
Running MIL Clean up passes: 100%|██████████████████████████████████████████████████████████████████████| 11/11 [00:08<00:00, 1.30 passes/s] | |
zsh: killed python -m python_coreml_stable_diffusion.torch2coreml --convert-unet -o | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % /Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown | |
warnings.warn('resource_tracker: There appear to be %d ' | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker -o sd2CoremlChunked --model-version stabilityai/stable-diffusion-2-base --bundle-resources-for-swift-cli --chunk-unet --attention-implementation SPLIT_EINSUM --compute-unit CPU_AND_NE | |
Torch version 1.13.0 has not been tested with coremltools. You may run into unexpected errors. Torch 1.12.1 is the most recent version that has been tested. | |
INFO:__main__:Initializing StableDiffusionPipeline with stabilityai/stable-diffusion-2-base.. | |
Fetching 12 files: 100%|██████████████████████████████████████████████████████████████████████████████████| 12/12 [00:00<00:00, 11952.42it/s] | |
INFO:__main__:Done. | |
INFO:__main__:Converting vae_decoder | |
INFO:__main__:`vae_decoder` already exists at sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_vae_decoder.mlpackage, skipping conversion. | |
INFO:__main__:Converted vae_decoder | |
INFO:__main__:Converting unet | |
INFO:__main__:`unet` chunks already exist, skipping conversion. | |
INFO:__main__:Converted unet | |
INFO:__main__:Converting text_encoder | |
INFO:__main__:Sample inputs spec: {'input_ids': (torch.Size([1, 77]), torch.float32)} | |
INFO:__main__:JIT tracing text_encoder.. | |
/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py:280: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! | |
if attn_weights.size() != (bsz * self.num_heads, tgt_len, src_len): | |
/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py:288: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! | |
if causal_attention_mask.size() != (bsz, 1, tgt_len, src_len): | |
/Users/ynaga/miniforge3/envs/coremlsd2_38/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py:320: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! | |
if attn_output.size() != (bsz * self.num_heads, tgt_len, self.head_dim): | |
INFO:__main__:Done. | |
INFO:__main__:Converting text_encoder to CoreML.. | |
WARNING:coremltools:Tuple detected at graph output. This will be flattened in the converted model. | |
Converting PyTorch Frontend ==> MIL Ops: 86%|███████████████████████████████████████████████▍ | 1252/1450 [00:00<00:00, 4151.35 ops/s]WARNING:coremltools:Saving value type of int64 into a builtin type of int32, might lose precision! | |
Converting PyTorch Frontend ==> MIL Ops: 100%|██████████████████████████████████████████████████████▉| 1448/1450 [00:00<00:00, 4079.26 ops/s] | |
Running MIL Common passes: 100%|████████████████████████████████████████████████████████████████████████| 39/39 [00:00<00:00, 39.73 passes/s] | |
Running MIL FP16ComputePrecision pass: 100%|██████████████████████████████████████████████████████████████| 1/1 [00:02<00:00, 2.25s/ passes] | |
Running MIL Clean up passes: 100%|██████████████████████████████████████████████████████████████████████| 11/11 [00:08<00:00, 1.36 passes/s] | |
INFO:__main__:Saved text_encoder model to sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_text_encoder.mlpackage | |
INFO:__main__:Saved text_encoder into sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_text_encoder.mlpackage | |
INFO:__main__:Converted text_encoder | |
INFO:__main__:Converting safety_checker | |
WARNING:__main__:diffusers pipeline for stabilityai/stable-diffusion-2-base does not have a `safety_checker` module! `--convert-safety-checker` will be ignored. | |
INFO:__main__:Converted safety_checker | |
INFO:__main__:Bundling resources for the Swift CLI | |
INFO:__main__:Created sd2CoremlChunked/Resources for Swift CLI assets | |
INFO:__main__:Compiling sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_text_encoder.mlpackage | |
/Users/ynaga/Temp/SD2ModelConvChunked/ml-stable-diffusion/sd2CoremlChunked/Resources/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_text_encoder.mlmodelc/coremldata.bin | |
INFO:__main__:Compiled sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_text_encoder.mlpackage to sd2CoremlChunked/Resources/TextEncoder.mlmodelc | |
INFO:__main__:Compiling sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_vae_decoder.mlpackage | |
/Users/ynaga/Temp/SD2ModelConvChunked/ml-stable-diffusion/sd2CoremlChunked/Resources/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_vae_decoder.mlmodelc/coremldata.bin | |
INFO:__main__:Compiled sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_vae_decoder.mlpackage to sd2CoremlChunked/Resources/VAEDecoder.mlmodelc | |
INFO:__main__:Compiling sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage | |
/Users/ynaga/Temp/SD2ModelConvChunked/ml-stable-diffusion/sd2CoremlChunked/Resources/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlmodelc/coremldata.bin | |
INFO:__main__:Compiled sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet.mlpackage to sd2CoremlChunked/Resources/Unet.mlmodelc | |
INFO:__main__:Compiling sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet_chunk1.mlpackage | |
/Users/ynaga/Temp/SD2ModelConvChunked/ml-stable-diffusion/sd2CoremlChunked/Resources/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet_chunk1.mlmodelc/coremldata.bin | |
INFO:__main__:Compiled sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet_chunk1.mlpackage to sd2CoremlChunked/Resources/UnetChunk1.mlmodelc | |
INFO:__main__:Compiling sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet_chunk2.mlpackage | |
/Users/ynaga/Temp/SD2ModelConvChunked/ml-stable-diffusion/sd2CoremlChunked/Resources/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet_chunk2.mlmodelc/coremldata.bin | |
INFO:__main__:Compiled sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_unet_chunk2.mlpackage to sd2CoremlChunked/Resources/UnetChunk2.mlmodelc | |
WARNING:__main__:sd2CoremlChunked/Stable_Diffusion_version_stabilityai_stable-diffusion-2-base_safety_checker.mlpackage not found, skipping compilation to SafetyChecker.mlmodelc | |
INFO:__main__:Downloading and saving tokenizer vocab.json | |
INFO:__main__:Done | |
INFO:__main__:Downloading and saving tokenizer merges.txt | |
INFO:__main__:Done | |
INFO:__main__:Bundled resources for the Swift CLI | |
(coremlsd2_38) ynaga@YasuhitonoMacBook-Air ml-stable-diffusion % ls sd2CoremlChunked/Resources | |
TextEncoder.mlmodelc UnetChunk1.mlmodelc VAEDecoder.mlmodelc vocab.json | |
Unet.mlmodelc UnetChunk2.mlmodelc merges.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment