Skip to content

VALDI: Train your model and upload it to Storj

Kaloyan Raev edited this page Jul 27, 2023 · 6 revisions

Prerequisites

Create the local workspace directory

If you haven't done it yet, 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 \
    --rm \
    --runtime=nvidia \
    --gpus all \
    -p 80:8888 \
    -p 443:7860 \
    --mount type=bind,source=/home/user/workspace,destination=/workspace \
    -e JUPYTER_PASSWORD=<password> \
    storjlabs/secure-stable-diffusion

Flags:

  • --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:8888 exposes the JupyterLab'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 JUPYTER_PASSWORD=<password> configures a password to connect to JupyterLab. Replace <password> with a password of your choice.

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

Watch the execution logs

The container is started once logs like these are printed:

[I 2023-07-26 21:11:03.793 ServerApp] Jupyter Server 2.6.0 is running at:
[I 2023-07-26 21:11:03.793 ServerApp] http://localhost:8888/lab?token=...
[I 2023-07-26 21:11:03.793 ServerApp]     http://127.0.0.1:8888/lab?token=...

Find the external port number of JupyterLab

The JupyterLab runs on port 8888. This is the port number inside the Docker container, and it is not directly accessible. This port was mapped to the host's HTTP port 80 in the previous step. This port is not directly accessible too. The VM forwards it to an external port through the firewall. You can connect to this external port number.

You can find the external port number on the VM info page.

image

Connect to the JupyterLab

Open your web browser at the following URL:

http://<ip-address>:<external-port-number>

Replace <ip-address> with the actual IP address of your VM and <external-port-number> with the port number identified in the previous step.

In the "Password or token" field, use the password you configured in the JUPYTER_PASSWORD environment variable. Then click the "Log in" button.

image

Train your model

You are now in the JupyterLab interface. Look at the file browser sidebar on the left. Find the DreamBooth_Stable_Diffusion.ipynb file and double-click it.

image

The notebook will open. Follow the instructions inside the notebook on how to train your model with DreamBooth.

To execute a step from the notebook, click on the Play button or use the Ctrl+Enter keyboard shortcut.

image