Skip to content

Commit 0c6ed0e

Browse files
authored
fix: resolve multi-GPU device assignment bug (#273)
1 parent 5782690 commit 0c6ed0e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

python/pybind/sapien.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@ Generator<int> init_sapien(py::module &m) {
329329

330330
py::object obj = py::cast(newArray);
331331
auto as_tensor = py::module_::import("torch").attr("as_tensor");
332-
return as_tensor("data"_a = obj, "device"_a = "cuda");
332+
333+
std::string device_str = array.cudaId >= 0 ?
334+
"cuda:" + std::to_string(array.cudaId) : "cuda";
335+
return as_tensor("data"_a = obj, "device"_a = device_str);
333336
})
334337
#ifdef SAPIEN_CUDA
335338
.def("jax",

0 commit comments

Comments
 (0)