How to Deploy the FLUX.1-schnell Image Generation Model on Vultr Cloud GPU

Updated on January 17, 2025
How to Deploy the FLUX.1-schnell Image Generation Model on Vultr Cloud GPU header image

Introduction

Deploy Flux 1-schnell to harness the power of open-source generative AI for creating images from text prompts. This streamlined version of the original Flux-pro model offers faster performance while retaining text embedding capabilities for enhanced image generation. Built on a transformer architecture with 12 billion parameters, Flux 1-schnell supports LoRA (Low-Rank Adaptations) to produce highly realistic images efficiently.

This article explains how to deploy the FLUX.1-schnell image generation model on a Vultr Cloud GPU server. You will use the ComfyUI web interface to create an image generation workflow and set up LoRAs to enhance the quality of the generated images.

Prerequisites

Before you begin:

Download the Flux-schnell Model

The huggingface_hub Python library includes a special function for downloading the Flux-schnell model. Follow the steps below to install the huggingface_hub library and create a new Python script to download the Flux-schnell model.

  1. Switch to your user's home directory.

    console
    $ cd /home/linuxuser/
    
  2. Create a new directory, such as flux to store the model files.

    console
    $ mkdir flux
    
  3. Switch to the new flux directory.

    console
    $ cd flux
    
  4. Use Pip to install the huggingface_hub Python library.

    console
    $ pip install huggingface_hub
    
  5. Create a new schnell_model_downloader.py file.

    console
    $ nano schnell_model_downloader.py
    
  6. Add the following Python script to the schnell_model_downloader.py file. Replace /home/linuxuser/flux with your actual model directory.

    python
    from huggingface_hub import snapshot_download
    snapshot_download(repo_id="black-forest-labs/FLUX.1-schnell", local_dir="/home/linuxuser/flux")
    

    Save and close the file.

    The above Python script imports the huggingface_hub library for downloading the Flux-schnell model files. The snapshot_download function downloads the model from the black-forest-labs/FLUX.1-schnell Huggingface repository to the /home/linuxuser/flux directory.

  7. Run the script using Python to download the Flux-schnell model files and wait at least 10 minutes for the model to download.

    console
    $ python3 schnell_model_downloader.py
    

    Output:

    ...
    model-00002-of-00002.safetensors: 100%|███████████████████████████████████████████████████████████████| 4.53G/4.53G [01:50<00:00, 40.9MB/s]
    (...)model-00001-of-00002.safetensors: 100%|███████████████████████████████████████████████████████████████| 4.99G/4.99G [02:00<00:00, 41.4MB/s]
    (...)pytorch_model-00002-of-00003.safetensors: 100%|████████████████████████████████████████████████████| 9.95G/9.95G [03:59<00:00, 41.6MB/s]
    pytorch_model-00001-of-00003.safetensors: 100%|████████████████████████████████████████████████████| 9.96G/9.96G [04:02<00:00, 41.1MB/s]
    flux1-schnell.safetensors: 100%|██████████████████████████████████████████████████████████████████████| 23.8G/23.8G [09:30<00:00, 41.7MB/s]
    Fetching 28 files: 100%|███████████████████████████████████████████████████████████████████████████████████| 28/28 [09:31<00:00, 20.40s/it]
  8. Move the flux1-schnell.safetensors file to the models/unet directory in your ComfyUI project.

    console
    $ sudo mv flux1-schnell.safetensors /opt/ComfyUI/models/unet/
    
  9. Move the ae.safetensors file to the models/vae directory in your ComfyUI project.

    console
    $ sudo mv ae.safetensors /opt/ComfyUI/models/vae
    

    The above command moves the ae.safetensors variational encoder file required by the model to enhance the visual quality of generated images.

Set up the Flux-schnell Model in ComfyUI

