Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: buffer size must be a multiple of element size #3067

Open
3 tasks done
DongmingMMM opened this issue Dec 9, 2024 · 1 comment
Open
3 tasks done

ValueError: buffer size must be a multiple of element size #3067

DongmingMMM opened this issue Dec 9, 2024 · 1 comment

Comments

@DongmingMMM
Copy link

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

main branch https://github.com/open-mmlab/mmdetection3d

Environment

sys.platform: darwin
Python: 3.9.20 (main, Oct 3 2024, 02:27:54) [Clang 14.0.6 ]
CUDA available: False
MUSA available: False
numpy_random_seed: 2147483648
GCC: Apple clang version 15.0.0 (clang-1500.3.9.4)
PyTorch: 1.11.0
PyTorch compiling details: PyTorch built with:

  • GCC 4.2
  • C++ Version: 201402
  • clang 12.0.0
  • Intel(R) oneAPI Math Kernel Library Version 2023.1-Product Build 20230303 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v2.5.2 (Git Hash a9302535553c73243c632ad3c4c80beec3d19a1e)
  • LAPACK is enabled (usually provided by MKL)
  • NNPACK is enabled
  • CPU capability usage: AVX2
  • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CXX_COMPILER=/Applications/Xcode-12.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -Wno-deprecated-declarations -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-range-loop-analysis -Wno-pass-failed -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -fcolor-diagnostics -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-unused-private-field -Wno-missing-braces -Wno-c++14-extensions -Wno-constexpr-not-const, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.11.0, USE_CUDA=0, USE_CUDNN=OFF, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=OFF, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=ON, USE_OPENMP=OFF, USE_ROCM=OFF,

TorchVision: 0.12.0
OpenCV: 4.10.0
MMEngine: 0.10.4
MMDetection: 3.2.0
MMDetection3D: 1.4.0+fe25f7a
spconv2.0: False

Reproduces the problem - code sample

pcd_demo.py

Reproduces the problem - command or script

I encountered the same errors when I try to visualize kitti demo and my own config (alongwith custom kitti format dataset) on my iMac.
I ran the command:
python demo/pcd_demo.py output_kitti.pcd configs/pointpillars/pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py checkpoints/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class_20220301_150306-37dc2420.pth --show --device cpu

Reproduces the problem - error message

