Skip to content

VALDI: Launch the Docker container in inference mode

Kaloyan Raev edited this page Jul 26, 2023 · 9 revisions

Prerequisites

Create the local workspace directory

Execute the following command in the connected SSH terminal:

mkdir /home/user/workspace

This is where the /workspace directory of the Docker container will be mounted to the local file system.

Run the Docker container

Execute the following command in the SSH terminal:

docker run \
    -d \
    --rm \
    --runtime=nvidia \
    --gpus all \
    -p 80:3000 \
    -p 443:7860 \
    --mount type=bind,source=/home/user/workspace,destination=/workspace \
    -e STORJ_ACCESS=<access-grant> \
    -e STORJ_BUCKET=<bucket-name> \
    -e STORJ_MODEL_PATH=<object-key-or-prefix> \
    storjlabs/secure-stable-diffusion

Flags:

  • -d starts the container in daemon mode. Use it if you want the container to run after disconnecting from the SSH session.
  • --rm automatically deletes the container after it stops. It is recommended to have to keep the system clean.
  • --runtime=nvidia is required to load the NVIDIA Container Runtime.
  • --gpus all is required to access the GPU.
  • -p 80:3000 exposes the Stability Studio's HTTP port to the host system's HTTP port.
  • -p 443:7860 exposes the Stable Diffusion Web UI's HTTP port to the host system's HTTPS port.
  • --mount type=bind,source=/home/user/workspace,destination=/workspace mounts the Docker container's workspace directory to the host file system.
  • -e STORJ_ACCESS=<access-grant> configures a Storj access grant for automatically downloading AI models from a Storj bucket to the Docker container. Replace <access-grant> with the actual access grant.
  • -e STORJ_BUCKET=<bucket-name> configures the Storj bucket to download the AI models. Replace <bucket-name> with the actual bucket name.
  • -e STORJ_MODEL_PATH=<object-key-or-prefix> configure the object key or the object prefix with the location of the AI models in the Storj bucket. Replace <object-key-or-prefix> with the actual object key or prefix. If it is an object key, this object will be downloaded. If it is an object prefix (it must end with a trailing slash), all object starting with this prefix will be recursively downloaded.

Setting the STORJ_ACCESS, STORJ_BUCKET, and STORJ_MODEL_PATH environment variables is optional. If one is missing, no AI model will be downloaded from Storj. Instead, the default Stable Diffusion v1.5 will be downloaded.

The above docker run command will pull the Docker image and start the container.

Watch the execution logs

If you used the -d flag, you must execute the docker logs -f <container-name> command to watch the execution logs. You can find the container name using the docker ps command.

If you did not use the -d flag, the logs will be printed directly in the SSH terminal.

The container is started once logs like these are printed:

➤ YN0000: [@stability/stablestudio-ui]:   ➜  Local:   http://localhost:3000/
➤ YN0000: [@stability/stablestudio-ui]:   ➜  Network: http://172.17.0.2:3000/

Next step

Launch the Stable Diffusion Web UI.