mmdetection3d icon indicating copy to clipboard operation
mmdetection3d copied to clipboard

[Bug] RuntimeError: hard_voxelize_forward_impl: implementation for device cuda:0 not found in Jetson Orin nano

Open zahidpichen opened this issue 6 months ago • 1 comments

Prerequisite

Task

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

Branch

1.x branch https://github.com/open-mmlab/mmdetection3d/tree/dev-1.x

Environment

i'm using jetson orin nano and the only version compatable for this is pytorch2.7 which doesn't have a wheel and need to build a docker container.

i had already built pytorch docker container. so, i used it as the image and tried to build library as how it's done in the official documentation.

FROM sentinel

RUN git clone https://github.com/open-mmlab/mmdetection3d.git && \
    cd mmdetection3d && \
    pip install -e .

during build it gave me torch moddule not found. so i did this

FROM sentinel

RUN pip show torch

RUN git clone https://github.com/open-mmlab/mmdetection3d.git && \
    cd mmdetection3d && \
    pip install -e .

this show the torch version which confirms that there's torch but for some reason it's not being used.

so far, i tired to install the library by adding tags

  • pip install -e . --no-build-isolation
  • pip install -e . --no-build-isolation --no-use-pep517

both didn't work i even tried adding them as ENV inside docker container, this also gave me the same result.

i thought that there would be a way to solve this. but, downgrading pytorch is not possible for me. so if anyone have face similar issues or solved it. or have any suggestions

please tell let me now

thanks in advance

Reproduces the problem - code sample

create a dockerfile and add this

FROM dustynv/pytorch:2.7-r36.4.0-cu128-24.04

ENV CUMM_CUDA_ARCH_LIST="8.7" \
    CUMM_CUDA_VERSION="12.6" \
    CUMM_DISABLE_JIT=1 \
    SPCONV_DISABLE_JIT=1