python demo/pcd_demo.py output_kitti.pcd configs/pointpillars/pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py checkpoints/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class_20220301_150306-37dc2420.pth --show --device cpu
12/09 21:47:51 - mmengine - WARNING - Display device not found. --show is forced to False
/Users/dongming/Documents/mmdetection3d/mmdet3d/models/dense_heads/anchor3d_head.py:94: UserWarning: dir_offset and dir_limit_offset will be depressed and be incorporated into box coder in the future
warnings.warn(
Loads checkpoint by local backend from path: checkpoints/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class_20220301_150306-37dc2420.pth
The model and loaded state dict do not match exactly

size mismatch for bbox_head.conv_cls.weight: copying a param with shape torch.Size([18, 384, 1, 1]) from checkpoint, the shape in current model is torch.Size([2, 384, 1, 1]).
size mismatch for bbox_head.conv_cls.bias: copying a param with shape torch.Size([18]) from checkpoint, the shape in current model is torch.Size([2]).
size mismatch for bbox_head.conv_reg.weight: copying a param with shape torch.Size([42, 384, 1, 1]) from checkpoint, the shape in current model is torch.Size([14, 384, 1, 1]).
size mismatch for bbox_head.conv_reg.bias: copying a param with shape torch.Size([42]) from checkpoint, the shape in current model is torch.Size([14]).
size mismatch for bbox_head.conv_dir_cls.weight: copying a param with shape torch.Size([12, 384, 1, 1]) from checkpoint, the shape in current model is torch.Size([4, 384, 1, 1]).
size mismatch for bbox_head.conv_dir_cls.bias: copying a param with shape torch.Size([12]) from checkpoint, the shape in current model is torch.Size([4]).
12/09 21:47:51 - mmengine - WARNING - Failed to search registry with scope "mmdet3d" in the "function" registry tree. As a workaround, the current "function" registry in "mmengine" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet3d" is a correct scope, or whether the registry is initialized.
/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/mmengine/visualization/visualizer.py:196: UserWarning: Failed to add <class 'mmengine.visualization.vis_backend.LocalVisBackend'>, please provide the save_dir argument.
warnings.warn(f'Failed to add {vis_backend.class}, '
Inference ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Traceback (most recent call last):
File "/Users/dongming/Documents/mmdetection3d/demo/pcd_demo.py", line 93, in
main()
File "/Users/dongming/Documents/mmdetection3d/demo/pcd_demo.py", line 83, in main
inferencer(**call_args)
File "/Users/dongming/Documents/mmdetection3d/mmdet3d/apis/inferencers/base_3d_inferencer.py", line 210, in call
for data in (track(inputs, description='Inference')
File "/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/rich/progress.py", line 168, in track
yield from progress.track(
File "/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/rich/progress.py", line 1210, in track
for value in sequence:
File "/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/mmengine/infer/infer.py", line 291, in preprocess
yield from map(self.collate_fn, chunked_data)
File "/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/mmengine/infer/infer.py", line 588, in _get_chunk_data
processed_data = next(inputs_iter)
File "/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/mmengine/dataset/base_dataset.py", line 60, in call
data = t(data)
File "/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/mmcv/transforms/base.py", line 12, in call
return self.transform(results)
File "/Users/dongming/Documents/mmdetection3d/mmdet3d/datasets/transforms/loading.py", line 1145, in transform
return self.from_file(inputs)
File "/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/mmcv/transforms/base.py", line 12, in call
return self.transform(results)
File "/Users/dongming/Documents/mmdetection3d/mmdet3d/datasets/transforms/loading.py", line 646, in transform
points = self._load_points(pts_file_path)
File "/Users/dongming/Documents/mmdetection3d/mmdet3d/datasets/transforms/loading.py", line 623, in _load_points
points = np.frombuffer(pts_bytes, dtype=np.float32)
ValueError: buffer size must be a multiple of element size

Additional information

I followed the instructions on https://mmdetection3d.readthedocs.io/en/latest/user_guides/inference.html.
Screenshot 2024-12-09 at 21 41 56
The code said the the it should be a 'PCD_FILE' but the example below was a .bin file. I tried both formats. The .bin one would crash so I wrote code to convert .bin to .pcd:

import numpy as np
import open3d as o3d

file_path = 'data/TJ4DRadSet_4DRadar/training/velodyne_reduced/000004.bin'
points = np.fromfile(file_path, dtype=np.float32).reshape(-1, 8) # original ptc has 8 dims

pcd = o3d.geometry.PointCloud()

pcd.points = o3d.utility.Vector3dVector(points[:, :3])

output_pcd_path = 'output_full_dimensions.pcd'
with open(output_pcd_path, 'w') as f:

f.write(f"# .PCD v0.7 - Point Cloud Data file format\n")
f.write(f"VERSION 0.7\n")
f.write(f"FIELDS x y z {''.join([f'f{i} ' for i in range(3, points.shape[1])]).strip()}\n")
f.write(f"SIZE 4 4 4 {' '.join(['4'] * (points.shape[1] - 3))}\n")
f.write(f"TYPE F F F {' '.join(['F'] * (points.shape[1] - 3))}\n")
f.write(f"COUNT 1 1 1 {' '.join(['1'] * (points.shape[1] - 3))}\n")
f.write(f"WIDTH {points.shape[0]}\n")
f.write(f"HEIGHT 1\n")
f.write(f"VIEWPOINT 0 0 0 1 0 0 0\n")
f.write(f"POINTS {points.shape[0]}\n")
f.write(f"DATA ascii\n")

for point in points:
    f.write(" ".join(map(str, point)) + "\n")

Then I encountered the error stated above, whether using either kitti demo or my own config file.

@DongmingMMM
Copy link
Author

Visualize problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant