mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
many updatedes to INSTALL_MAC.md
This commit is contained in:
parent
cd494c2f6c
commit
3c732500e7
@ -9,18 +9,21 @@ title: macOS
|
|||||||
- Patience
|
- Patience
|
||||||
- Apple Silicon or Intel Mac
|
- Apple Silicon or Intel Mac
|
||||||
|
|
||||||
Things have moved really fast and so these instructions change often and are
|
Things have moved really fast and so these instructions change often which makes
|
||||||
often out-of-date. One of the problems is that there are so many different ways
|
them outdated pretty fast. One of the problems is that there are so many
|
||||||
to run this.
|
different ways to run this.
|
||||||
|
|
||||||
We are trying to build a testing setup so that when we make changes it doesn't
|
We are trying to build a testing setup so that when we make changes it doesn't
|
||||||
always break.
|
always break.
|
||||||
|
|
||||||
How to (this hasn't been 100% tested yet):
|
## How to
|
||||||
|
|
||||||
First get the weights checkpoint download started - it's big:
|
(this hasn't been 100% tested yet)
|
||||||
|
|
||||||
1. Sign up at https://huggingface.co
|
First get the weights checkpoint download started since it's big and will take
|
||||||
|
some time:
|
||||||
|
|
||||||
|
1. Sign up at [huggingface.co](https://huggingface.co)
|
||||||
2. Go to the
|
2. Go to the
|
||||||
[Stable diffusion diffusion model page](https://huggingface.co/CompVis/stable-diffusion-v-1-4-original)
|
[Stable diffusion diffusion model page](https://huggingface.co/CompVis/stable-diffusion-v-1-4-original)
|
||||||
3. Accept the terms and click Access Repository:
|
3. Accept the terms and click Access Repository:
|
||||||
@ -28,24 +31,26 @@ First get the weights checkpoint download started - it's big:
|
|||||||
[sd-v1-4.ckpt (4.27 GB)](https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/blob/main/sd-v1-4.ckpt)
|
[sd-v1-4.ckpt (4.27 GB)](https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/blob/main/sd-v1-4.ckpt)
|
||||||
and note where you have saved it (probably the Downloads folder)
|
and note where you have saved it (probably the Downloads folder)
|
||||||
|
|
||||||
While that is downloading, open Terminal and run the following commands one
|
While that is downloading, open Terminal and run the following commands one at a
|
||||||
at a time.
|
time.
|
||||||
|
|
||||||
```bash
|
```{ .bash .annotate }
|
||||||
# install brew (and Xcode command line tools):
|
# install brew (and Xcode command line tools):
|
||||||
|
/bin/bash -c \
|
||||||
|
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
|
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
# Now there are two different routes to get the Python (miniconda) environment
|
||||||
|
# up and running:
|
||||||
# Now there are two different routes to get the Python (miniconda) environment up and running:
|
#
|
||||||
# 1. Alongside pyenv
|
# 1. Alongside pyenv
|
||||||
# 2. No pyenv
|
# 2. No pyenv
|
||||||
#
|
#
|
||||||
# If you don't know what we are talking about, choose 2.
|
# If you don't know what we are talking about, choose 2.
|
||||||
#
|
|
||||||
# NOW EITHER DO
|
# NOW EITHER DO
|
||||||
# 1. Installing alongside pyenv
|
# 1. Installing alongside pyenv
|
||||||
|
|
||||||
brew install pyenv-virtualenv # you might have this from before, no problem
|
brew install pyenv-virtualenv # (1)!
|
||||||
pyenv install anaconda3-2022.05
|
pyenv install anaconda3-2022.05
|
||||||
pyenv virtualenv anaconda3-2022.05
|
pyenv virtualenv anaconda3-2022.05
|
||||||
eval "$(pyenv init -)"
|
eval "$(pyenv init -)"
|
||||||
@ -53,7 +58,7 @@ pyenv activate anaconda3-2022.05
|
|||||||
|
|
||||||
# OR,
|
# OR,
|
||||||
# 2. Installing standalone
|
# 2. Installing standalone
|
||||||
# install python 3, git, cmake:
|
# install cmake and rust:
|
||||||
brew install cmake rust
|
brew install cmake rust
|
||||||
|
|
||||||
# install miniconda for M1 arm64:
|
# install miniconda for M1 arm64:
|
||||||
@ -77,16 +82,21 @@ cd stable-diffusion
|
|||||||
# create symlink to checkpoint
|
# create symlink to checkpoint
|
||||||
mkdir -p models/ldm/stable-diffusion-v1/
|
mkdir -p models/ldm/stable-diffusion-v1/
|
||||||
|
|
||||||
PATH_TO_CKPT="$HOME/Downloads" # or wherever you saved sd-v1-4.ckpt
|
PATH_TO_CKPT="$HOME/Downloads" # (2)!
|
||||||
|
|
||||||
ln -s "$PATH_TO_CKPT/sd-v1-4.ckpt" models/ldm/stable-diffusion-v1/model.ckpt
|
ln -s "$PATH_TO_CKPT/sd-v1-4.ckpt" \
|
||||||
|
models/ldm/stable-diffusion-v1/model.ckpt
|
||||||
|
|
||||||
# install packages for arm64
|
# install packages for arm64
|
||||||
PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -f environment-mac.yaml
|
PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 \
|
||||||
|
conda env create \
|
||||||
|
-f environment-mac.yaml
|
||||||
conda activate ldm
|
conda activate ldm
|
||||||
|
|
||||||
# OR install packages for x86_64
|
# OR install packages for x86_64
|
||||||
PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-x86_64 conda env create -f environment-mac.yaml
|
PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-x86_64 \
|
||||||
|
conda env create \
|
||||||
|
-f environment-mac.yaml
|
||||||
conda activate ldm
|
conda activate ldm
|
||||||
|
|
||||||
# only need to do this once
|
# only need to do this once
|
||||||
@ -99,25 +109,32 @@ python scripts/dream.py --full_precision # half-precision requires autocast and
|
|||||||
python scripts/dream.py --web
|
python scripts/dream.py --web
|
||||||
```
|
```
|
||||||
|
|
||||||
|
1. you might have this from before, no problem
|
||||||
|
2. or wherever you saved sd-v1-4.ckpt
|
||||||
|
3. half-precision requires autocast and won't work
|
||||||
|
|
||||||
The original scripts should work as well.
|
The original scripts should work as well.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python scripts/orig_scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --plms
|
python scripts/orig_scripts/txt2img.py \
|
||||||
|
--prompt "a photograph of an astronaut riding a horse" \
|
||||||
|
--plms
|
||||||
```
|
```
|
||||||
|
|
||||||
Note,
|
Note:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export PIP_EXISTS_ACTION=w
|
export PIP_EXISTS_ACTION=w
|
||||||
```
|
```
|
||||||
|
|
||||||
is a precaution to fix
|
is a precaution to fix a problem where
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
conda env create -f environment-mac.yaml
|
conda env create \
|
||||||
|
-f environment-mac.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
never finishing in some situations. So it isn't required but wont hurt.
|
did never finish in some situations. So it isn't required but wont hurt.
|
||||||
|
|
||||||
After you follow all the instructions and run dream.py you might get several
|
After you follow all the instructions and run dream.py you might get several
|
||||||
errors. Here's the errors I've seen and found solutions for.
|
errors. Here's the errors I've seen and found solutions for.
|
||||||
@ -130,10 +147,10 @@ Be sure to specify 1 sample and 1 iteration.
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
python ./scripts/orig_scripts/txt2img.py \
|
python ./scripts/orig_scripts/txt2img.py \
|
||||||
--prompt "ocean" \
|
--prompt "ocean" \
|
||||||
--ddim_steps 5 \
|
--ddim_steps 5 \
|
||||||
--n_samples 1 \
|
--n_samples 1 \
|
||||||
--n_iter 1
|
--n_iter 1
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -151,55 +168,76 @@ solution please
|
|||||||
One debugging step is to update to the latest version of PyTorch nightly.
|
One debugging step is to update to the latest version of PyTorch nightly.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
conda install pytorch torchvision torchaudio -c pytorch-nightly
|
conda install \
|
||||||
|
pytorch \
|
||||||
|
torchvision \
|
||||||
|
torchaudio \
|
||||||
|
-c pytorch-nightly
|
||||||
```
|
```
|
||||||
|
|
||||||
If it takes forever to run
|
If it takes forever to run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
conda env create -f environment-mac.yaml
|
conda env create \
|
||||||
|
-f environment-mac.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
you could try to run `git clean -f` followed by:
|
you could try to run:
|
||||||
|
|
||||||
`conda clean --yes --all`
|
```bash
|
||||||
|
git clean -f
|
||||||
|
conda clean \
|
||||||
|
--yes \
|
||||||
|
--all
|
||||||
|
```
|
||||||
|
|
||||||
Or you could try to completley reset Anaconda:
|
Or you could try to completley reset Anaconda:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
conda update --force-reinstall -y -n base -c defaults conda
|
conda update \
|
||||||
|
--force-reinstall \
|
||||||
|
-y \
|
||||||
|
-n base \
|
||||||
|
-c defaults conda
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### "No module named cv2", torch, 'ldm', 'transformers', 'taming', etc
|
### "No module named cv2", torch, 'ldm', 'transformers', 'taming', etc
|
||||||
|
|
||||||
There are several causes of these errors.
|
There are several causes of these errors:
|
||||||
|
|
||||||
- First, did you remember to `conda activate ldm`? If your terminal prompt
|
1. Did you remember to `conda activate ldm`? If your terminal prompt begins with
|
||||||
begins with "(ldm)" then you activated it. If it begins with "(base)" or
|
"(ldm)" then you activated it. If it begins with "(base)" or something else
|
||||||
something else you haven't.
|
you haven't.
|
||||||
|
|
||||||
- Second, you might've run `./scripts/preload_models.py` or `./scripts/dream.py`
|
2. You might've run `./scripts/preload_models.py` or `./scripts/dream.py`
|
||||||
instead of `python ./scripts/preload_models.py` or
|
instead of `python ./scripts/preload_models.py` or
|
||||||
`python ./scripts/dream.py`. The cause of this error is long so it's below.
|
`python ./scripts/dream.py`. The cause of this error is long so it's below.
|
||||||
|
|
||||||
- Third, if it says you're missing taming you need to rebuild your virtual
|
<!-- I could not find out where the error is, otherwise would have marked it as a footnote -->
|
||||||
environment.
|
|
||||||
|
|
||||||
```bash
|
3. if it says you're missing taming you need to rebuild your virtual
|
||||||
conda deactivate
|
environment.
|
||||||
|
|
||||||
conda env remove -n ldm
|
```bash
|
||||||
PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -f environment-mac.yaml
|
conda deactivate
|
||||||
```
|
|
||||||
|
|
||||||
Fourth, If you have activated the ldm virtual environment and tried rebuilding
|
conda env remove -n ldm
|
||||||
it, maybe the problem could be that I have something installed that you don't
|
PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 \
|
||||||
and you'll just need to manually install it. Make sure you activate the virtual
|
conda env create \
|
||||||
environment so it installs there instead of globally.
|
-f environment-mac.yaml
|
||||||
|
```
|
||||||
|
|
||||||
`conda activate ldm pip install _name_`
|
4. If you have activated the ldm virtual environment and tried rebuilding it,
|
||||||
|
maybe the problem could be that I have something installed that you don't and
|
||||||
|
you'll just need to manually install it. Make sure you activate the virtual
|
||||||
|
environment so it installs there instead of globally.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda activate ldm
|
||||||
|
pip install <package name>
|
||||||
|
```
|
||||||
|
|
||||||
You might also need to install Rust (I mention this again below).
|
You might also need to install Rust (I mention this again below).
|
||||||
|
|
||||||
@ -259,21 +297,22 @@ output of `python3 -V` and `python -V`.
|
|||||||
/Users/name/miniforge3/envs/ldm/bin/python
|
/Users/name/miniforge3/envs/ldm/bin/python
|
||||||
```
|
```
|
||||||
|
|
||||||
The above is what you'll see if you have miniforge and you've correctly
|
The above is what you'll see if you have miniforge and correctly activated the
|
||||||
activated the ldm environment, and you used option 2 in the setup instructions
|
ldm environment, while usingd option 2 in the setup instructions above ("no
|
||||||
above ("no pyenv").
|
pyenv").
|
||||||
|
|
||||||
|
If you otherwise used the first option ("alongside pyenv"), you will get this
|
||||||
|
prompt:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
(anaconda3-2022.05) % which python
|
(anaconda3-2022.05) % which python
|
||||||
/Users/name/.pyenv/shims/python
|
/Users/name/.pyenv/shims/python
|
||||||
```
|
```
|
||||||
|
|
||||||
... and the above is what you'll see if you used option 1 ("Alongside pyenv").
|
|
||||||
|
|
||||||
It's all a mess and you should know
|
It's all a mess and you should know
|
||||||
[how to modify the path environment variable](https://support.apple.com/guide/terminal/use-environment-variables-apd382cc5fa-4f58-4449-b20a-41c53c006f8f/mac)
|
[how to modify the path environment variable](https://support.apple.com/guide/terminal/use-environment-variables-apd382cc5fa-4f58-4449-b20a-41c53c006f8f/mac)
|
||||||
if you want to fix it. Here's a brief hint of all the ways you can modify it
|
if you want to fix it. Here's a brief hint of the most common ways you can
|
||||||
(don't really have the time to explain it all here).
|
modify it (don't really have the time to explain it all here).
|
||||||
|
|
||||||
- ~/.zshrc
|
- ~/.zshrc
|
||||||
- ~/.bash_profile
|
- ~/.bash_profile
|
||||||
@ -281,19 +320,20 @@ if you want to fix it. Here's a brief hint of all the ways you can modify it
|
|||||||
- /etc/paths.d
|
- /etc/paths.d
|
||||||
- /etc/path
|
- /etc/path
|
||||||
|
|
||||||
Which one you use will depend on what you have installed except putting a file
|
Which one you use will depend on what you have installed, except putting a file
|
||||||
in /etc/paths.d is what I prefer to do.
|
in /etc/paths.d - which also is the way I prefer to do.
|
||||||
|
|
||||||
Finally, to answer the question posed by this section's title, it may help to
|
Finally, to answer the question posed by this section's title, it may help to
|
||||||
list all of the `python` / `python3` things found in `$PATH` instead of just the
|
list all of the `python` / `python3` things found in `$PATH` instead of just the
|
||||||
one that will be executed by default. To do that, add the `-a` switch to
|
first hit. To do so, add the `-a` switch to `which`:
|
||||||
`which`:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
% which -a python3
|
% which -a python3
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This will show a list of all binaries which are actually available in your PATH.
|
||||||
|
|
||||||
### Debugging?
|
### Debugging?
|
||||||
|
|
||||||
Tired of waiting for your renders to finish before you can see if it works?
|
Tired of waiting for your renders to finish before you can see if it works?
|
||||||
@ -301,10 +341,14 @@ Reduce the steps! The image quality will be horrible but at least you'll get
|
|||||||
quick feedback.
|
quick feedback.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python ./scripts/txt2img.py --prompt "ocean" --ddim_steps 5 --n_samples 1 --n_iter 1
|
python ./scripts/txt2img.py \
|
||||||
|
--prompt "ocean" \
|
||||||
|
--ddim_steps 5 \
|
||||||
|
--n_samples 1 \
|
||||||
|
--n_iter 1
|
||||||
```
|
```
|
||||||
|
|
||||||
### OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'...
|
### OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python scripts/preload_models.py
|
python scripts/preload_models.py
|
||||||
@ -312,10 +356,7 @@ python scripts/preload_models.py
|
|||||||
|
|
||||||
### "The operator [name] is not current implemented for the MPS device." (sic)
|
### "The operator [name] is not current implemented for the MPS device." (sic)
|
||||||
|
|
||||||
Example error.
|
```bash title="example error"
|
||||||
|
|
||||||
```bash
|
|
||||||
|
|
||||||
... NotImplementedError: The operator 'aten::_index_put_impl_' is not current
|
... NotImplementedError: The operator 'aten::_index_put_impl_' is not current
|
||||||
implemented for the MPS device. If you want this op to be added in priority
|
implemented for the MPS device. If you want this op to be added in priority
|
||||||
during the prototype phase of this feature, please comment on
|
during the prototype phase of this feature, please comment on
|
||||||
@ -323,7 +364,6 @@ during the prototype phase of this feature, please comment on
|
|||||||
As a temporary fix, you can set the environment variable
|
As a temporary fix, you can set the environment variable
|
||||||
`PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op.
|
`PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op.
|
||||||
WARNING: this will be slower than running natively on MPS.
|
WARNING: this will be slower than running natively on MPS.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The lstein branch includes this fix in
|
The lstein branch includes this fix in
|
||||||
@ -335,7 +375,10 @@ I have not seen this error because I had Rust installed on my computer before I
|
|||||||
started playing with Stable Diffusion. The fix is to install Rust.
|
started playing with Stable Diffusion. The fix is to install Rust.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
curl \
|
||||||
|
--proto '=https' \
|
||||||
|
--tlsv1.2 \
|
||||||
|
-sSf https://sh.rustup.rs | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### How come `--seed` doesn't work?
|
### How come `--seed` doesn't work?
|
||||||
@ -356,6 +399,7 @@ still working on it.
|
|||||||
```bash
|
```bash
|
||||||
OMP: Error #15: Initializing libiomp5.dylib, but found libomp.dylib already initialized.
|
OMP: Error #15: Initializing libiomp5.dylib, but found libomp.dylib already initialized.
|
||||||
```
|
```
|
||||||
|
|
||||||
You are likely using an Intel package by mistake. Be sure to run conda with the
|
You are likely using an Intel package by mistake. Be sure to run conda with the
|
||||||
environment variable `CONDA_SUBDIR=osx-arm64`, like so:
|
environment variable `CONDA_SUBDIR=osx-arm64`, like so:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user