Skip to content

Commit

Permalink
get rid of pycache stuff and make work with windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gammagec committed Sep 26, 2022
1 parent c87b129 commit 25e5c25
Show file tree
Hide file tree
Showing 54 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
gen.bat
gen_ref.bat
train.bat
__pycache__
*/**/__pycache__
logs
2 changes: 1 addition & 1 deletion configs/stable-diffusion/v1-finetune_unfrozen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ data:
target: main.DataModuleFromConfig
params:
batch_size: 1
num_workers: 2
num_workers: 1
wrap: false
train:
target: ldm.data.personalized.PersonalizedBase
Expand Down
Binary file removed evaluation/__pycache__/clip_eval.cpython-36.pyc
Binary file not shown.
Binary file removed evaluation/__pycache__/clip_eval.cpython-38.pyc
Binary file not shown.
Binary file removed ldm/__pycache__/util.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/__pycache__/util.cpython-38.pyc
Binary file not shown.
Binary file removed ldm/data/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/data/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file removed ldm/data/__pycache__/base.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/data/__pycache__/base.cpython-38.pyc
Binary file not shown.
Binary file removed ldm/data/__pycache__/personalized.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/data/__pycache__/personalized.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ldm/models/__pycache__/autoencoder.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/models/__pycache__/autoencoder.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ldm/models/diffusion/__pycache__/ddim.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/models/diffusion/__pycache__/ddim.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file removed ldm/models/diffusion/__pycache__/ddpm.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/models/diffusion/__pycache__/ddpm.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file removed ldm/models/diffusion/__pycache__/plms.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/models/diffusion/__pycache__/plms.cpython-38.pyc
Binary file not shown.
Binary file removed ldm/modules/__pycache__/attention.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/modules/__pycache__/attention.cpython-38.pyc
Binary file not shown.
Binary file removed ldm/modules/__pycache__/ema.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/modules/__pycache__/ema.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ldm/modules/__pycache__/x_transformer.cpython-36.pyc
Binary file not shown.
Binary file removed ldm/modules/__pycache__/x_transformer.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion ldm/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def log_txt_as_img(wh, xc, size=10):
for bi in range(b):
txt = Image.new("RGB", wh, color="white")
draw = ImageDraw.Draw(txt)
font = ImageFont.truetype('data/DejaVuSans.ttf', size=size)
# Changed to work on Windows
font = ImageFont.load_default()
#font = ImageFont.truetype('data/DejaVuSans.ttf', size=size)
nc = int(40 * (wh[0] / 256))
lines = "\n".join(xc[bi][start:start + nc] for start in range(0, len(xc[bi]), nc))

Expand Down
10 changes: 6 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,6 @@ def on_train_epoch_start(self, trainer, pl_module):
lightning_config = config.pop("lightning", OmegaConf.create())
# merge trainer cli with config
trainer_config = lightning_config.get("trainer", OmegaConf.create())
# default to ddp
trainer_config["accelerator"] = "ddp"

This comment has been minimized.

Copy link
@AnujSaharan

AnujSaharan Sep 26, 2022

Hi - was running into errors with distributed training on 2 GPUs. Maybe a good idea to re-add line 611 in main.py here with a simple if statement to check num_gpus and set to ddp if > 1 and dp if < 1?

Alternatively, could just add accelerator to the lightning config, and leave it default to dp, so it's easier to flip distributed training on and off for people with 2 GPUs?
@gammagec @JoePenna

for k in nondefault_trainer_args(opt):
trainer_config[k] = getattr(opt, k)
if not "gpus" in trainer_config:
Expand Down Expand Up @@ -821,8 +819,12 @@ def divein(*args, **kwargs):

import signal

signal.signal(signal.SIGUSR1, melk)
signal.signal(signal.SIGUSR2, divein)

# Changed to work with windows
signal.signal(signal.SIGTERM, melk)
#signal.signal(signal.SIGUSR1, melk)
signal.signal(signal.SIGTERM, divein)
#signal.signal(signal.SIGUSR2, divein)

# run
if opt.train:
Expand Down

0 comments on commit 25e5c25

Please sign in to comment.