Skip to content

Commit

Permalink
Upgrade to torch 13 (#175)
Browse files Browse the repository at this point in the history
* upgrade to torch 13

* remove cd

* fix tests, force 113
  • Loading branch information
mvpatel2000 authored Feb 17, 2023
1 parent 1856596 commit 3eda8af
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
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 -------- #
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

0 comments on commit 3eda8af

Please sign in to comment.