-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
colab t4 #33
Comments
!git clone https://github.com/NVlabs/Sana.git %cd /content/Sana !pip install torch %cd /content/Sana !git config --global credential.helper store !huggingface-cli login %env DEMO_PORT=15432 env: DEMO_PORT=15432 |
import torch Import the huggingface_hub libraryfrom huggingface_hub import hf_hub_download device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") sana = SanaPipeline("/content/Sana/configs/sana_config/512ms/Sana_600M_img512.yaml") Use hf_hub_download to download the model weightsrepo_id = "Efficient-Large-Model/Sana_1600M_512px" image = sana( 2024-11-23 06:52:38 - [Sana] - INFO - Sampler flow_dpm-solver, flow_shift: 1.0
|
The config file you are using is for 600M model, but the checkpoint is for 1600M model. |
!git clone https://github.com/newgenai79/Sana_win
%cd Sana_win
!git clone https://github.com/woct0rdho/triton-windows/releases
!/content/Sana_win/environment_setup.bat sana
!chmod +x /content/Sana_win/environment_setup.bat
!/content/Sana_win/environment_setup.bat sana
@echo off
setlocal enabledelayedexpansion
set CONDA_ENV=%1
if "%CONDA_ENV%"=="" (
echo Please provide a conda environment name
exit /b 1
)
echo Creating Conda Environment: %CONDA_ENV%
call conda create -n %CONDA_ENV% python=3.10.0 -y
echo Conda Environment Created Successfully
echo Activating Conda Environment: %CONDA_ENV%
call conda activate %CONDA_ENV%
echo Conda Environment Activated
echo Installing CUDA Toolkit
call conda install -c nvidia cuda-toolkit -y
echo CUDA Toolkit Installed Successfully
echo Activating Conda Environment: %CONDA_ENV%
call conda activate %CONDA_ENV%
echo Conda Environment Activated
echo Updating pip to latest version
python -m pip install --upgrade pip
echo Pip Updated Successfully
echo Activating Conda Environment: %CONDA_ENV%
call conda activate %CONDA_ENV%
echo Conda Environment Activated
echo Installing xformers
call pip install -U xformers==0.0.27.post2 --index-url https://download.pytorch.org/whl/cu121
echo Xformers Installed Successfully
echo Activating Conda Environment: %CONDA_ENV%
call conda activate %CONDA_ENV%
echo Conda Environment Activated
echo Installing project in editable mode
call pip install -e .
echo Project Installed Successfully
echo Activating Conda Environment: %CONDA_ENV%
call conda activate %CONDA_ENV%
echo Conda Environment Activated
echo Installing triton from wheel
pip install triton-3.0.0-cp310-cp310-win_amd64.whl
echo Installing triton complete
echo Environment Setup Complete!
#!/bin/bash
CONDA_ENV=$1
if [ -z "$CONDA_ENV" ]; then
echo "Please provide a conda environment name"
exit 1
fi
echo "Creating Conda Environment: $CONDA_ENV"
conda create -n "$CONDA_ENV" python=3.10.0 -y
echo "Conda Environment Created Successfully"
echo "Activating Conda Environment: $CONDA_ENV"
conda activate "$CONDA_ENV"
echo "Conda Environment Activated"
echo "Installing CUDA Toolkit"
conda install -c nvidia cuda-toolkit -y
echo "CUDA Toolkit Installed Successfully"
echo "Updating pip to latest version"
python -m pip install --upgrade pip
echo "Pip Updated Successfully"
echo "Installing xformers"
pip install -U xformers==0.0.27.post2 --index-url https://download.pytorch.org/whl/cu121
echo "Xformers Installed Successful"
%%writefile environment_setup.sh
#!/bin/bash
... (paste the bash script here) ...
#!/bin/bash
CONDA_ENV=$1
if [ -z "$CONDA_ENV" ]; then
echo "Please provide a conda environment name"
exit 1
fi
echo "Creating Conda Environment: $CONDA_ENV"
conda create -n "$CONDA_ENV" python=3.10.0 -y
echo "Conda Environment Created Successfully"
echo "Activating Conda Environment: $CONDA_ENV"
conda activate "$CONDA_ENV"
echo "Conda Environment Activated"
echo "Installing CUDA Toolkit"
conda install -c nvidia cuda-toolkit -y
echo "CUDA Toolkit Installed Successfully"
echo "Updating pip to latest version"
python -m pip install --upgrade pip
echo "Pip Updated Successfully"
echo "Installing xformers"
pip install -U xformers==0.0.27.post2 --index-url https://download.pytorch.org/whl/cu121
echo "Xformers Installed Successful"
!chmod +x environment_setup.sh
!./environment_setup.sh sana
Step 1: Clone the repository
Step 2: Navigate inside the cloned repository
Step 3: Download triton wheel and place in Sana_win (triton-3.0.0-cp310-cp310-win_amd64.whl)
Step 4: Install requirements (make sure conda or miniconda is installed)
Step 5: Download models (refer main repository https://github.com/NVlabs/Sana#-news)
mkdir Efficient-Large-Model\Sana_1600M_512px\checkpoints
mkdir Efficient-Large-Model\Sana_1600M_1024px\checkpoints
Step 6: Gradio UI (1.6B)
512x512 model
python app\app_sana.py --config configs\sana_config\512ms\Sana_1600M_img512.yaml --model_path Efficient-Large-Model\Sana_1600M_512px\checkpoints\Sana_1600M_512px.pth
!git clone https://github.com/newgenai79/Sana_win
%cd Sana_win
!wget -P Sana_win https://github.com/woct0rdho/triton-windows/releases/download/v3.0.0/triton-3.0.0-cp310-cp310-win_amd64.whl
!pip install tritonclient[http]
!chmod +x environment_setup.sh
!./environment_setup.sh sana
import os
from getpass import getpass
HF_TOKEN = getpass("Enter your Hugging Face access token:hR")
os.environ["HF_TOKEN"] = HF_TOKEN
!huggingface-cli login
!mkdir -p Efficient-Large-Model/Sana_1600M_512px/checkpoints
!wget -P Efficient-Large-Model/Sana_1600M_512px/checkpoints https://huggingface.co/newgenai/Sana/resolve/main/Efficient-Large-Model/Sana_1600M_512px/checkpoints/Sana_1600M_512px.pth
cache_dir="./Efficient-Large-Model/Sana_1600M_512px/checkpoints"
#!pip install huggingface_hub
import os
from getpass import getpass # Import the getpass function
from huggingface_hub import hf_hub_download, login
Get the Hugging Face access token
HF_TOKEN = getpass("Enter your Hugging Face access token:")
Log in to Hugging Face using the access token
login(token=HF_TOKEN)
Download the file
file_path = hf_hub_download(
repo_id="Efficient-Large-Model/Sana_1600M_1024px",
filename="checkpoints/Sana_1600M_1024px.pth",
cache_dir="./Efficient-Large-Model/Sana_1600M_1024px/checkpoints", # local path
token=HF_TOKEN
)
print(f"File downloaded to: {file_path}")
!pip install gradio
!pip install spaces
!python /content/Sana_win/app/app_sana.py --config configs/sana_config/512ms/Sana_1600M_img512.yaml --model_path Efficient-Large-Model/Sana_1600M_512px/checkpoints/Sana_1600M_512px.pth
import torch
import torchvision
print(f"PyTorch CUDA version: {torch.version.cuda}")
print(f"torchvision CUDA version: {torchvision.version}")
!pip uninstall torchvision -y
!pip install torchvision==0.16.0+cu118 -f https://download.pytorch.org/whl/torch_stable.html
!apt-get install cuda-toolkit-11-8 # example if CUDA 11.8 is needed
!python /content/Sana_win/app/app_sana.py --config configs/sana_config/512ms/Sana_1600M_img512.yaml --model_path Efficient-Large-Model/Sana_1600M_512px/checkpoints/Sana_1600M_512px.pth
!apt-get install libjpeg-dev libpng-dev -y
!pip install torch torchvision --upgrade
Traceback (most recent call last):
File "/content/Sana_win/app/app_sana.py", line 34, in
from app.sana_pipeline import SanaPipeline
ModuleNotFoundError: No module named 'app'
/content/Sana_win/app/app_sana_512.py
!python /content/Sana_win/app/app_sana_512.py --config /content/Sana_win/configs/sana_config/512ms/Sana_1600M_img512.yaml --model_path Efficient-Large-Model/Sana_1600M_512px/checkpoints/Sana_1600M_512px.pth
!python /content/Sana_win/app/app_sana_512.py
!pip install --upgrade torch
!pip install torch==1.13.0+cu117 # Adjust version and CUDA as needed
!python app/app_sana.py --config configs/sana_config/512ms/Sana_1600M_img512.yaml --model_path Efficient-Large-Model/Sana_1600M_512px/checkpoints/Sana_1600M_512px.pth
!python /content/Sana_win/app/app_sana_512.py --config /content/Sana_win/configs/sana_config/512ms/Sana_1600M_img512.yaml --model_path Efficient-Large-Model/Sana_1600M_512px/checkpoints/Sana_1600M_512px.pth
%cd /content/Sana_win/app
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
!python app_sana_512.py
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
!python app_sana_512.py
!python /content/Sana_win/app/app_sana_512.py --config /content/Sana_win/configs/sana_config/512ms/Sana_1600M_img512.yaml --model_path Efficient-Large-Model/Sana_1600M_512px/checkpoints/Sana_1600M_512px.pth
!python app_sana_512.py --config configs/sana_config/512ms/Sana_1600M_img512.yaml --model_path Efficient-Large-Model/Sana_1600M_512px/checkpoints/Sana_1600M_512px.pth
!cat /content/Sana_win/app/app_sana_512.py
with open('/content/Sana_win/app/app_sana_512.py', 'r') as f:
print(f.read())
!python /content/Sana_win/app/app_sana_512.py
The text was updated successfully, but these errors were encountered: