[Fix] Replace hardcoded .cuda() with device-aware .to() in MinkUNet voxelization#3140
[Fix] Replace hardcoded .cuda() with device-aware .to() in MinkUNet voxelization#3140Mr-Neutr0n wants to merge 2 commits into
Conversation
…oxelization In Det3DDataPreprocessor.voxelize(), the minkunet branch converts numpy arrays back to tensors using torch.from_numpy(...).cuda(), which hardcodes the CUDA device. This causes failures when running on CPU-only environments or when the input data resides on a specific device (e.g., cuda:1). Replace .cuda() with .to(res.device) to correctly place tensors on the same device as the input point cloud.
|
|
|
I have read the CLA Document and I hereby sign the CLA |
|
The 2-line fix in The
It cannot have introduced a new failure on the 1.8.1/3.7 matrix because the semantic at the call sites is unchanged for any single-GPU CUDA run. Almost certainly a pre-existing flake on that old combo or an unrelated dependency issue. Worth re-running the |
|
Pushed a no-op commit ( |
Motivation
In
Det3DDataPreprocessor.voxelize(), theminkunetvoxelization branch converts numpy arrays back to tensors usingtorch.from_numpy(...).cuda(). This hardcodes the CUDA device assumption, which causes:cuda:0regardless of which device the input data resides on (e.g.,cuda:1), leading to device mismatch errors during subsequent operationsModification
Replace
.cuda()with.to(res.device)for bothpoint2voxel_mapandindstensors, whereresis the input point cloud tensor already on the correct device. This is consistent with how device handling is done elsewhere in the same file (e.g., using.new_tensor()andF.pad()which inherit the device from existing tensors).Before:
After:
BC-breaking (No)
This is a backward-compatible fix. On CUDA environments,
res.devicewill becuda:X(matching the previous behavior when oncuda:0), and it additionally supports CPU and multi-GPU scenarios correctly.