@@ -75,6 +75,14 @@ def __init__(
7575 settings = SettingsManager .instance ()
7676 self ._use_fabric = bool (settings .get ("/physics/fabricEnabled" , False ))
7777
78+ if self ._use_fabric and self ._device not in ("cuda" , "cuda:0" ):
79+ logger .warning (
80+ f"Fabric mode is not supported on device '{ self ._device } '. "
81+ "USDRT SelectPrims and Warp fabric arrays only support cuda:0. "
82+ "Falling back to standard USD operations. This may impact performance."
83+ )
84+ self ._use_fabric = False
85+
7886 self ._fabric_initialized = False
7987 self ._fabric_usd_sync_done = False
8088 self ._fabric_selection = None
@@ -154,7 +162,7 @@ def set_world_poses(self, positions=None, orientations=None, indices=None):
154162 indices_wp ,
155163 self ._view_to_fabric ,
156164 ],
157- device = self ._device ,
165+ device = self ._fabric_device ,
158166 )
159167 wp .synchronize ()
160168
@@ -192,7 +200,7 @@ def get_world_poses(self, indices: wp.array | None = None) -> tuple[ProxyArray,
192200 indices_wp ,
193201 self ._view_to_fabric ,
194202 ],
195- device = self ._device ,
203+ device = self ._fabric_device ,
196204 )
197205
198206 if use_cached :
@@ -245,7 +253,7 @@ def set_scales(self, scales, indices=None):
245253 indices_wp ,
246254 self ._view_to_fabric ,
247255 ],
248- device = self ._device ,
256+ device = self ._fabric_device ,
249257 )
250258 wp .synchronize ()
251259
@@ -281,7 +289,7 @@ def get_scales(self, indices=None):
281289 indices_wp ,
282290 self ._view_to_fabric ,
283291 ],
284- device = self ._device ,
292+ device = self ._fabric_device ,
285293 )
286294
287295 if use_cached :
@@ -325,14 +333,14 @@ def _rebuild_fabric_arrays(self) -> None:
325333 f"Prim count changed ({ self .count } vs { self ._default_view_indices .shape [0 ]} ). "
326334 "Fabric topology change added/removed tracked prims — full re-initialization required."
327335 )
328- self ._view_to_fabric = wp .zeros ((self .count ,), dtype = wp .uint32 , device = self ._device )
336+ self ._view_to_fabric = wp .zeros ((self .count ,), dtype = wp .uint32 , device = self ._fabric_device )
329337 self ._fabric_to_view = wp .fabricarray (self ._fabric_selection , self ._view_index_attr )
330338
331339 wp .launch (
332340 kernel = fabric_utils .set_view_to_fabric_array ,
333341 dim = self ._fabric_to_view .shape [0 ],
334342 inputs = [self ._fabric_to_view , self ._view_to_fabric ],
335- device = self ._device ,
343+ device = self ._fabric_device ,
336344 )
337345 wp .synchronize ()
338346
@@ -378,22 +386,34 @@ def _initialize_fabric(self) -> None:
378386 )
379387 wp .synchronize ()
380388
389+ fabric_device = self ._device
390+ if self ._device == "cuda" :
391+ logger .warning ("Fabric device is not specified, defaulting to 'cuda:0'." )
392+ fabric_device = "cuda:0"
393+ elif self ._device .startswith ("cuda:" ):
394+ if self ._device != "cuda:0" :
395+ logger .debug (
396+ f"SelectPrims only supports cuda:0. Using cuda:0 for SelectPrims "
397+ f"even though simulation device is { self ._device } ."
398+ )
399+ fabric_device = "cuda:0"
400+
381401 self ._fabric_selection = fabric_stage .SelectPrims (
382402 require_attrs = [
383403 (usdrt .Sdf .ValueTypeNames .UInt , self ._view_index_attr , usdrt .Usd .Access .Read ),
384404 (usdrt .Sdf .ValueTypeNames .Matrix4d , "omni:fabric:worldMatrix" , usdrt .Usd .Access .ReadWrite ),
385405 ],
386- device = self . _device ,
406+ device = fabric_device ,
387407 )
388408
389- self ._view_to_fabric = wp .zeros ((self .count ,), dtype = wp .uint32 , device = self . _device )
409+ self ._view_to_fabric = wp .zeros ((self .count ,), dtype = wp .uint32 , device = fabric_device )
390410 self ._fabric_to_view = wp .fabricarray (self ._fabric_selection , self ._view_index_attr )
391411
392412 wp .launch (
393413 kernel = fabric_utils .set_view_to_fabric_array ,
394414 dim = self ._fabric_to_view .shape [0 ],
395415 inputs = [self ._fabric_to_view , self ._view_to_fabric ],
396- device = self . _device ,
416+ device = fabric_device ,
397417 )
398418 wp .synchronize ()
399419
@@ -405,6 +425,7 @@ def _initialize_fabric(self) -> None:
405425 self ._fabric_dummy_buffer = wp .zeros ((0 , 3 ), dtype = wp .float32 , device = self ._device )
406426 self ._fabric_world_matrices = wp .fabricarray (self ._fabric_selection , "omni:fabric:worldMatrix" )
407427 self ._fabric_stage = fabric_stage
428+ self ._fabric_device = fabric_device
408429
409430 self ._fabric_initialized = True
410431 self ._fabric_usd_sync_done = False
0 commit comments