How do I get started generating images from prompts?

With Lambda GPU Cloud, you can begin generating images from prompts without having to buy expensive GPUs and other computer hardware.

In this tutorial, you’ll learn how to set up AUTOMATIC1111 (Stable Diffusion) and Dream Factory on a Lambda GPU Cloud on-demand instance—and start generating images right away.

Sign up for a Lambda GPU Cloud account

Sign up for a Lambda GPU Cloud account if you don’t have one already.

You won’t have to enter payment information when you sign up. However, you’ll need to enter payment information before you can launch any instances.

Launch an on-demand instance

From the dashboard, launch an instance.

Configure firewall rules for your account

Use the Firewall feature to allow your computer to access Dream Factory once it’s running on your instance.

  1. Learn your computer’s IP address by visiting What Is My IP Address from your computer.

  2. In the dashboard, click Firewall. Then, under Inbound Rules, click Edit.

  3. In the Edit inbound rules dialog, click Add rule.

  4. In the newly created rule, set Protocol to TCP and enter the following information:

    • Port range: 8080
    • Source: YOUR-IP-ADDRESS
    • Description: Dream Factory

    Replace YOUR-IP-ADDRESS with your computer’s actual IP address.

  5. Click Update to enable the firewall rule you just created.

Log into your instance

To log into your instance using Jupyter Notebook:

  1. Open Jupyter Notebook.

  2. Under Other, click Terminal.

You now have a terminal open that you’ll use to run various commands, below.

Install AUTOMATIC1111

Once you’re logged into your instance, copy and paste the following command into the terminal:

bash <(wget -qO- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh)

Then, press Enter to run the command.

This command will download and install AUTOMATIC1111 directly to your instance. The download and install will take a few minutes to complete.

When the installation completes, you’ll see the following message:

Can't run without a checkpoint. Find and place a .ckpt or .safetensors file into any of those locations. The program will exit.

You can safely disregard this message. In the next step of this tutorial, you’ll install a model checkpoint.

Download a Stable Diffusion prompt-to-image model

Next, download the Realistic Vision V1.3 prompt-to-image model directly to your instance.

To download the model directly to your instance, copy and paste the following command into your terminal, then press Enter:

wget -O /home/ubuntu/stable-diffusion-webui/models/Stable-diffusion/realisticVisionV13.LtFu.safetensors \
https://civitai.com/api/download/models/6987

Install Anaconda

Anaconda is used to create virtual environments and manage packages. Virtual environments can be separated from each other and manage different versions of Python and packages.

Install Anaconda by running:

wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh && \
bash Anaconda3-2022.10-Linux-x86_64.sh

You’ll be asked to review a license agreement before you can continue. Press Enter to see the license agreement. Press Spacebar until you reach the end of the license agreement.

When you’re asked whether or not you accept the license terms, type yes to accept the license terms. Then, press Enter.

You’ll now see:

Anaconda3 will now be installed into this location:
/home/ubuntu/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/ubuntu/anaconda3] >>>

Press Enter to proceed with the installation.

Once the installation completes, you’ll see:

Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>>

Type yes, then press Enter.

When the installation completes and you’re back at the command prompt, copy and paste the following command into the terminal, then press Enter:

source .bashrc

Your command prompt should now look like:

(base) ubuntu@INSTANCE-IP-ADDRESS:~$

This command prompt indicates you’re in the base conda environment. In the next step, you’ll create and activate a virtual environment in which you’ll run Dream Factory.

Create, activate, and set up a conda virtual environment

In this step, you’ll create, activate, and set up a conda virtual environment that you’ll use to run Dream Factory.

  1. To create a conda virtual environment, copy and paste the following command into your terminal, then press Enter:

    conda create --name dream-factory python=3.9
    

    You’ll see The following NEW packages will be INSTALLED: followed by a list of packages.

    Following the list of packages, you’ll see Proceed ([y]/n)?.

    Press Enter to proceed with the creation of the conda virtual environment.

    When creation of the conda virtual environment completes, you’ll be back at the command prompt.

  2. To activate the conda virtual environment you just created, copy and paste the following command into your terminal, then press Enter:

    conda activate dream-factory
    

    The command prompt in your terminal should now look like:

    (dream-factory) ubuntu@INSTANCE-IP-ADDRESS:~$
    

    This command prompt indicates you’re in the dream-factory virtual environment that you’ll use to run Dream Factory.

  3. To install packages needed to install Dream Factory, copy and paste the following command into your terminal, then press Enter:

    conda install -c anaconda git urllib3
    

    At the Proceed ([y]/n)? prompt, press Enter.

Install, configure, and run Dream Factory

  1. Copy and paste the following command into your terminal, then press Enter:

    git clone https://github.com/rbbrdckybk/dream-factory && \
    cd dream-factory && \
    python setup.py
    

    This command installs Dream Factory. Installation of Dream Factory can take up to 10 minutes.

    When the installation completes, you should see the following message:

    All done! - don't forget to add your automatic1111 repo location to config.txt!
    
  2. In the left sidebar of Jupyter Notebook, double-click the dream-factory folder to open the folder. Then, double-click the config.txt file to open the file.

    Change line 7 so it reads:

    SD_LOCATION = /home/ubuntu/stable-diffusion-webui
    

    This change tells Dream Factory where to find AUTOMATIC1111 that you installed at the beginning of this tutorial.

    Change line 46 so it reads:

    WEBSERVER_NETWORK_ACCESSIBLE = yes
    

    This change tells Dream Factory to allow connections over the Internet, such as from your computer.

    Close the tab and click Save to save your changes.

  3. To run Dream Factory, copy and paste the following command into the terminal, then press Enter.

    python dream-factory.py
    

    You’ll be able to access Dream Factory from your web browser once you see the following message:

    [controller] >>> starting webserver (http://localhost:8080/) as a background process...
    

Access Dream Factory from your web browser

In your web browser, go to http://INSTANCE-IP-ADDRESS:8080.

Replace INSTANCE-IP-ADDRESS with the actual IP address of your instance.

You’ll be taken to the Dream Factory status monitor, where you can see the activity of each of your instance’s GPUs.

To begin generating images from example prompts:

  1. In the top navigation bar, click Control Panel.

  2. Under Prompt File, in the Choose a prompt file drop-down menu, choose either example-random or example-standard.

Dream Factory will begin continuously generating images. You can view these images by clicking Gallery in the top navigation bar.

To learn how to create your own prompt files, read Dream Factory’s usage documentation.

If you have questions about this tutorial, post them in the Lambda community forum.


Last modified February 11, 2023: Use more popular name (8ae4ab5)