InvokeAI/docs/installation/020_INSTALL_MANUAL.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

370 lines
12 KiB
Markdown
Raw Normal View History

---
title: Installing Manually
---
<figure markdown>
# :fontawesome-brands-linux: Linux | :fontawesome-brands-apple: macOS | :fontawesome-brands-windows: Windows
</figure>
!!! warning "This is for advanced Users"
**python experience is mandatory**
## Introduction
2023-02-07 02:47:29 +00:00
!!! tip "Conda"
As of InvokeAI v2.3.0 installation using the `conda` package manager is no longer being supported. It will likely still work, but we are not testing this installation method.
On Windows systems, you are encouraged to install and use the
[PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3),
2023-02-07 02:47:29 +00:00
which provides compatibility with Linux and Mac shells and nice
features such as command-line completion.
2023-02-07 22:04:01 +00:00
### Prerequisites
2023-02-07 02:47:29 +00:00
Before you start, make sure you have the following preqrequisites
installed. These are described in more detail in [Automated
Installation](010_INSTALL_AUTOMATED.md), and in many cases will
already be installed (if, for example, you have used your system for
gaming):
* **Python**
version 3.9 or 3.10 (3.11 is not recommended).
* **CUDA Tools**
2023-02-07 02:47:29 +00:00
For those with _NVidia GPUs_, you will need to
install the [CUDA toolkit and optionally the XFormers library](070_INSTALL_XFORMERS.md).
2023-02-07 02:47:29 +00:00
* **ROCm Tools**
For _Linux users with AMD GPUs_, you will need
to install the [ROCm toolkit](./030_INSTALL_CUDA_AND_ROCM.md). Note that
InvokeAI does not support AMD GPUs on Windows systems due to
lack of a Windows ROCm library.
* **Visual C++ Libraries**
_Windows users_ must install the free
[Visual C++ libraries from Microsoft](https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170)
* **The Xcode command line tools**
for _Macintosh users_. Instructions are available at
[Free Code Camp](https://www.freecodecamp.org/news/install-xcode-command-line-tools/)
* _Macintosh users_ may also need to run the `Install Certificates` command
if model downloads give lots of certificate errors. Run:
`/Applications/Python\ 3.10/Install\ Certificates.command`
2023-02-07 02:47:29 +00:00
### Installation Walkthrough
To install InvokeAI with virtual environments and the PIP package
manager, please follow these steps:
1. Please make sure you are using Python 3.9 or 3.10. The rest of the install
procedure depends on this and will not work with other versions:
```bash
2023-02-07 02:47:29 +00:00
python -V
```
2023-02-07 02:47:29 +00:00
2. Create a directory to contain your InvokeAI library, configuration
files, and models. This is known as the "runtime" or "root"
directory, and often lives in your home directory under the name `invokeai`.
Please keep in mind the disk space requirements - you will need at
least 20GB for the models and the virtual environment. From now
2023-02-07 19:19:55 +00:00
on we will refer to this directory as `INVOKEAI_ROOT`. For convenience,
the steps below create a shell variable of that name which contains the
path to `HOME/invokeai`.
2023-02-07 02:47:29 +00:00
=== "Linux/Mac"
2023-02-08 19:07:12 +00:00
2023-02-07 02:47:29 +00:00
```bash
export INVOKEAI_ROOT=~/invokeai
2023-02-07 04:59:48 +00:00
mkdir $INVOKEAI_ROOT
2023-02-07 02:47:29 +00:00
```
2023-02-07 04:59:48 +00:00
=== "Windows (Powershell)"
2023-02-08 19:07:12 +00:00
2023-02-07 02:47:29 +00:00
```bash
2023-02-07 19:19:55 +00:00
Set-Variable -Name INVOKEAI_ROOT -Value $Home/invokeai
2023-02-07 04:59:48 +00:00
mkdir $INVOKEAI_ROOT
2023-02-07 02:47:29 +00:00
```
2023-02-07 04:59:48 +00:00
3. Enter the root (invokeai) directory and create a virtual Python
2023-02-07 02:47:29 +00:00
environment within it named `.venv`. If the command `python`
doesn't work, try `python3`. Note that while you may create the
virtual environment anywhere in the file system, we recommend that
you create it within the root directory as shown here. This makes
it possible for the InvokeAI applications to find the model data
and configuration. If you do not choose to install the virtual
environment inside the root directory, then you **must** set the
`INVOKEAI_ROOT` environment variable in your shell environment, for
example, by editing `~/.bashrc` or `~/.zshrc` files, or setting the
2023-02-07 19:19:55 +00:00
Windows environment variable using the Advanced System Settings dialogue.
Refer to your operating system documentation for details.
2023-02-07 02:47:29 +00:00
```terminal
cd $INVOKEAI_ROOT
python -m venv .venv --prompt InvokeAI
```
4. Activate the new environment:
2023-02-07 02:47:29 +00:00
2023-02-07 04:59:48 +00:00
=== "Linux/Mac"
2023-02-07 04:59:48 +00:00
```bash
source .venv/bin/activate
2023-02-07 04:59:48 +00:00
```
2023-02-07 02:47:29 +00:00
2023-02-07 04:59:48 +00:00
=== "Windows"
2023-02-07 02:47:29 +00:00
```ps
.venv\Scripts\activate
```
2023-02-07 02:47:29 +00:00
If you get a permissions error at this point, run this command and try again
`Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`
The command-line prompt should change to to show `(InvokeAI)` at the
2023-02-07 19:19:55 +00:00
beginning of the prompt. Note that all the following steps should be
run while inside the INVOKEAI_ROOT directory
2023-02-07 02:47:29 +00:00
5. Make sure that pip is installed in your virtual environment and up to date:
```bash
python -m pip install --upgrade pip
```
6. Install the InvokeAI Package. The `--extra-index-url` option is used to select among
CUDA, ROCm and CPU/MPS drivers as shown below:
2023-02-07 04:59:48 +00:00
=== "CUDA (NVidia)"
2023-02-07 04:59:48 +00:00
```bash
pip install "InvokeAI[xformers]" --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu117
2023-02-07 04:59:48 +00:00
```
2023-02-07 19:19:55 +00:00
2023-02-07 04:59:48 +00:00
=== "ROCm (AMD)"
2023-02-07 04:59:48 +00:00
```bash
2023-02-07 19:19:55 +00:00
pip install InvokeAI --use-pep517 --extra-index-url https://download.pytorch.org/whl/rocm5.2
2023-02-07 04:59:48 +00:00
```
=== "CPU (Intel Macs & non-GPU systems)"
2023-02-07 04:59:48 +00:00
```bash
2023-02-07 19:19:55 +00:00
pip install InvokeAI --use-pep517 --extra-index-url https://download.pytorch.org/whl/cpu
2023-02-07 04:59:48 +00:00
```
=== "MPS (M1 and M2 Macs)"
2023-02-07 04:59:48 +00:00
```bash
pip install InvokeAI --use-pep517
2023-02-07 04:59:48 +00:00
```
2023-02-07 02:47:29 +00:00
7. Deactivate and reactivate your runtime directory so that the invokeai-specific commands
become available in the environment
2023-02-07 04:59:48 +00:00
=== "Linux/Macintosh"
2023-02-07 04:59:48 +00:00
```bash
2023-02-07 19:19:55 +00:00
deactivate && source .venv/bin/activate
2023-02-07 04:59:48 +00:00
```
2023-02-07 04:59:48 +00:00
=== "Windows"
```ps
2023-02-07 19:19:55 +00:00
deactivate
.venv\Scripts\activate
2023-02-07 04:59:48 +00:00
```
2023-02-07 02:47:29 +00:00
8. Set up the runtime directory
In this step you will initialize your runtime directory with the downloaded
models, model config files, directory for textual inversion embeddings, and
your outputs.
```terminal
2023-02-07 02:47:29 +00:00
invokeai-configure
```
The script `invokeai-configure` will interactively guide you through the
process of downloading and installing the weights files needed for InvokeAI.
Note that the main Stable Diffusion weights file is protected by a license
agreement that you have to agree to. The script will list the steps you need
to take to create an account on the site that hosts the weights files,
accept the agreement, and provide an access token that allows InvokeAI to
legally download and install the weights files.
If you get an error message about a module not being installed, check that
the `invokeai` environment is active and if not, repeat step 5.
!!! tip
If you have already downloaded the weights file(s) for another Stable
Diffusion distribution, you may skip this step (by selecting "skip" when
prompted) and configure InvokeAI to use the previously-downloaded files. The
2023-02-07 04:59:48 +00:00
process for this is described in [Installing Models](050_INSTALLING_MODELS.md).
2023-02-07 02:47:29 +00:00
9. Run the command-line- or the web- interface:
2023-02-07 19:19:55 +00:00
From within INVOKEAI_ROOT, activate the environment
(with `source .venv/bin/activate` or `.venv\scripts\activate), and then run
the script `invokeai`. If the virtual environment you selected is NOT inside
INVOKEAI_ROOT, then you must specify the path to the root directory by adding
`--root_dir \path\to\invokeai` to the commands below:
!!! example ""
2023-02-07 19:19:55 +00:00
!!! warning "Make sure that the virtual environment is activated, which should create `(.venv)` in front of your prompt!"
=== "CLI"
```bash
2023-02-07 19:19:55 +00:00
invokeai
```
=== "local Webserver"
```bash
2023-02-07 19:19:55 +00:00
invokeai --web
```
=== "Public Webserver"
```bash
2023-02-07 19:19:55 +00:00
invokeai --web --host 0.0.0.0
```
If you choose the run the web interface, point your browser at
http://localhost:9090 in order to load the GUI.
!!! tip
2023-02-07 19:19:55 +00:00
You can permanently set the location of the runtime directory
by setting the environment variable `INVOKEAI_ROOT` to the
path of the directory. As mentioned previously, this is
*highly recommended** if your virtual environment is located outside of
your runtime directory.
2023-02-07 02:47:29 +00:00
10. Render away!
Browse the [features](../features/CLI.md) section to learn about all the
things you can do with InvokeAI.
2023-02-07 19:19:55 +00:00
2023-02-07 02:47:29 +00:00
11. Subsequently, to relaunch the script, activate the virtual environment, and
then launch `invokeai` command. If you forget to activate the virtual
environment you will most likeley receive a `command not found` error.
!!! warning
2023-02-07 04:59:48 +00:00
Do not move the runtime directory after installation. The virtual environment will get confused if the directory is moved.
2023-02-07 19:19:55 +00:00
12. Other scripts
2023-02-08 19:07:12 +00:00
The [Textual Inversion](../features/TEXTUAL_INVERSION.md) script can be launched with the command:
2023-02-07 19:19:55 +00:00
```bash
invokeai-ti --gui
```
Similarly, the [Model Merging](../features/MODEL_MERGING.md) script can be launched with the command:
```bash
invokeai-merge --gui
```
Leave off the `--gui` option to run the script using command-line arguments. Pass the `--help` argument
to get usage instructions.
2023-02-07 22:04:01 +00:00
### Developer Install
If you have an interest in how InvokeAI works, or you would like to
add features or bugfixes, you are encouraged to install the source
code for InvokeAI. For this to work, you will need to install the
`git` source code management program. If it is not already installed
on your system, please see the [Git Installation
Guide](https://github.com/git-guides/install-git)
1. From the command line, run this command:
```bash
git clone https://github.com/invoke-ai/InvokeAI.git
```
This will create a directory named `InvokeAI` and populate it with the
full source code from the InvokeAI repository.
2023-02-07 22:04:01 +00:00
2. Activate the InvokeAI virtual environment as per step (4) of the manual
installation protocol (important!)
3. Enter the InvokeAI repository directory and run one of these
commands, based on your GPU:
=== "CUDA (NVidia)"
```bash
pip install -e .[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu117
```
=== "ROCm (AMD)"
```bash
pip install -e . --use-pep517 --extra-index-url https://download.pytorch.org/whl/rocm5.2
```
=== "CPU (Intel Macs & non-GPU systems)"
```bash
pip install -e . --use-pep517 --extra-index-url https://download.pytorch.org/whl/cpu
```
=== "MPS (M1 and M2 Macs)"
```bash
pip install -e . --use-pep517
2023-02-07 22:04:01 +00:00
```
Be sure to pass `-e` (for an editable install) and don't forget the
dot ("."). It is part of the command.
You can now run `invokeai` and its related commands. The code will be
read from the repository, so that you can edit the .py source files
and watch the code's behavior change.
4. If you wish to contribute to the InvokeAI project, you are
encouraged to establish a GitHub account and "fork"
https://github.com/invoke-ai/InvokeAI into your own copy of the
repository. You can then use GitHub functions to create and submit
pull requests to contribute improvements to the project.
Please see [Contributing](../index.md#contributing) for hints
2023-02-08 19:07:12 +00:00
on getting started.
### Unsupported Conda Install
Congratulations, you found the "secret" Conda installation
instructions. If you really **really** want to use Conda with InvokeAI
you can do so using this unsupported recipe:
```
mkdir ~/invokeai
conda create -n invokeai python=3.10
conda activate invokeai
pip install InvokeAI[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu117
invokeai-configure --root ~/invokeai
invokeai --root ~/invokeai --web
```
The `pip install` command shown in this recipe is for Linux/Windows
systems with an NVIDIA GPU. See step (6) above for the command to use
with other platforms/GPU combinations. If you don't wish to pass the
`--root` argument to `invokeai` with each launch, you may set the
environment variable INVOKEAI_ROOT to point to the installation directory.
Note that if you run into problems with the Conda installation, the InvokeAI
staff will **not** be able to help you out. Caveat Emptor!