ComfyUI requires multiple files to run models on a server. Follow the steps below to download the required Flux-schnell model files to your ComfyUI project directory.

  1. Switch to the models/clip directory in your ComfyUI project.

    console
    $ cd /opt/ComfyUI/models/clip
    
  2. Download the Flux-schnell clip_l.safetensors file.

    console
    $ sudo wget https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors
    

    The above command downloads the clip model used by the Flux-schnell model during the image generation process to support text inputs.

  3. Download the Flux-schnell t5xxl_fp16.safetensors file.

    console
    $ sudo wget https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp16.safetensors
    

    The above command takes between 2 and 5 minutes to download the FP16 model file used by Flux-schnell to encode text inputs. The model uses the FP16 precision standard to balance the model's image generation quality and performance.

Generate Images Using the Flux-schnell Model in ComfyUI

ComfyUI generates images using workflows in the form of interconnected nodes. Workflows connect multiple AI image generation components to produce a final image. ComfyUI loads workflows from sources such as configuration or image files. Follow the steps below to load the Flux-schnell image generation workflow and generate images using ComfyUI.

  1. Access your ComfyUI domain using a web browser such as Chrome.

    https://comfyui.example.com
  2. Download the following image to your workstation to load the Flux-schnell workflow in ComfyUI.

    Flux-schnell Workload Image

  3. Click Load in the floating ComfyUI menu to browse and open the workflow image on your workstation.

    Load the Workload in ComfyUI

  4. Find the Prompt node and enter a new text prompt to generate images. For example, A photorealistic image of a golden retriever dog with soulful brown eyes, lying on a soft rug in front of a cozy fireplace, with a warm glow illuminating its fur. The dog is relaxed, with its head resting on its paws, and its tail gently curled around its body. In the background, a peaceful living room with comfy furniture and soft lighting creates a calm, serene atmosphere..

  5. Click Queue Prompt to generate the image using the Flux-schnell model.

    Generate the Image in ComfyUI

  6. Wait at least 30 seconds for the image generation process to complete and verify the image in the Save Image node.

    Preview Generated Image in ComfyUI

Download the Flux-dev Model

The Flux-schnell development (Flux-dev) model generates higher-quality images at a slower generation speed as compared to the main Flux-schnell model. LoRas also require the Flux-dev model in order to generate higher-quality images. Follow the steps below to generate a new Hugging Face access token and download the Flux-dev model on your server.

  1. Visit the Flux-dev model page on Hugging Face.

  2. Click Agree to accept the model's terms and conditions.

    Agree to the Terms and Conditions for Using the Dev Model

  3. Visit the Tokens page in your Hugging Face account settings.

  4. Click Create new token.

    Create a new Huggingface Authorization Token

  5. Enter your desired token name and description in the respective fields.

  6. Check the Read access to contents of all public gated repos you can access within the User Permissions section to access the Flux-dev repository using the token.

    Configure the Correct Token Permission

  7. Scroll and click Create token to apply the new token to your Hugging Face account.

    Create a new Huggingface Authorization Token

  8. Click Copy to save the token to your clipboard.

    Copy the Token To Your Clipboard

  9. Switch to the flux directory you created earlier in your user's home directory. Replace /home/linuxuser/flux with your actual path.

    console
    $ cd /home/linuxuser/flux
    
  10. Create a new dev_model_downloader.py file.

    console
    $ nano dev_model_downloader.py
    
  11. Add the following Python script to the dev_model_downloader.py file. Replace YOUR_ACCESS_TOKEN with your Hugging Face token and /home/linuxuser/flux with your actual path.

    python
    from huggingface_hub import snapshot_download
    from huggingface_hub import login
    login(token="YOUR_ACCESS_TOKEN")
    snapshot_download(repo_id="black-forest-labs/FLUX.1-dev", local_dir="/home/linuxuser/flux")
    

    Save and close the file.

    The above Python script runs the login(...) function from the huggingface_hub library to download the Flux-dev model using the snapshot_download(...) function and your Hugging Face token.

  12. Run the dev_model_downloader.py script using Python.

    console
    $ python3 dev_model_downloader.py
    

    Wait at least 10 minutes for the model to finish downloading and verify that your output is similar to the one below when successful.

    (…) pytorch_model-00003-of-00003.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3.87G/3.87G [01:35<00:00, 40.5MB/s]  
    (…) pytorch_model-00002-of-00003.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9.95G/9.95G [03:57<00:00, 41.9MB/s]  
    (…) pytorch_model-00001-of-00003.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9.98G/9.98G [03:58<00:00, 41.9MB/s]  
    flux1-dev.safetensors: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 23.8G/23.8G [09:29<00:00, 41.8MB/s]  
    Fetching 29 files: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 29/29 [09:29<00:00, 19.65s/it]
  13. Move the flux-dev model files to the models/unet directory in your ComfyUI project.

    console
    $ sudo mv flux1-dev.safetensors /opt/ComfyUI/models/unet/
    
  14. Access the ComfyUI interface using your domain in a new web browser window.

    https://comfyui.example.com
  15. Download the following image to your workstation to load a new Flux-dev workflow in ComfyUI.

    Flux-dev Workload Image

    The Flux-dev workflow allows you to generate images with the Flux-dev model and contains all necessary paths required by the model.

  16. Click Load in ComfyUI to browse the image from your workstation and load the Flux-dev workflow.

    Load the Workload in ComfyUI

  17. Enter a new text prompt in the Prompt node. For example, enter the prompt A photorealistic image of a golden retriever dog with soulful brown eyes, lying on a soft rug in front of a cozy fireplace, with a warm glow illuminating its fur. The dog is relaxed, with its head resting on its paws, and its tail gently curled around its body. In the background, a peaceful living room with comfy furniture and soft lighting creates a calm, serene atmosphere..

  18. Click Queue Prompt to generate the image using the Flux-dev model.

    Generate the Image in ComfyUI

  19. Wait at least 30 seconds for the image generation process to complete and verify the image in the Save Image node.

    Preview Generated Image in ComfyUI

Set up LoRAs to Generate More Realistic Images

LoRAs are additional model files that increase the realism of generated images including faces. Follow the steps below to set up LoRAs developed by XLabs AI to increase the quality of images generated by the Flux-dev model.

  1. Switch to the models/loras directory in your ComfyUI project.

    console
    $ cd /opt/ComfyUI/models/loras
    
  2. Download the LoRAs file for the Flux-dev model.

    console
    $ sudo wget https://huggingface.co/comfyanonymous/flux_RealismLora_converted_comfyui/resolve/main/flux_realism_lora.safetensors
    
  3. Download the following image to your workstation to load the Flux-dev image generation workflow with LoRAs in ComfyUI.

    Flux with Loras Workload Image

  4. Click Load in ComfyUI to browse the image and open the LoRAs workflow.

    Load the Workload in ComfyUI

  5. Enter a new text prompt in the Prompt that contains a face to test the LoRAs output. For example, enter the prompt, A photorealistic image of a young man's face with short, dark hair and smooth skin. He has a focused, thoughtful expression, with relaxed eyes and a slight, confident smile. Soft lighting from one side highlights his sharp cheekbones and well-defined jawline, bringing out the natural contours of his face. The background is simple and blurred, emphasizing his facial features and calm demeanor..

  6. Click Queue Prompt to generate a new image using the model.

    Generate the Image in ComfyUI

  7. Wait at least 30 seconds for the image generation process to complete and view the image in the Save Image node.

    Preview Generated Image in ComfyUI

Troubleshooting

ComfyUI may display some errors while generating images using the Flux-schnell model. Use the following solutions to fix any errors on your server.

  • torch.cuda.OutOfMemoryError: Upgrade your GPU server plan or clear the GPU memory to generate images using the Flux-schnell model.
  • Numpy is not available: Verify the latest supported ComfyUI Numpy version and install it on your server. For example, Install the numpy<2 package using Pip as required by most ComfyUI versions.

Conclusion

You have deployed the Flux-schnell model on a Vultr Cloud GPU server and generated images using ComfyUI. In addition, you deployed the Flux-dev model to increase the generated image output quality and set up LoRAs to enable the model to produce more realistic images. For more information, workflow, and model options, please visit the official Flux-schnell Hugging Face page.