Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to torch 13 #175

Merged
merged 4 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions examples/stable_diffusion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,12 @@ This folder contains starter code for finetuning Stable Diffusion. You can easil
## Clone the repo and install requirements

```bash
git clone https://github.com/mosaicml/examples.gitcd examples/
git clone https://github.com/mosaicml/examples.git
cd examples
pip install -e ".[stable-diffusion]"
cd examples/stable_diffusion
```
## Optionally, install xformers
xformers contains faster, more memory effecient transformer layers. But can take a while to install.

```
pip install ninja # Faster xformers install
pip install git+https://github.com/facebookresearch/xformers.git@3df785ce54114630155621e2be1c2fa5037efa27#egg=xformers
```
## Train the model
```
composer main.py yamls/finetune.yaml
Expand Down
9 changes: 4 additions & 5 deletions examples/stable_diffusion/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# --------- pytorch --------- #
torch>=1.12.0
torchvision>=0.11.0
torch>=1.13.0
torchvision>=0.12.0
mosaicml[all]>=0.12.1,<0.13

# --------- others --------- #
Expand All @@ -10,6 +10,5 @@ omegaconf
diffusers[torch]==0.11.1
transformers[torch]==4.25.1

# -------- optional -------- #
# ninja # Faster xformers install
# git+https://github.com/facebookresearch/xformers.git@3df785ce54114630155621e2be1c2fa5037efa27#egg=xformers #xformers
# -------- xformers -------- #
mvpatel2000 marked this conversation as resolved.
Show resolved Hide resolved
xformers
2 changes: 1 addition & 1 deletion examples/stable_diffusion/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def build_dummy_stable_diffusion_model(model_name_or_path: str,
"""
unet = UNet2DConditionModel(**PretrainedConfig.get_config_dict(
model_name_or_path, subfolder='unet')[0])
if is_xformers_available():
if torch.cuda.is_available() and is_xformers_available():
unet.enable_xformers_memory_efficient_attention()
vae = AutoencoderKL(**PretrainedConfig.get_config_dict(model_name_or_path,
subfolder='vae')[0])
Expand Down
2 changes: 1 addition & 1 deletion examples/stable_diffusion/yamls/mcloud_run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ run_name: stable-diffusion-finetune
cluster: # Name of the cluster to use for this run
gpu_type: # Type of GPU to use
gpu_num: # Number of GPUs to use
image: mosaicml/pytorch:1.12.1_cu116-python3.9-ubuntu20.04
image: mosaicml/pytorch:1.13.1_cu117-python3.10-ubuntu20.04
integrations:
- integration_type: git_repo
git_repo: mosaicml/examples
Expand Down