requirement.txt
numba==0.53.1
numpy==1.19.5
nuscenes-devkit==1.1.9
mmcv==1.4.8
mmcv-full==1.4.0
mmdet==2.19.1
mmdet3d==1.0.0rc0
mmsegmentation==0.20.2
motmetrics==1.1.3
tensorboard==2.6.0
torch==1.9.1+cu111
torchmetrics==0.5.0
torchvision==0.10.1+cu111
pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html
mmdet3d==1.0.0rc0 直接pip安裝报错,下载源码安装,
pip install -v -e .
先说下安装成功过程:前提需要安装gcc,g++, /usr/local/cuda下面要有相应头文件
报错1:
self.build_extensions() File "/home//envs/torch1.9/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 379, in build_extensions self._check_abi() File "/home//envs/torch1.9/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 735, in _check_abi check_compiler_abi_compatibility(compiler) File "/home//envs/torch1.9/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 283, in check_compiler_abi_compatibility if not check_compiler_ok_for_platform(compiler): File "/home//envs/torch1.9/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 243, in check_compiler_ok_for_platform which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT) File "/home//envs/torch1.9/lib/python3.8/subprocess.py", line 415, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/home//envs/torch1.9/lib/python3.8/subprocess.py", line 516, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['which', 'g++']' returned non-zero exit status 1. error: subprocess-exited-with-error × python setup.py develop did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. full command: /home//envs/torch1.9/bin/python -c ' exec(compile('"'"''"'"''"'"' # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py # # - It imports setuptools before invoking setup.py, to enable projects that directly # import from distutils.core to work with newer packaging standards. # - It provides a clear error message when setuptools is not installed. # - It sets sys.argv[0] to the underlying setup.py, when invoking setup.py so # setuptools doesn'"'"'t think the script is -c. This avoids the following warning: # manifest_maker: standard file '"'"'-c'"'"' not found". # - It generates a shim setup.py, for handling setup.cfg-only projects. import os, sys, tokenize try: import setuptools except ImportError as error: print( "ERROR: Can not execute setup.py since setuptools is not available in " "the build environment.", file=sys.stderr, ) sys.exit(1) __file__ = %r sys.argv[0] = __file__ if os.path.exists(__file__): filename = __file__ with tokenize.open(__file__) as f: setup_py_code = f.read() else: filename = "<auto-generated setuptools caller>" setup_py_code = "from setuptools import setup; setup()" exec(compile(setup_py_code, filename, "exec")) '"'"''"'"''"'"' % ('"'"'/data/0001_project/20260611_mmdet3d1.0.0rc0/mmdetection3d-1.0.0rc0/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' develop --no-deps cwd: /data/0001_project/20260611_mmdet3d1.0.0rc0/mmdetection3d-1.0.0rc0/ error: subprocess-exited-with-error × python setup.py develop did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip.
从报错看,根本原因不是 pip,也不是 mmdet3d,而是 系统找不到 g++ 编译器, 由于是docker环境,没有g++
apt update
apt install -y build-essential
安装好后检查g++ --version
报错2:
creating build/temp.linux-x86_64-3.8/mmdet3d/ops/spconv
creating build/temp.linux-x86_64-3.8/mmdet3d/ops/spconv/src
gcc -pthread -B //home/Anaconda/envs/torch1.9/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I//data/0001_project/20260611_mmdet3d1.0.0rc0/mmdetection3d-1.0.0rc0/mmdet3d/ops/spconv/include -I//home/Anaconda/envs/torch1.9/lib/python3.8/site-packages/torch/include -I//home/Anaconda/envs/torch1.9/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I//home/Anaconda/envs/torch1.9/lib/python3.8/site-packages/torch/include/TH -I//home/Anaconda/envs/torch1.9/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda/include -I//home/Anaconda/envs/torch1.9/include/python3.8 -c mmdet3d/ops/spconv/src/all.cc -o build/temp.linux-x86_64-3.8/mmdet3d/ops/spconv/src/all.o -w -std=c++14 -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1011" -DTORCH_EXTENSION_NAME=sparse_conv_ext -D_GLIBCXX_USE_CXX11_ABI=0
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
mmdet3d/ops/spconv/src/all.cc:15:10: fatal error: cuda_runtime_api.h: No such file or directory
15 | #include <cuda_runtime_api.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
error: subprocess-exited-with-error
× python setup.py develop did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: //home/Anaconda/envs/torch1.9/bin/python -c '
exec(compile('"'"''"'"''"'"'
# This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
#
# - It imports setuptools before invoking setup.py, to enable projects that directly
# import from `distutils.core` to work with newer packaging standards.
# - It provides a clear error message when setuptools is not installed.
# - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
# setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
# manifest_maker: standard file '"'"'-c'"'"' not found".
# - It generates a shim setup.py, for handling setup.cfg-only projects.
import os, sys, tokenize
try:
import setuptools
except ImportError as error:
print(
"ERROR: Can not execute `setup.py` since setuptools is not available in "
"the build environment.",
file=sys.stderr,
)
sys.exit(1)
__file__ = %r
sys.argv[0] = __file__
if os.path.exists(__file__):
filename = __file__
with tokenize.open(__file__) as f:
setup_py_code = f.read()
else:
filename = "<auto-generated setuptools caller>"
setup_py_code = "from setuptools import setup; setup()"
exec(compile(setup_py_code, filename, "exec"))
'"'"''"'"''"'"' % ('"'"'//data/0001_project/20260611_mmdet3d1.0.0rc0/mmdetection3d-1.0.0rc0/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' develop --no-deps
cwd: //data/0001_project/20260611_mmdet3d1.0.0rc0/mmdetection3d-1.0.0rc0/
error: subprocess-exited-with-error
真正报错
fatal error: cuda_runtime_api.h: No such file or directory,找不到 CUDA 头文件。
因为docker里面自带的轻量化的cuda库都没有头文件,需要安装cuda,从其他机器拷贝cuda文件就好了。
后面剩下的报错就是numpy,numba,matplot等版本问题
直接升级到 mmdet3d 1.0.0rc0 推荐组合:
pip install numpy==1.21.6
pip install matplotlib==3.5.3
pip install numba==0.55.2
装好后就是用mmdetection3d打包nuscene数据:
python tools/create_data.py nuscenes --root-path 数据集根目录 --version v1.0-mini --extra-tag nuscenes --out-dir 数据集根目录
python tools/create_data.py nuscenes --root-path 数据集根目录 --version v1.0 --extra-tag nuscenes --out-dir 数据集根目录
{
"name": "create_nuscenes_data",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/tools/create_data.py",
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "${workspaceFolder}"
},
"justMyCode": false,
"python": "/opt/conda/bin/python",
"args": [
"nuscenes",
"--root-path",
"/20260420_sparse4D/V1/Sparse4D-1.0/data/nuscenes",
"--out-dir",
"/20260420_sparse4D/V1/Sparse4D-1.0/data/nuscenes_cam",
"--extra-tag",
"nuscenes"
]
}