showlab / DragAnything

[ECCV 2024] DragAnything: Motion Control for Anything using Entity Representation
417 stars 13 forks source link

Problems with running gradio_run.py using multiple graphics cards #13

Open Pruokai opened 7 months ago

Pruokai commented 7 months ago

When I run gradio_run.py, the video memory is insufficient, so I want to use multiple 4090 graphics cards. How can I modify it?

weijiawu commented 7 months ago

The current model may require over 20 GB of GPU memory, or you can simply adjust the inference "frame_number" to be smaller. It's currently set at 14; you can try 8 frames or 10 frames.

Pruokai commented 7 months ago

The current model may require over 20 GB of GPU memory, or you can simply adjust the inference "frame_number" to be smaller. It's currently set at 14; you can try 8 frames or 10 frames.

I set "frame_number" to 10, but got an error: Traceback (most recent call last): File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/gradio/queueing.py", line 501, in call_prediction output = await route_utils.call_process_api( File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/gradio/route_utils.py", line 258, in call_process_api output = await app.get_blocks().process_api( File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1684, in process_api result = await self.call_function( File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1250, in call_function prediction = await anyio.to_thread.run_sync( File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread return await future File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 851, in run result = context.run(func, args) File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/gradio/utils.py", line 750, in wrapper response = f(args, kwargs) File "/home/pengrk/code/DragAnything/gradio_run.py", line 386, in run video_frames = self.pipeline(validation_image, validation_control_images[:self.model_length], decode_chunk_size=8,num_frames=self.model_length,motion_bucket_id=motion_bucket_id,controlnet_cond_scale=1.0,height=self.height,width=self.width,ids_embedding=ids_embedding[:self.model_length]).frames File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, *kwargs) File "/home/pengrk/code/DragAnything/pipeline/pipeline_svd_DragAnything.py", line 568, in call down_block_res_samples, mid_block_res_sample = self.controlnet( File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/home/pengrk/code/DragAnything/venv/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward output = module._old_forward(*args, **kwargs) File "/home/pengrk/code/DragAnything/models/DragAnything.py", line 621, in forward sample = sample + controlnet_cond RuntimeError: The size of tensor a (28) must match the size of tensor b (20) at non-singleton dimension 0

weijiawu commented 7 months ago

The error is caused by the inconsistency between the frame numbers of the condition and latent noise. You need to set the hyperparameters at both L410 and L433 to be 10 simultaneously.