RUN apt-get update && \
      DEBIAN_FRONTEND=noninteractive apt-get install -y \
      libx11-6 libx11-dev \
      libxt6 libxt-dev \
      libglu1-mesa libglu1-mesa-dev \
      libosmesa6 libosmesa6-dev \
      libgl1-mesa-dev libglx-mesa0 libegl1-mesa-dev \
      libxcursor1 libxcursor-dev \
      libxrandr2 libxrandr-dev \
      libxfixes3 libxfixes-dev \
      tesseract-ocr \
      libtesseract-dev \
      libleptonica-dev \
      libgtk-3-0 \
      libgtk-3-dev \
      libgstreamer1.0-0 \
      libxi6 libxi-dev \
      gstreamer1.0-tools \
      gstreamer1.0-plugins-base \
      gstreamer1.0-plugins-good \
      gstreamer1.0-plugins-bad \
      gstreamer1.0-plugins-ugly \
      libgstreamer-plugins-base1.0-dev \
      libxinerama1 libxinerama-dev && \
      apt-get clean && rm -rf /var/lib/apt/lists/*

    
    
RUN apt-get update && apt-get install -y \
    git cmake build-essential python3-dev python3-pip && \
    rm -rf /var/lib/apt/lists/*
    
WORKDIR /opt/dockerbuild
    
    


COPY spconv_cu126-2.3.8-cp312-cp312-manylinux2014_aarch64.whl /tmp/
COPY cumm_cu126-0.8.1-cp312-cp312-manylinux2014_aarch64.whl /tmp/
COPY custom_object_detection-0.1-py3-none-any.whl /tmp/
COPY pcdet-0.6.0+8caccce-cp312-cp312-linux_aarch64.whl /tmp/


RUN pip install /tmp/spconv_cu126-2.3.8-cp312-cp312-manylinux2014_aarch64.whl
RUN pip install /tmp/cumm_cu126-0.8.1-cp312-cp312-manylinux2014_aarch64.whl
RUN pip install /tmp/custom_object_detection-0.1-py3-none-any.whl
RUN pip install /tmp/pcdet-0.6.0+8caccce-cp312-cp312-linux_aarch64.whl



RUN git clone https://github.com/zahidpichen/Python-LivoxSDK2.git && \
    cd Python-LivoxSDK2/Livox-SDK2 && \
    mkdir build && cd build && cmake .. && make -j4 && make install -j3 && \
    cd ../../ && \
    mkdir build && cd build && \
    cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON && \
    make -j3 && make install && \
    cd .. && \
    VENV_SITE_PKG=$(python3 -c "import site; print(site.getsitepackages()[0])") && \
    cp openpylivoxv2.cpython-312-aarch64-linux-gnu.so $VENV_SITE_PKG && \
    cd ..
    


RUN pip install \
    opencv-python-headless fastapi pyvista panel uvicorn websockets av2 pyquaternion imageio pybind11



RUN pip install insta360


RUN pip install setuptools
RUN apt-get update && \
    apt-get install -y libgeos-c1v5 libgeos-dev && \
    rm -rf /var/lib/apt/lists/*


RUN pip install shapely shapely

ENV MAX_JOBS=4

RUN pip install --upgrade pip wheel && \
    pip install 'mmcv>=2.0.0rc4,<2.2.0'
RUN pip install "mmdet>=3.0.0"



RUN git clone https://github.com/zahidpichen/mmdetection3d.git -b dev-1.x && \
    cd mmdetection3d && \
    pip install -v -e . --no-build-isolation



WORKDIR /workspace
CMD ["bash"]

NOTE: i have a pre-built spconv and cumm so i'm using it's wheel

Reproduces the problem - command or script

run this in the terminal to start the bulid which would end with the torch not found error

then build it using

sudo docker build --progress=plain -t sentinel .

Reproduces the problem - error message

#16 24.09       openxlab 0.1.2 requires requests~=2.28.2, but you have requests 2.32.4 which is incompatible.
#16 24.09       openxlab 0.1.2 requires setuptools~=60.2.0, but you have setuptools 80.9.0 which is incompatible.
#16 24.09       Successfully installed setuptools-80.9.0
#16 24.09       Removed build tracker: '/tmp/pip-build-tracker-3k52dnhu'
#16 24.43       Installing build dependencies: finished with status 'done'
#16 24.44       Checking if build backend supports build_editable: started
#16 24.44       Running command Checking if build backend supports build_editable
#16 25.17       Checking if build backend supports build_editable: finished with status 'done'
#16 25.18       Getting requirements to build editable: started
#16 25.18       Running command Getting requirements to build editable
#16 25.50       Traceback (most recent call last):
#16 25.50         File "/opt/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
#16 25.50           main()
#16 25.50         File "/opt/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
#16 25.50           json_out["return_val"] = hook(**hook_input["kwargs"])
#16 25.50                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#16 25.50         File "/opt/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 157, in get_requires_for_build_editable
#16 25.50           return hook(config_settings)
#16 25.50                  ^^^^^^^^^^^^^^^^^^^^^
#16 25.51         File "/tmp/pip-build-env-x9bt4jsu/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 473, in get_requires_for_build_editable
#16 25.51           return self.get_requires_for_build_wheel(config_settings)
#16 25.51                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#16 25.51         File "/tmp/pip-build-env-x9bt4jsu/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheel
#16 25.51           return self._get_build_requires(config_settings, requirements=[])
#16 25.52                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#16 25.52         File "/tmp/pip-build-env-x9bt4jsu/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
#16 25.52           self.run_setup()
#16 25.53         File "/tmp/pip-build-env-x9bt4jsu/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 512, in run_setup
#16 25.53           super().run_setup(setup_script=setup_script)
#16 25.53         File "/tmp/pip-build-env-x9bt4jsu/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 317, in run_setup
#16 25.53           exec(code, locals())
#16 25.53         File "<string>", line 10, in <module>
#16 25.53       ModuleNotFoundError: No module named 'torch'
#16 25.58       error: subprocess-exited-with-error
#16 25.58 
#16 25.58       × Getting requirements to build editable did not run successfully.
#16 25.58       │ exit code: 1
#16 25.58       ╰─> See above for output.
#16 25.58 
#16 25.58       note: This error originates from a subprocess, and is likely not a problem with pip.
#16 25.58       full command: /opt/venv/bin/python /opt/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py get_requires_for_build_editable /tmp/tmpr2p1glu6
#16 25.59       cwd: /workspace/mmdetection3d
#16 25.59       Getting requirements to build editable: finished with status 'error'
#16 25.59     error: subprocess-exited-with-error
#16 25.59 
#16 25.59     × Getting requirements to build editable did not run successfully.
#16 25.59     │ exit code: 1
#16 25.59     ╰─> See above for output.
#16 25.59 
#16 25.59     note: This error originates from a subprocess, and is likely not a problem with pip.
#16 25.81     Traceback (most recent call last):
#16 25.81       File "<string>", line 2, in <module>
#16 25.81       File "<pip-setuptools-caller>", line 35, in <module>
#16 25.81       File "/workspace/mmdetection3d/setup.py", line 194, in <module>
#16 25.81         setup(
#16 25.81       File "/opt/venv/lib/python3.12/site-packages/setuptools/__init__.py", line 115, in setup
#16 25.81         return distutils.core.setup(**attrs)
#16 25.81                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#16 25.81       File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 186, in setup
#16 25.81         return run_commands(dist)
#16 25.81                ^^^^^^^^^^^^^^^^^^
#16 25.81       File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
#16 25.81         dist.run_commands()
#16 25.81       File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands
#16 25.81         self.run_command(cmd)
#16 25.81       File "/opt/venv/lib/python3.12/site-packages/setuptools/dist.py", line 1102, in run_command
#16 25.81         super().run_command(command)
#16 25.81       File "/opt/venv/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
#16 25.81         cmd_obj.run()
#16 25.81       File "/opt/venv/lib/python3.12/site-packages/setuptools/command/develop.py", line 39, in run
#16 25.81         subprocess.check_call(cmd)
#16 25.81       File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
#16 25.81         raise CalledProcessError(retcode, cmd)
#16 25.81     subprocess.CalledProcessError: Command '['/opt/venv/bin/python', '-m', 'pip', 'install', '-e', '.', '--use-pep517', '--no-deps']' returned non-zero exit status 1.
#16 27.08     error: subprocess-exited-with-error
#16 27.08     
#16 27.08     × python setup.py develop did not run successfully.
#16 27.08     │ exit code: 1
#16 27.08     ╰─> See above for output.
#16 27.08     
#16 27.08     note: This error originates from a subprocess, and is likely not a problem with pip.
#16 27.09     full command: /opt/venv/bin/python -c '
#16 27.09     exec(compile('"'"''"'"''"'"'
#16 27.09     # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
#16 27.09     #
#16 27.09     # - It imports setuptools before invoking setup.py, to enable projects that directly
#16 27.09     #   import from `distutils.core` to work with newer packaging standards.
#16 27.09     # - It provides a clear error message when setuptools is not installed.
#16 27.09     # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
#16 27.09     #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
#16 27.09     #     manifest_maker: standard file '"'"'-c'"'"' not found".
#16 27.09     # - It generates a shim setup.py, for handling setup.cfg-only projects.
#16 27.09     import os, sys, tokenize, traceback
#16 27.09     
#16 27.09     try:
#16 27.09         import setuptools
#16 27.09     except ImportError:
#16 27.09         print(
#16 27.09             "ERROR: Can not execute `setup.py` since setuptools failed to import in "
#16 27.09             "the build environment with exception:",
#16 27.09             file=sys.stderr,
#16 27.09         )
#16 27.09         traceback.print_exc()
#16 27.09         sys.exit(1)
#16 27.09     
#16 27.09     __file__ = %r
#16 27.09     sys.argv[0] = __file__
#16 27.09     
#16 27.09     if os.path.exists(__file__):
#16 27.09         filename = __file__
#16 27.09         with tokenize.open(__file__) as f:
#16 27.09             setup_py_code = f.read()
#16 27.09     else:
#16 27.09         filename = "<auto-generated setuptools caller>"
#16 27.09         setup_py_code = "from setuptools import setup; setup()"
#16 27.09     
#16 27.09     exec(compile(setup_py_code, filename, "exec"))
#16 27.09     '"'"''"'"''"'"' % ('"'"'/workspace/mmdetection3d/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' develop --no-deps
#16 27.09     cwd: /workspace/mmdetection3d/
#16 27.09   Rolling back uninstall of mmdet3d
#16 27.09   Moving to /opt/venv/lib/python3.12/site-packages/mmdet3d-1.4.0.dist-info/
#16 27.09    from /opt/venv/lib/python3.12/site-packages/~mdet3d-1.4.0.dist-info
#16 27.09   Moving to /opt/venv/lib/python3.12/site-packages/mmdet3d/
#16 27.09    from /opt/venv/lib/python3.12/site-packages/~mdet3d
#16 27.09   Replacing /opt/venv/lib/python3.12/site-packages/mmdet3d-1.4.0.dist-info/ from /opt/venv/lib/python3.12/site-packages/~mdet3d-1.4.0.dist-info
#16 27.09   Replacing /opt/venv/lib/python3.12/site-packages/mmdet3d/ from /opt/venv/lib/python3.12/site-packages/~mdet3d
#16 27.10 error: subprocess-exited-with-error
#16 27.10 
#16 27.10 × python setup.py develop did not run successfully.
#16 27.10 │ exit code: 1
#16 27.10 ╰─> See above for output.
#16 27.10 
#16 27.10 note: This error originates from a subprocess, and is likely not a problem with pip.
#16 27.10 Exception information:
#16 27.10 Traceback (most recent call last):
#16 27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 105, in _run_wrapper
#16 27.10     status = _inner_run()
#16 27.10              ^^^^^^^^^^^^
#16 27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 96, in _inner_run
#16 27.10     return self.run(options, args)
#16 27.10            ^^^^^^^^^^^^^^^^^^^^^^^
#16 27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 68, in wrapper
#16 27.10     return func(self, options, args)
#16 27.10            ^^^^^^^^^^^^^^^^^^^^^^^^^
#16 27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 459, in run
#16 27.10     installed = install_given_reqs(
#16 27.10                 ^^^^^^^^^^^^^^^^^^^
#16 27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/req/__init__.py", line 83, in install_given_reqs
#16 27.10     requirement.install(
#16 27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/req/req_install.py", line 850, in install
#16 27.10     install_editable_legacy(
#16 27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/operations/install/editable_legacy.py", line 42, in install_editable
#16 27.10     call_subprocess(
#16 27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/utils/subprocess.py", line 209, in call_subprocess
#16 27.10     raise error
#16 27.10 pip._internal.exceptions.InstallationSubprocessError: python setup.py develop exited with 1
#16 27.10 Removed build tracker: '/tmp/pip-build-tracker-3k52dnhu'
#16 ERROR: process "/bin/bash -c git clone https://github.com/zahidpichen/mmdetection3d.git -b dev-1.x &&     cd mmdetection3d &&     python -m pip install -v -e . --no-build-isolation" did not complete successfully: exit code: 1
------
 > [13/13] RUN git clone https://github.com/zahidpichen/mmdetection3d.git -b dev-1.x &&     cd mmdetection3d &&     python -m pip install -v -e . --no-build-isolation:
27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/req/__init__.py", line 83, in install_given_reqs
27.10     requirement.install(
27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/req/req_install.py", line 850, in install
27.10     install_editable_legacy(
27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/operations/install/editable_legacy.py", line 42, in install_editable
27.10     call_subprocess(
27.10   File "/opt/venv/lib/python3.12/site-packages/pip/_internal/utils/subprocess.py", line 209, in call_subprocess
27.10     raise error
27.10 pip._internal.exceptions.InstallationSubprocessError: python setup.py develop exited with 1
27.10 Removed build tracker: '/tmp/pip-build-tracker-3k52dnhu'
------
Dockerfilev2:30
--------------------
  29 |     
  30 | >>> RUN git clone https://github.com/zahidpichen/mmdetection3d.git -b dev-1.x && \
  31 | >>>     cd mmdetection3d && \
  32 | >>>     python -m pip install -v -e . --no-build-isolation
  33 |     
--------------------
ERROR: failed to solve: process "/bin/bash -c git clone https://github.com/zahidpichen/mmdetection3d.git -b dev-1.x &&     cd mmdetection3d &&     python -m pip install -v -e . --no-build-isolation" did not complete successfully: exit code: 1

and if i install the library without editable like this

pip install .

then when i run the script model in my function it's giving me the following error

Inference ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   [2025-06-16 17:03:57.288] [console] [info]  Receive Command: Id 258 Seq 65369  [mid360_command_handler.cpp] [Handle] [67]
Inference ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   
Thread 3: Error in object detection: hard_voxelize_forward_impl: implementation for device cuda:0 not found.

Traceback (most recent call last):
  File "/workspace/lidar_insta360_live/lidar_live_feed.py", line 606, in object_detection
    results = CODet(
              ^^^^^^
  File "/workspace/lidar_insta360_live/lidar_live_feed.py", line 143, in CODet
    results = model(inputs=input_dict)
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/mmdet3d/apis/inferencers/base_3d_inferencer.py", line 212, in __call__
    preds.extend(self.forward(data, **forward_kwargs))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/mmengine/infer/infer.py", line 296, in forward
    return self.model.test_step(inputs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/mmengine/model/base_model/base_model.py", line 144, in test_step
    data = self.data_preprocessor(data, False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/mmdet3d/models/data_preprocessors/data_preprocessor.py", line 152, in forward
    return self.simple_process(data, training)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/mmdet3d/models/data_preprocessors/data_preprocessor.py", line 178, in simple_process
    voxel_dict = self.voxelize(inputs['points'], data_samples)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/mmdet3d/models/data_preprocessors/data_preprocessor.py", line 367, in voxelize
    res_voxels, res_coors, res_num_points = self.voxel_layer(res)
                                            ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/mmdet3d/models/data_preprocessors/voxelize.py", line 170, in forward
    return voxelization(input, self.voxel_size, self.point_cloud_range,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/torch/autograd/function.py", line 575, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/mmdet3d/models/data_preprocessors/voxelize.py", line 78, in forward
    ext_module.hard_voxelize_forward(
RuntimeError: hard_voxelize_forward_impl: implementation for device cuda:0 not found.

Additional information

the model i used was centerpoint model from the repo's model zoo, it was trained on nuscence dataset.

here's the config file that i used


i tried the pcd_demo.py and it was working. so to use the model and config in my app i created the following function

from mmdet3d.apis import LidarDet3DInferencer

def CODet(config_file: str, checkpoint: str, device: str = 'cuda:0', point_cloud_file: str = "", pred_score_thr: float = 0.3):
    """
    3D Object Detection function with proper NMS filtering.

    Args:
        config_file (str): Path to the model configuration file.
        checkpoint (str): Path to the model checkpoint file.
        device (str, optional): Device used for inference. Defaults to 'cuda:0'.
        point_cloud_file (str): Path to the point cloud file.
        pred_score_thr (float): Bbox score threshold. Defaults to 0.3.

    Returns:
        dict: Object detection results
    """
    model = LidarDet3DInferencer(model=config_file, weights=checkpoint, device=device)


    points = np.fromfile(point_cloud_file, dtype=np.float32).reshape(-1, 5)

    input_dict = {'points': points, 'pts_filename': point_cloud_file}

    results = model(inputs=input_dict)

    pred = results['predictions'][0]
    bboxes_3d = pred['bboxes_3d']
    scores_3d = pred['scores_3d']
    labels_3d = pred['labels_3d']


    if not isinstance(bboxes_3d, torch.Tensor):
        bboxes_3d = torch.tensor(bboxes_3d, device=device)
        scores_3d = torch.tensor(scores_3d, device=device)
        labels_3d = torch.tensor(labels_3d, device=device)


    mask = scores_3d >= pred_score_thr
    bboxes_3d = bboxes_3d[mask]
    scores_3d = scores_3d[mask]
    labels_3d = labels_3d[mask]


    transformed = {}
    counter = 1


    for cls_id in torch.unique(labels_3d):
        cls_mask = labels_3d == cls_id
        if not cls_mask.any():
            continue

        cls_boxes = bboxes_3d[cls_mask]
        cls_scores = scores_3d[cls_mask]

        boxes_for_nms = torch.zeros((cls_boxes.shape[0], 5), device=device)
        boxes_for_nms[:, 0] = cls_boxes[:, 0] - cls_boxes[:, 3] / 2  # x1 = x - w/2
        boxes_for_nms[:, 1] = cls_boxes[:, 1] - cls_boxes[:, 4] / 2  # y1 = y - l/2
        boxes_for_nms[:, 2] = cls_boxes[:, 0] + cls_boxes[:, 3] / 2  # x2 = x + w/2
        boxes_for_nms[:, 3] = cls_boxes[:, 1] + cls_boxes[:, 4] / 2  # y2 = y + l/2
        boxes_for_nms[:, 4] = cls_boxes[:, 6]  # ry

 
        keep_indices = nms_bev(boxes_for_nms, cls_scores, thresh=0.1)

 
        for i in keep_indices:
            transformed[f'object_{counter}'] = {
                "label": int(cls_id.item()),
                "score": float(cls_scores[i].item()),
                "bbox": cls_boxes[i].cpu().numpy().tolist()
            }
            counter += 1

    return transformed

zahidpichen avatar Jun 17 '25 13:06 zahidpichen

Try to recompile mmcv from source by setting MM_CUDA_ARGS correctly according to your GPU architecture. https://github.com/open-mmlab/mmcv/blob/90d83c94cfb967ef162c449faf559616f31f28c2/setup.py#L266C1-L267C1

lisabug avatar Jun 21 '25 06:06 lisabug