Fix KITTI eval and checkpoint loading on numpy>=2 / torch>=2.6 - #1773
blancnight2 wants to merge 1 commit into
Conversation
Two independent compatibility fixes needed to run OpenPCDet on current
toolchains:
1. rotate_iou.py: the numba.cuda kernel fails type inference
("Signature mismatch" raised from FixupArgs) on recent numba
releases combined with numpy >= 2.0. Replace it with a thin PyTorch
wrapper around the project's own compiled boxes_overlap_bev_gpu op.
This removes the numba requirement for KITTI evaluation entirely
rather than pinning numpy back to <2.
The rectangle geometry is reproduced exactly by setting
heading = -angle: the original code rotates local corners by
[[cos,sin],[-sin,cos]] = R(-angle), while boxes_overlap_bev_gpu
rotates by R(heading).
Verified against an independent shapely reference that implements
the original corner convention, over random boxes and all four
criterion values: max abs error 9.0e-07 (IoU), 1.3e-06 and 6.2e-07
(the two ratio criteria), 6.9e-05 (raw intersection area, in area
units) -- i.e. float32 round-off.
2. detector3d_template.py: torch 2.6 flipped the default of torch.load
to weights_only=True, which breaks loading OpenPCDet checkpoints
since they contain more than plain tensors. Pass weights_only=False
explicitly at the two checkpoint load sites.
|
Two clarifications after re-reading my own description. 1. Scope of the numba change. To be precise, this removes the For reference, the failure is limited to evaluation — training and inference never 2. The same kernel is duplicated elsewhere. The identical That makes three implementations of rotated-rectangle intersection in the repo: |
What
Two independent compatibility fixes needed to run OpenPCDet on current toolchains
(numpy >= 2.0, torch >= 2.6). Both currently block evaluation out of the box.
1.
rotate_iou.py— drop the numba dependencyThe
numba.cudakernel used by the KITTI evaluator fails type inference on recentnumba releases combined with numpy >= 2.0, raising
Signature mismatchfromFixupArgs. The workaround circulating in the issue tracker is to pinnumpy==1.23, which is not viable on newer toolchains (and conflicts with otherpackages in a modern CUDA 12.x environment).
Instead of pinning numpy back, this PR removes the numba.cuda GPU-kernel path from KITTI evaluation (the part that breaks); the CPU @numba.jit functions in eval.py are untouched and continue to work by reimplementing
rotate_iou_gpu_evalas a thin PyTorchwrapper around the project's own compiled
boxes_overlap_bev_gpuop(
pcdet/ops/iou3d_nms). That op is already a hard dependency of OpenPCDet, sono new dependency is introduced — one is removed.
Geometry equivalence. The original code builds corners and rotates them by
[[cos, sin], [-sin, cos]], which isR(-angle), whereasboxes_overlap_bev_gpurotates by
R(heading). Settingheading = -angle(withdx = x_d,dy = y_d)makes the two rectangles identical, so the returned intersection area matches.
2.
detector3d_template.py—weights_only=Falsetorch 2.6 flipped the default of
torch.loadtoweights_only=True. OpenPCDetcheckpoints contain more than plain tensors, so loading them now fails. This PR
passes
weights_only=Falseexplicitly at the two checkpoint load sites.Verification
rotate_iou_gpu_evalwas checked against an independent shapely reference thatreimplements the original corner convention, over random boxes and all four
criterionvalues:criterion-101i.e. float32 round-off. End-to-end, PointPillars trained for 80 epochs evaluates
normally on KITTI val with this evaluator (3D AP R40 — Car 85.59 / 75.60 / 72.76,
Pedestrian 50.79 / 43.75 / 39.12, Cyclist 79.72 / 62.05 / 57.71).
Environment
Ubuntu 20.04 (WSL2), torch 2.11.0+cu128, CUDA 12.8, RTX 5070 (sm_120), numpy 2.2,
spconv-cu124.
Notes
device_idis now honoured (tensors are placed oncuda:device_id) instead ofbeing ignored.
torch.cuda.FloatTensor(...)constructor is avoided.iou3d_nmsop at eval time. This isalready required to run any detector in OpenPCDet, so it should not be a new
constraint in practice — happy to guard it behind a try/except with a clear
error message if maintainers prefer.