-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
How I got this repo (entirely) running with pip (no conda) on M1 Mac #302
Comments
Repo was working before the
The |
@ricardobeat would updating that import to use typing_extensions help, it should backport though, yes, it is quite confusing if you should use 3.9 or 3.10, just generally. I tried to use 3.9 and ran into trouble installing |
I ran into the
|
Same. Will submit PR for this. |
@jordanfbrown Where should I put this? I tried at various places in [scripts/dream.py] to no avail. |
for the |
its in the k-diffusion dependency in "src/k-diffusion/k_diffusion/sampling.py" |
As @yousifa mentioned, it's coming from this line: https://github.com/Birch-san/k-diffusion/blob/mps/k_diffusion/sampling.py#L10 Full stack trace on Python 3.9:
|
It seems that this typing import is being added when installing the dependency as it is not in the k-diffusion repo either in sampling.py |
opened PR in the upstream repo: Birch-san/k-diffusion#1 could also try replacing the dep in
|
maybe we should add a patch to be applied after dependency install on this repo and pin k-diffusion, its at head right now |
@stillmatic with this edit, I just get an infinite spinner on my PIP block in
PEBKAC? Did I mess up the edit? |
Just tried it. Worked for me. Maybe you messed up the formatting in the file. |
I'm also observing this behavior as well. |
Have you tried adding the changes in the file after installation? |
Not sure if I follow? The change in question is in a list of pip dependencies, so it wouldn't be effective unless it was applied before attempting to install those dependencies. |
After normal installation, go to the file "src/k-diffusion/k_diffusion/sampling.py" change: to:
|
I don't understand conda or pip well enough to identify root cause, but there are some reports of conda getting stuck on installing pip dependencies. @stillmatic's diff looks pretty innocuous, but I guess there could be some issue with introducing At any rate, the workaround I came up with is as follows:
|
@jeffomatic getting 'no matches found' on #3. Maybe that's the root of my issue? BTW, to all, wanted to mention I appreciate all the lively helpful feedback in this thread. A+. |
Here's what's working for me right now:
@irrg Probably a moot point given the above, but I wasn't able to repro the "no matches found" issue you ran into. Here's what it looks like from my terminal:
|
@stillmatic some of the steps have been replicated, and work quite well on an M1 mac: |
@FrenchBen yepp- that's a great guide and I followed it to get setup on their fork, this is what I had to do to similarly get this fork running. |
I'm using stable-diffusion on a 2022 Macbook M2 Air with 24 GB unified memory. I see this taking about 2.0s/it. I've moved many deps from pip to conda-forge, to take advantage of the precompiled binaries. Some notes for Mac users, since I've seen a lot of confusion about this: One doesn't need the `apple` channel to run this on a Mac-- that's only used by `tensorflow-deps`, required for running tensorflow-metal. For that, I have an example environment.yml here: https://developer.apple.com/forums/thread/711792?answerId=723276022#723276022 However, the `CONDA_ENV=osx-arm64` environment variable *is* needed to ensure that you do not run any Intel-specific packages such as `mkl`, which will fail with [cryptic errors](CompVis/stable-diffusion#25 (comment)) on the ARM architecture and cause the environment to break. I've also added a comment in the env file about 3.10 not working yet. When it becomes possible to update, those commands run on an osx-arm64 machine should work to determine the new version set. Here's what a successful run of dream.py should look like: ``` $ python scripts/dream.py --full_precision SIGABRT(6) ↵ 08:42:59 * Initializing, be patient... Loading model from models/ldm/stable-diffusion-v1/model.ckpt LatentDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.52 M params. making attention of type 'vanilla' with 512 in_channels Working with z of shape (1, 4, 32, 32) = 4096 dimensions. making attention of type 'vanilla' with 512 in_channels Using slower but more accurate full-precision math (--full_precision) >> Setting Sampler to k_lms model loaded in 6.12s * Initialization done! Awaiting your command (-h for help, 'q' to quit) dream> "an astronaut riding a horse" Generating: 0%| | 0/1 [00:00<?, ?it/s]/Users/corajr/Documents/lstein/ldm/modules/embedding_manager.py:152: UserWarning: The operator 'aten::nonzero' is not currently supported on the MPS backend and will fall back to run on the CPU. This may have performance implications. (Triggered internally at /Users/runner/work/_temp/anaconda/conda-bld/pytorch_1662016319283/work/aten/src/ATen/mps/MPSFallback.mm:11.) placeholder_idx = torch.where( 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [01:37<00:00, 1.95s/it] Generating: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [01:38<00:00, 98.55s/it] Usage stats: 1 image(s) generated in 98.60s Max VRAM used for this generation: 0.00G Outputs: outputs/img-samples/000001.1525943180.png: "an astronaut riding a horse" -s50 -W512 -H512 -C7.5 -Ak_lms -F -S1525943180 ```
Update: everything is working great
pip install -r requirements.txt; pip install -e .
PYTORCH_ENABLE_MPS_FALLBACK=1 python scripts/dream.py --full_precision -A plms --web
You should see a warning
>> cuda not available, using device mps
- this is good! On fully loaded M1 Max, this is 1.5 it/s on keuler or 3.91it/s on PLMS.I got various errors attempting to run the main repo as is (commit 3ee82d8), with pip install instead of conda install. this laptop doesn't have conda on it at all.
workaround is to setup a python env with 3.10 and update requirements.txt
also need to run
pip install -e .
to findldm
.this enables me to run scripts and get output:
python ./scripts/orig_scripts/txt2img.py --prompt "ocean" --ddim_steps 5 --n_samples 1 --n_iter 1
✨ ✨ ✨ ✨ (output isn't great, but it works!)
however,
dream.py
has trouble running, even with thefull_precision
flag. that shows some errors like:searching issues, I see that this is possibly due to hardcoded assumptions of CPU vs GPU (see #44 (comment)), internally somewhere the code expects a half-precision for GPU vs full-precision for CPU. since other scripts work but-- this is fixed in #319dream.py
doesn't work, is there somewhere indream.py
with similar hard coded assumptions that we need to update?everything runs great now on M1, though I have to set env var
PYTORCH_ENABLE_MPS_FALLBACK=1
. so, runningworks great!
The text was updated successfully, but these errors were encountered: