Add Support for Python 3.11 and PyTorch 2.0 #295
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Raising some issues I found when running ControlNet with Python 3.11 and PyTorch 2.0. The changes required to run with these versions this are outlined below:
Fix 1:
Encountered a ValueError when running python tool_add_control_sd21.py ./models/v2-1_768-ema-pruned.ckpt ./models/control_sd21_ini.ckpt.
Error message:
Solution:
Implemented the fix from the following commit in HuggingFace's PyTorch Image Models repository:
huggingface/pytorch-image-models@a482365
Alternatively, you can use the pre-release version of timm by running pip install --pre timm.
Fix 2:
Encountered an ImportError for rank_zero_only from pytorch_lightning.utilities.distributed.
Replace:
With:
Fix 3:
remove dataloader_idx param in 'ImageLogger' and 'def on_train_batch_start(self, batch, batch_idx):'
Then you can train successfully with Python 3.11 and PyTorch 2.0, also added cpu core variable for more efficient data loading.