Closed Vargol closed 6 hours ago
run command?
https://colab.research.google.com/drive/1HSXXSv1WRsV0flaedvi5WOpZLvAK6n8r?usp=sharing
%%bash
git clone https://github.com/NVlabs/Sana.git
cd Sana
pip install -e .
import sys
import os
sys.path.insert(0, os.path.abspath('Sana'))
import torch
from app.sana_pipeline import SanaPipeline
from torchvision.utils import save_image
device = torch.device("cuda")
generator = torch.Generator(device=device).manual_seed(42)
sana = SanaPipeline("/content/Sana/configs/sana_config/1024ms/Sana_1600M_img1024.yaml")
^^^^ fails here.
Try this one, and let's see if it will work.
import pyrallis
from app.sana_pipeline import SanaInference
config = pyrallis.parse(config_class=SanaInference, config_path="/content/Sana/configs/sana_config/1024ms/Sana_1600M_img1024.yaml")
Same error by the looks of it
colab_kernel_launcher.py: error: unrecognized arguments: -f /root/.local/share/jupyter/runtime/kernel-44d5aa92-13f8-4c86-a46e-c6a472635a6b.json
An exception has occurred, use %tb to see the full traceback.
import sys
import os
sys.path.insert(0, os.path.abspath('Sana'))
import pyrallis
from app.sana_pipeline import SanaInference
config = pyrallis.parse(config_class=SanaInference, config_path="/content/Sana/configs/sana_config/1024ms/Sana_1600M_img1024.yaml")
Then, I suggest you to try if your machine can run with pyrallis
. Seems it's something related to this package.
make a new train.py file with:
from dataclasses import dataclass
import pyrallis
@dataclass
class TrainConfig:
""" Training config for Machine Learning """
workers: int = 8 # The number of workers for training
exp_name: str = 'default_exp' # The experiment name
def main():
cfg = pyrallis.parse(config_class=TrainConfig)
print(f'Training {cfg.exp_name} with {cfg.workers} workers...')
main()
make a new train.yaml file with:
workers: 4
exp_name: "test"
$ python train.py --config_path=train.yaml
Training my_first_exp with 42 workers...
that worked,
Training default_exp with 8 workers...
could this be something like pyrasllis doesn't play well with notebooks ?
okay running the inference script as a file gets me further, as it now downloads the models and looks like its starting to do something but doesn't seems to generate anything and outputs a ^C at the end...
! python run_sana.py
2024-11-22 13:37:22.655597: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-11-22 13:37:22.938755: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-11-22 13:37:23.017131: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-11-22 13:37:23.500011: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-11-22 13:37:25.688638: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-11-22 21:37:33 - [Sana] - INFO - Sampler flow_dpm-solver, flow_shift: 3.0
2024-11-22 21:37:33 - [Sana] - INFO - Inference with torch.float16, PAG guidance layer: [8]
[DC-AE] Loading model from mit-han-lab/dc-ae-f32c32-sana-1.0
Loading checkpoint shards: 100% 2/2 [00:01<00:00, 1.52it/s]
2024-11-22 21:38:28 - [Sana] - WARNING - use pe: False, position embed interpolation: 1.0, base size: 32
2024-11-22 21:38:28 - [Sana] - WARNING - attention type: linear; ffn type: glumbconv; autocast linear attn: False
^C
This fixes it in SanaPipeline:
# config = pyrallis.parse(config_class=SanaInference, config_path=config)
config = pyrallis.load(SanaInference, open(config, "r"))
^C
means Ctrl-C, try to re-run the code.
I had with the same results, including the printing the ^C to the terminal,. Now I can run it it directly from the notebook , it seems that running as a python script was 'hiding' the colab running out of system RAM, I'd guess that it running as a separate process to the notebook allowed a break to be sent to the processes rather than the hard restart running it as a notebook seems to require.
config = pyrallis.load(SanaInference, open(config, "r")) SanaPipeline
import torch from app.sana_pipeline import SanaPipeline from torchvision.utils import save_image
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") generator = torch.Generator(device=device).manual_seed(42)
sana = SanaPipeline("/content/Sana/configs/sana_config/1024ms/Sana_1600M_img1024.yaml") sana.from_pretrained("hf://Efficient-Large-Model/Sana_1600M_1024px/checkpoints/Sana_1600M_1024px.pth") prompt = 'a cyberpunk cat with a neon sign that says "Sana"'
image = sana( prompt=prompt, height=128, width=128, guidance_scale=5.0, pag_guidance_scale=2.0, num_inference_steps=18, generator=generator, ) save_image(image, 'output/sana.png', nrow=1, normalize=True, value_range=(-1, 1))
Your session crashed after using all available RAM.
colab t4
import os import sys sys.path.insert(0, os.path.abspath('Sana'))
from huggingface_hub import login from google.colab import userdata
import torch from app.sana_pipeline import SanaPipeline from torchvision.utils import save_image
device = torch.device("cuda") generator = torch.Generator(device=device).manual_seed(42)
sana = SanaPipeline("/content/Sana/configs/sana_config/1024ms/Sana_1600M_img1024.yaml") sana.from_pretrained("hf://Efficient-Large-Model/Sana_1600M_1024px/checkpoints/Sana_1600M_1024px.pth") prompt = 'a cyberpunk cat with a neon sign that says "Sana"'
image = sana( prompt=prompt, height=1024, width=1024, guidance_scale=5.0, pag_guidance_scale=2.0, num_inference_steps=18, generator=generator, ) save_image(image, 'output/sana.png', nrow=1, normalize=True, value_range=(-1, 1))
2024-11-23 03:10:55 - [Sana] - INFO - Sampler flow_dpm-solver, flow_shift: 3.0 2024-11-23 03:10:55 - [Sana] - INFO - Inference with torch.float16, PAG guidance layer: [8] [DC-AE] Loading model from mit-han-lab/dc-ae-f32c32-sana-1.0 Loading checkpoint shards: 100% 2/2 [00:01<00:00, 1.35it/s] 2024-11-23 03:12:04 - [Sana] - WARNING - use pe: False, position embed interpolation: 1.0, base size: 32 2024-11-23 03:12:04 - [Sana] - WARNING - attention type: linear; ffn type: glumbconv; autocast linear attn: False
Your session crashed after using all available RAM. View runtime logs Skip
colab t4
I had with the same results, including the printing the ^C to the terminal,. Now I can run it it directly from the notebook , it seems that running as a python script was 'hiding' the colab running out of system RAM, I'd guess that it running as a separate process to the notebook allowed a break to be sent to the processes rather than the hard restart running it as a notebook seems to require.
how???
code???????
!python /content/Sana/scripts/inference.py
[1] 25s !python /content/Sana/scripts/inference.py 2024-11-22 19:16:59.870052: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. Couldn't find the field 'data' in the dict with keys [] Couldn't find the field 'model' in the dict with keys [] Couldn't find the field 'vae' in the dict with keys [] Couldn't find the field 'text_encoder' in the dict with keys [] Couldn't find the field 'scheduler' in the dict with keys [] Couldn't find the field 'train' in the dict with keys [] Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/pyrallis/parsers/decoding.py", line 86, in decode_dataclass instance = cls(**init_args) # type: ignore TypeError: SanaInference.init() missing 6 required positional arguments: 'data', 'model', 'vae', 'text_encoder', 'scheduler', and 'train'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/content/Sana/scripts/inference.py", line 264, in
I had with the same results, including the printing the ^C to the terminal,. Now I can run it it directly from the notebook , it seems that running as a python script was 'hiding' the colab running out of system RAM, I'd guess that it running as a separate process to the notebook allowed a break to be sent to the processes rather than the hard restart running it as a notebook seems to require.
how???
code???????
The code is in the notebook I shared earlier, running the code in python I just copied the inference code to a python file, run_sana.py, and created a cell with ! python run_sana.py
instead of the cell with the inference code.
Just to be clear it still probably ran out of memory, I just got the Ctrl-C termination instead of the whole colab restarting.
Hi, trying to run this on Colab as may main I computer is MacOS, but I'm getting issues with the example code in the README.
The error I get is...
%tb gives...
Any idea what might be the issue ?