V2AI / Det3D

World's first general purpose 3D object detection codebse.
https://arxiv.org/abs/1908.09492
Apache License 2.0
1.49k stars 298 forks source link

ModuleNotFoundError: No module named 'det3d.ops.nms.nms' #12

Closed chowkamlee81 closed 4 years ago

chowkamlee81 commented 4 years ago

when i try to execute python create_data.py function, it gave error below:

Kinfdly help

File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/ops/nms/nms_gpu.py", line 10, in from det3d.ops.nms.nms import non_max_suppression ModuleNotFoundError: No module named 'det3d.ops.nms.nms'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tools/create_data.py", line 7, in from det3d.datasets.kitti import kitti_common as kitti_ds File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/datasets/init.py", line 4, in from .kitti import KittiDataset File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/datasets/kitti/init.py", line 1, in from .kitti import KittiDataset File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/datasets/kitti/kitti.py", line 7, in from det3d.core import box_np_ops File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/core/init.py", line 4, in from .anchor import * File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/core/anchor/init.py", line 1, in from .anchor_generator import ( File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/core/anchor/anchor_generator.py", line 2, in from det3d.core.bbox import box_np_ops File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/core/bbox/init.py", line 42, in from . import box_coders, box_np_ops, box_torch_ops, geometry, region_similarity File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/core/bbox/box_coders.py", line 5, in from . import box_np_ops, box_torch_ops File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/core/bbox/box_torch_ops.py", line 6, in from det3d.ops.nms.nms_cpu import rotate_nms_cc File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/ops/nms/init.py", line 1, in from det3d.ops.nms.nms_cpu import nms_jit, soft_nms_jit File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/ops/nms/nms_cpu.py", line 7, in from det3d.ops.nms.nms_gpu import rotate_iou_gpu File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/ops/nms/nms_gpu.py", line 17, in cuda=True, File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/utils/buildtools/pybind11_build.py", line 109, in load_pb11 cmds.append(Nvcc(s, out(s), arch)) File "/home/ubuntu/Nuscenes_Top/Det3D-master/det3d/utils/buildtools/command.py", line 128, in init raise ValueError("you must specify arch if use cuda.") ValueError: you must specify arch if use cuda.

muzi2045 commented 4 years ago

refer this: https://github.com/poodarchu/Det3D/issues/5

chowkamlee81 commented 4 years ago

Great @muzi2045 . I will add it in setup.py

chowkamlee81 commented 4 years ago

After adding in setup.py, got error below.

det3d/ops/nms/nms_kernel.cu.cc:48:61: note: (if you use \u2018-fpermissive\u2019, G++ will accept your code, but allowing the use of an undeclared name is deprecated) det3d/ops/nms/nms_kernel.cu.cc:50:61: error: there are no arguments to \u2018min\u2019 that depend on a template parameter, so a declaration of \u2018min\u2019 must be available [-fpermissive] min(n_boxes - col_start BLOCK_THREADS, BLOCK_THREADS); ^ det3d/ops/nms/nms_kernel.cu.cc:53:7: error: \u2018threadIdx\u2019 was not declared in this scope if (threadIdx.x < col_size) ^ det3d/ops/nms/nms_kernel.cu.cc:62:17: error: there are no arguments to \u2018syncthreads\u2019 that depend on a template parameter, so a declaration of \u2018syncthreads\u2019 must be available [-fpermissive] __syncthreads(); ^ det3d/ops/nms/nms_kernel.cu.cc:64:7: error: \u2018threadIdx\u2019 was not declared in this scope if (threadIdx.x < row_size) ^ det3d/ops/nms/nms_kernel.cu.cc: In function \u2018int _nms_gpu(int, const DType, int, int, DType, int)\u2019: det3d/ops/nms/nms_kernel.cu.cc:123:37: error: expected primary-expression before \u2018<\u2019 token nms_kernel<DType, BLOCK_THREADS><<<blocks, threads>>>(boxes_num, ^ det3d/ops/nms/nms_kernel.cu.cc:123:55: error: expected primary-expression before \u2018>\u2019 token nms_kernel<DType, BLOCK_THREADS><<<blocks, threads>>>(boxes_num, ^ det3d/ops/nms/nms_kernel.cu.cc: In instantiation of \u2018int _nms_gpu(int, const DType, int, int, DType, int) [with DType = float; int BLOCK_THREADS = 64]\u2019: det3d/ops/nms/nms_kernel.cu.cc:162:65: required from here det3d/ops/nms/nms_kernel.cu.cc:123:66: warning: left operand of comma operator has no effect [-Wunused-value] nms_kernel<DType, BLOCK_THREADS><<<blocks, threads>>>(boxes_num, ^ det3d/ops/nms/nms_kernel.cu.cc:124:53: warning: right operand of comma operator has no effect [-Wunused-value] nms_overlap_thresh, ^ det3d/ops/nms/nms_kernel.cu.cc:125:44: warning: right operand of comma operator has no effect [-Wunused-value] boxes_dev, ^ det3d/ops/nms/nms_kernel.cu.cc: In instantiation of \u2018int _nms_gpu(int, const DType*, int, int, DType, int) [with DType = double; int BLOCK_THREADS = 64]\u2019: det3d/ops/nms/nms_kernel.cu.cc:165:66: required from here det3d/ops/nms/nms_kernel.cu.cc:123:66: warning: left operand of comma operator has no effect [-Wunused-value] nms_kernel<DType, BLOCK_THREADS><<<blocks, threads>>>(boxes_num, ^ det3d/ops/nms/nms_kernel.cu.cc:124:53: warning: right operand of comma operator has no effect [-Wunused-value] nms_overlap_thresh, ^ det3d/ops/nms/nms_kernel.cu.cc:125:44: warning: right operand of comma operator has no effect [-Wunused-value] boxes_dev, ^ error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

qchenclaire commented 4 years ago

@chowkamlee81 Have you solved the problem? I went the same processes as you did and got exact the same errors.

jhultman commented 4 years ago

@qchenclaire Make sure you have renamed the nms_kernel.cu.cc file to nms_kernel.cu. It seems this problem occurs when compiling CUDA code which does not have .cu file extension (source). I have opened a pull request which fixed this problem for me.

qchenclaire commented 4 years ago

@chowkamlee81 found the solution here: https://github.com/traveller59/second.pytorch/issues/69#issuecomment-455753268 nvcc one does not work for me but g++ works. Just remember to conda install pybind11 instead of pip install.

Manojbhat09 commented 4 years ago

Correct solution:

First make sure you have pybind11 Do conda install pybind11 And check import pybind11 Make sure you are able to do nvcc --version Make sure you have the paths for nvcc or else:

export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
PATH=${CUDA_HOME}/bin:${PATH}
export PATH

After this, go to nms folder and do

nvcc -std=c++11 -c -o nms_kernel.cu.o nms_kernel.cu -I/usr/local/cuda/include -x cu -Xcompiler -fPIC -arch=sm_61 --expt-relaxed-constexpr

There should be no errors, if there are check if you have correct Cuda version with the scripts Finally,

g++ -std=c++11 -shared -o nms.so nms_kernel.cu.o nms.cc -I/usr/local/cuda/include -fPIC -O3 -I/home/manoj/anaconda3/include/python3.6m -I/home/manoj/anaconda3/envs/centerpoint/include/python3.6m/ -L/usr/local/cuda/lib64 -lcublas -lcudart

You will get the nms.so