Skip to content

How to run on cpu? #219

@RiccardoRiglietti

Description

@RiccardoRiglietti

When running the script:

(ldm) user@user-Aspire-A317-51G:~/diffusion/stable-diffusion$ python scripts/img2img.py --prompt "A fantasy landscape, trending on artstation" --init-img start_for_fantasy.jpg --strength 0.8

I get the error:

RuntimeError: CUDA out of memory. Tried to allocate 114.00 MiB (GPU 0; 1.96 GiB total capacity; 1.31 GiB already allocated; 108.88 MiB free; 1.35 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Because I only have 2GB video ram. I can I tell the script to ignore the GPU as it is too small and use the CPU instead?

I tried reading the flags but cannot find the no_gpu or cpu flag.

(ldm) riccardo@riccardo-Aspire-A317-51G:~/diffusion/stable-diffusion$ python scripts/img2img.py --h

usage: img2img.py [-h] [--prompt [PROMPT]] [--init-img [INIT_IMG]] [--outdir [OUTDIR]] [--skip_grid]
                  [--skip_save] [--ddim_steps DDIM_STEPS] [--plms] [--fixed_code] [--ddim_eta DDIM_ETA]
                  [--n_iter N_ITER] [--C C] [--f F] [--n_samples N_SAMPLES] [--n_rows N_ROWS]
                  [--scale SCALE] [--strength STRENGTH] [--from-file FROM_FILE] [--config CONFIG]
                  [--ckpt CKPT] [--seed SEED] [--precision {full,autocast}]

optional arguments:
  -h, --help            show this help message and exit
  --prompt [PROMPT]     the prompt to render
  --init-img [INIT_IMG]
                        path to the input image
  --outdir [OUTDIR]     dir to write results to
  --skip_grid           do not save a grid, only individual samples. Helpful when evaluating lots of
                        samples
  --skip_save           do not save indiviual samples. For speed measurements.
  --ddim_steps DDIM_STEPS
                        number of ddim sampling steps
  --plms                use plms sampling
  --fixed_code          if enabled, uses the same starting code across all samples
  --ddim_eta DDIM_ETA   ddim eta (eta=0.0 corresponds to deterministic sampling
  --n_iter N_ITER       sample this often
  --C C                 latent channels
  --f F                 downsampling factor, most often 8 or 16
  --n_samples N_SAMPLES
                        how many samples to produce for each given prompt. A.k.a batch size
  --n_rows N_ROWS       rows in the grid (default: n_samples)
  --scale SCALE         unconditional guidance scale: eps = eps(x, empty) + scale * (eps(x, cond) -
                        eps(x, empty))
  --strength STRENGTH   strength for noising/unnoising. 1.0 corresponds to full destruction of
                        information in init image
  --from-file FROM_FILE
                        if specified, load prompts from this file
  --config CONFIG       path to config which constructs model
  --ckpt CKPT           path to checkpoint of model
  --seed SEED           the seed (for reproducible sampling)
  --precision {full,autocast}
                        evaluate at this precision

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions