Sana is an innovative text-to-image framework designed to generate high-quality images with resolutions up to 4096 × 4096, combining efficiency and precision. It leverages key advancements like a 32× compression Autoencoder (DC-AE), Linear Diffusion Transformer (Linear DiT) for high-resolution efficiency, and a modern decoder-only text encoder for enhanced text-image alignment. Sana also features Flow-DPM-Solver to accelerate both training and sampling processes, enabling faster convergence and streamlined content creation.
Despite being compact at 0.6B parameters, Sana outperforms larger models in speed and resource efficiency, generating 1024 × 1024 images in under a second on a 16GB laptop GPU. Fully open source under the Apache License 2.0, Sana is a fantastic opportunity for open-source contributors to innovate and enhance the field of high-resolution image synthesis.
Resource
GitHub
Link: https://github.com/NVlabs/Sana
Prerequisites for Installing NVIDIA SANA Locally
Make sure you have the following:
- GPUs: 1xRTXA6000 (for smooth execution).
- Disk Space: 100 GB free.
- RAM: 64 GB(48 Also works) but we use 64 for smooth execution
- CPU: 64 Cores(48 Also works)but we use 64 for smooth execution
Step-by-Step Process to Install NVIDIA SANA Model Locally
For the purpose of this tutorial, we will use a GPU-powered Virtual Machine offered by NodeShift; however, you can replicate the same steps with any other cloud provider of your choice. NodeShift provides the most affordable Virtual Machines at a scale that meets GDPR, SOC2, and ISO27001 requirements.
Step 1: Sign Up and Set Up a NodeShift Cloud Account
Visit the NodeShift Platform and create an account. Once you’ve signed up, log into your account.
Follow the account setup process and provide the necessary details and information.
Step 2: Create a GPU Node (Virtual Machine)
GPU Nodes are NodeShift’s GPU Virtual Machines, on-demand resources equipped with diverse GPUs ranging from H100s to A100s. These GPU-powered VMs provide enhanced environmental control, allowing configuration adjustments for GPUs, CPUs, RAM, and Storage based on specific requirements.
Navigate to the menu on the left side. Select the GPU Nodes option, create a GPU Node in the Dashboard, click the Create GPU Node button, and create your first Virtual Machine deployment.
Step 3: Select a Model, Region, and Storage
In the “GPU Nodes” tab, select a GPU Model and Storage according to your needs and the geographical region where you want to launch your model.
We will use 1x RTX A6000 GPU for this tutorial to achieve the fastest performance. However, you can choose a more affordable GPU with less VRAM if that better suits your requirements.
Step 4: Select Authentication Method
There are two authentication methods available: Password and SSH Key. SSH keys are a more secure option. To create them, please refer to our official documentation.
Step 5: Choose an Image
Next, you will need to choose an image for your Virtual Machine. We will deploy NVIDIA SANA on an NVIDIA Cuda Virtual Machine. This proprietary, closed-source parallel computing platform will allow you to install NVIDIA SANA on your GPU Node.
After choosing the image, click the ‘Create’ button, and your Virtual Machine will be deployed.
Step 6: Virtual Machine Successfully Deployed
You will get visual confirmation that your node is up and running.
Step 7: Connect to GPUs using SSH
NodeShift GPUs can be connected to and controlled through a terminal using the SSH key provided during GPU creation.
Once your GPU Node deployment is successfully created and has reached the ‘RUNNING’ status, you can navigate to the page of your GPU Deployment Instance. Then, click the ‘Connect’ button in the top right corner.
Now open your terminal and paste the proxy SSH IP or direct SSH IP.
Next, if you want to check the GPU details, run the command below:
nvidia-smi
Step 8: Clone the Repository
Run the following command to clone the NVIDIA SANA repository:
git clone https://github.com/NVlabs/Sana.git
cd Sana
Step 9: Check the Available Python version and Install the new version
Run the following commands to check the available Python version.
If you check the version of the python, system has Python 3.8.1 available by default. To install a higher version of Python, you’ll need to use the deadsnakes
PPA.
Run the following commands to add the deadsnakes
PPA:
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt update
Step 10: Install Python 3.11
Now, run the following command to install Python 3.11 or another desired version:
sudo apt install -y python3.11 python3.11-distutils python3.11-venv
Step 11: Update the Default Python3
Version
Now, run the following command to link the new Python version as the default python3
:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2
sudo update-alternatives --config python3
Then, run the following command to verify that the new Python version is active:
python3 --version
Step 12: Install and Update Pip
Run the following command to install and update the pip:
python3 -m ensurepip --upgrade
python3 -m pip install --upgrade pip
Then, run the following command to check the version of pip:
pip --version
Step 13: Download Miniconda
Run the following command to download the miniconda:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
Then, run the following command to install it:
bash Miniconda3-latest-Linux-x86_64.sh
Step 14: Add Conda to PATH
Run the following command to add conda to path:
export PATH="$HOME/miniconda3/bin:$PATH"
Then, run the following command to reload your shell:
source ~/.bashrc
Then, run the following command to verify the conda installation:
conda --version
Step 15: Add Environment Setup
Run the following command to add environment setup:
./environment_setup.sh sana
Step 16: Install Gradio
Run the following command to install the gradio:
pip install gradio
Step 17: Run the Script
Execute the following command to run the script and start the server:
DEMO_PORT=15432 python3 app/app_sana.py \
M_1024px.pth \
--image_size=1024 \
--share \
--config=configs/sana_config/1024ms/Sana_1600M_img1024.yaml \
--model_path=hf://Efficient-Large-Model/Sana_1600M_1024px/checkpoints/Sana_1600M_1024px.pth \
--image_size=1024
Step 18: Access the Application and Generate Images
Accessing the application at: https://1f75620f0777c5e65e.gradio.live
Conclusion
In this guide, we introduced Sana, an innovative open-source text-to-image framework under the Apache License 2.0, designed for generating high-resolution images with remarkable efficiency. We provided a detailed step-by-step tutorial on installing Sana on a GPU-powered virtual machine using NodeShift, covering everything from configuring the environment and setting up essential tools to running the Sana application and generating high-quality images. By following this guide, you’ve learned how to install the required software, set up the necessary dependencies, and leverage Sana’s capabilities for streamlined content creation. Whether you’re a developer or an open-source enthusiast, Sana empowers you to explore and contribute to the future of high-resolution image synthesis.