Skip to content

Commit

Permalink
Permit usage of GPUs in docker script (#1985)
Browse files Browse the repository at this point in the history
* Add gpu support to docker

Enable GPUs within docker

* Use gpus flag

* Add GPU information to readme

* Fix env var name for GPU
  • Loading branch information
xrd committed Dec 14, 2022
1 parent ccf8a46 commit 5d20f47
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docker-build/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ volumename=${VOLUMENAME:-${project_name}_data}
arch=${ARCH:-x86_64}
platform=${PLATFORM:-Linux/${arch}}
invokeai_tag=${INVOKEAI_TAG:-${project_name}:${arch}}
gpus=${GPU_FLAGS:+--gpus=${GPU_FLAGS}}

export project_name
export volumename
export arch
export platform
export invokeai_tag
export gpus
1 change: 1 addition & 0 deletions docker-build/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ docker run \
--mount="source=$volumename,target=/data" \
--publish=9090:9090 \
--cap-add=sys_nice \
$gpus \
"$invokeai_tag" ${1:+$@}
21 changes: 21 additions & 0 deletions docs/installation/INSTALL_DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ also do so.

---

## Running the container on your GPU

If you have an Nvidia GPU, you can enable InvokeAI to run on the GPU by running the container with an extra
environment variable to enable GPU usage and have the process run much faster:

```bash
GPU_FLAGS=all ./docker-build/run.sh
```

This passes the `--gpus all` to docker and uses the GPU.

If you don't have a GPU (or your host is not yet setup to use it) you will see a message like this:

`docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].`

You can use the full set of GPU combinations documented here:

https://docs.docker.com/config/containers/resource_constraints/#gpu

For example, use `GPU_FLAGS=device=GPU-3a23c669-1f69-c64e-cf85-44e9b07e7a2a` to choose a specific device identified by a UUID.

## Running InvokeAI in the cloud with Docker

We offer an optimized Ubuntu-based image that has been well-tested in cloud deployments. Note: it also works well locally on Linux x86_64 systems with an Nvidia GPU. It *may* also work on Windows under WSL2 and on Intel Mac (not tested).
Expand Down

0 comments on commit 5d20f47

Please sign in to comment.