Spaces:
Configuration error
Configuration error
Wei Liu Claude Sonnet 4.6 commited on
Commit ·
6dad5cc
1
Parent(s): 0cdce4a
Fix Genesis RuntimeError: don't move simulator tensors to GPU
Browse filesGenesis uses backend=gs.cpu — all simulation runs on CPU. Moving
simulator tensors to CUDA caused two bugs:
1. scene.reset() raises "Tensor subclass already associated" because
Genesis internally tries to re-wrap CPU tensors that conflict with
our moved CUDA tensors.
2. state.pos from solver.get_state() is always on CPU, so
particles_now - init_particles_gpu would be a CPU/CUDA mismatch.
Fix: remove simulator.move_to_device() calls. Only the video generator
pipeline (transformer, VAE, text encoder) and case data (latents,
embeddings) are moved to GPU. Simulation and PyTorch3D rendering stay
on CPU throughout.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -489,11 +489,10 @@ def do_generate(case_name, prompt, d0, s0, d1, s1, d2, s2):
|
|
| 489 |
return
|
| 490 |
|
| 491 |
# Transfer all CPU-resident state to GPU for this generation session.
|
|
|
|
|
|
|
| 492 |
video_generator.move_pipeline_to_device("cuda")
|
| 493 |
video_generator.move_case_data_to_device("cuda")
|
| 494 |
-
for _b in cases.values():
|
| 495 |
-
if _b.simulator is not None:
|
| 496 |
-
_b.simulator.move_to_device("cuda")
|
| 497 |
|
| 498 |
bundle = cases[case_name]
|
| 499 |
|
|
@@ -686,9 +685,6 @@ def do_generate(case_name, prompt, d0, s0, d1, s1, d2, s2):
|
|
| 686 |
if video_generator is not None:
|
| 687 |
video_generator.move_pipeline_to_device("cpu")
|
| 688 |
video_generator.move_case_data_to_device("cpu")
|
| 689 |
-
for _b in cases.values():
|
| 690 |
-
if _b is not None and _b.simulator is not None:
|
| 691 |
-
_b.simulator.move_to_device("cpu")
|
| 692 |
torch.cuda.empty_cache()
|
| 693 |
_is_generating = False
|
| 694 |
|
|
|
|
| 489 |
return
|
| 490 |
|
| 491 |
# Transfer all CPU-resident state to GPU for this generation session.
|
| 492 |
+
# NOTE: simulators are NOT moved to GPU — Genesis uses backend=gs.cpu and
|
| 493 |
+
# simulation tensors must remain on CPU alongside Genesis internal state.
|
| 494 |
video_generator.move_pipeline_to_device("cuda")
|
| 495 |
video_generator.move_case_data_to_device("cuda")
|
|
|
|
|
|
|
|
|
|
| 496 |
|
| 497 |
bundle = cases[case_name]
|
| 498 |
|
|
|
|
| 685 |
if video_generator is not None:
|
| 686 |
video_generator.move_pipeline_to_device("cpu")
|
| 687 |
video_generator.move_case_data_to_device("cpu")
|
|
|
|
|
|
|
|
|
|
| 688 |
torch.cuda.empty_cache()
|
| 689 |
_is_generating = False
|
| 690 |
|