diff --git a/docker-build/env.sh b/docker-build/env.sh index d612afb7fa..76d4127ec1 100644 --- a/docker-build/env.sh +++ b/docker-build/env.sh @@ -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 diff --git a/docker-build/run.sh b/docker-build/run.sh index 14d2b1827d..d2f232d6fa 100755 --- a/docker-build/run.sh +++ b/docker-build/run.sh @@ -17,4 +17,5 @@ docker run \ --mount="source=$volumename,target=/data" \ --publish=9090:9090 \ --cap-add=sys_nice \ + $gpus \ "$invokeai_tag" ${1:+$@} diff --git a/docs/installation/INSTALL_DOCKER.md b/docs/installation/INSTALL_DOCKER.md index 704662a06f..9f0b203930 100644 --- a/docs/installation/INSTALL_DOCKER.md +++ b/docs/installation/INSTALL_DOCKER.md @@ -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).