Skip to content
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

Add low VRAM mode, CPU-only mode + image pre-loading fix #407

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FlyingFathead
Copy link

@FlyingFathead FlyingFathead commented Sep 7, 2024

  1. Low VRAM mode implemented: Introduced the unimplemented option lingering around in streamlit_helpers.py to run the model with half-precision (float16). Allows efficient usage on GPUs with limited memory, lowering memory requirements by half. I've tested this on a RTX 3060 w/ 12GB VRAM.

  2. CPU-only mode: added an option to run the model on CPUs for users without the necessary CUDA GPU hardware, though at slower speeds.

Both can be set with True/False in streamlit_helpers.py, although a more viable solution in the future would be to i.e. add a separate config.ini w/ configparser for the entire framework.

  1. Image Loading Fix: Fixed an issue where the app would throw an error if an image was not loaded before model execution. The model now uses a dummy tensor until the image is loaded in. See: video_sampling.py

@linlang171
Copy link

linlang171 commented Mar 16, 2025

PS D:\AI\stable video diffusion\generative-models> python scripts/sampling/simple_video_sample_4d.py
 --input_path assets/sv4d_videos/test_video1.mp4
WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
    PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.0.1+cpu)
    Python  3.10.11 (you have 3.10.0)
  Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers)  
  Memory-efficient attention, SwiGLU, sparse and more won't be available.
  Set XFORMERS_MORE_DETAILS=1 for more details
Reading assets/sv4d_videos/test_video1.mp4
preprocess assets/sv4d_videos/test_video1.mp4
Traceback (most recent call last):
  File "D:\AI\stable video diffusion\generative-models\scripts\sampling\simple_video_sample_4d.py", line 257, in <module>
    Fire(sample)
  File "D:\AI\stable video diffusion\generative-models\.pt2\lib\site-packages\fire\core.py", line 135, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "D:\AI\stable video diffusion\generative-models\.pt2\lib\site-packages\fire\core.py", line 468, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "D:\AI\stable video diffusion\generative-models\.pt2\lib\site-packages\fire\core.py", line 684, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "D:\AI\stable video diffusion\generative-models\scripts\sampling\simple_video_sample_4d.py", line 106, in sample
    images_v0 = read_video(processed_input_path, n_frames=n_frames, device=device)
  File "D:\AI\stable video diffusion\generative-models\scripts\demo\sv4d_helpers.py", line 163, in read_video
    image = ToTensor()(image).unsqueeze(0).to(device)
  File "D:\AI\stable video diffusion\generative-models\.pt2\lib\site-packages\torch\cuda\__init__.py", line 239, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

I use your branch and set USE_CUDA = False.I still get this error.What did I do wrong?Maybe I need to manually modify all .to(device) to .to('cpu)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants