bevdepth 环境配置
https://github.com/Megvii-BaseDetection/BEVDepth
我硬件环境是3090 24G,ubuntu1804系统
这个环境是真难配置啊,各种报错。今天终于可以正常跑了,踩坑无数,特意来记录下:
环境难弄的原因在于这个项目是22年的,现在25年,比如pip安装一些库不指定版本就都默认按最新的,更麻烦的是mmdet系列各个库之间版本有依赖特定版本,安装最新的有问题。
1. 配好的库版本清单
首先给上配置好的环境各个库版本清单:
n/data# pip list
Package Version Editable project location
------------------------- -------------- -------------------------------------------------------------------
absl-py 2.1.0
addict 2.4.0
aiohappyeyeballs 2.4.6
aiohttp 3.11.13
aiosignal 1.3.2
aliyun-python-sdk-core 2.16.0
aliyun-python-sdk-kms 2.16.5
anyio 4.8.0
argon2-cffi 23.1.0
argon2-cffi-bindings 21.2.0
arrow 1.3.0
asttokens 3.0.0
async-lru 2.0.4
async-timeout 5.0.1
attrs 25.1.0
babel 2.17.0
beautifulsoup4 4.13.3
BEVDepth 0.0.1 /workspace/BEVDepth-main
black 25.1.0
bleach 6.2.0
cachetools 5.5.2
certifi 2025.1.31
cffi 1.17.1
charset-normalizer 3.4.1
click 8.1.8
colorama 0.4.6
comm 0.2.2
contourpy 1.3.0
crcmod 1.7
cryptography 44.0.1
cycler 0.12.1
debugpy 1.8.12
decorator 5.2.1
defusedxml 0.7.1
descartes 1.1.0
exceptiongroup 1.2.2
executing 2.2.0
fastjsonschema 2.21.1
filelock 3.14.0
fire 0.7.0
flake8 7.1.2
fonttools 4.56.0
fqdn 1.5.1
frozenlist 1.5.0
fsspec 2025.2.0
grpcio 1.70.0
h11 0.14.0
httpcore 1.0.7
httpx 0.28.1
idna 3.10
imageio 2.37.0
importlib_metadata 8.6.1
importlib_resources 6.5.2
iniconfig 2.0.0
ipykernel 6.29.5
ipython 8.18.1
ipywidgets 8.1.5
isoduration 20.11.0
jedi 0.19.2
Jinja2 3.1.5
jmespath 0.10.0
joblib 1.4.2
json5 0.10.0
jsonpointer 3.0.0
jsonschema 4.23.0
jsonschema-specifications 2024.10.1
jupyter 1.1.1
jupyter_client 8.6.3
jupyter-console 6.6.3
jupyter_core 5.7.2
jupyter-events 0.12.0
jupyter-lsp 2.2.5
jupyter_server 2.15.0
jupyter_server_terminals 0.5.3
jupyterlab 4.3.5
jupyterlab_pygments 0.3.0
jupyterlab_server 2.27.3
jupyterlab_widgets 3.0.13
kiwisolver 1.4.7
lightning-utilities 0.12.0
llvmlite 0.38.1
lyft-dataset-sdk 0.0.8
Markdown 3.7
markdown-it-py 3.0.0
MarkupSafe 3.0.2
matplotlib 3.5.2
matplotlib-inline 0.1.7
mccabe 0.7.0
mdurl 0.1.2
mistune 3.1.2
mmcls 0.25.0
mmcv-full 1.5.3
mmdet 2.28.0
mmdet3d 1.0.0rc4 /workspace/BEVDepth/mmdetection3d-1.0.0rc4
mmsegmentation 0.30.0
model-index 0.1.11
mpmath 1.3.0
multidict 6.1.0
mypy-extensions 1.0.0
narwhals 1.28.0
nbclient 0.10.2
nbconvert 7.16.6
nbformat 5.10.4
nest-asyncio 1.6.0
networkx 2.2
notebook 7.3.2
notebook_shim 0.2.4
numba 0.55.0
numpy 1.21.0
nuscenes-devkit 1.1.10
nvidia-cublas-cu12 12.4.5.8
nvidia-cuda-cupti-cu12 12.4.127
nvidia-cuda-nvrtc-cu12 12.4.127
nvidia-cuda-runtime-cu12 12.4.127
nvidia-cudnn-cu12 9.1.0.70
nvidia-cufft-cu12 11.2.1.3
nvidia-curand-cu12 10.3.5.147
nvidia-cusolver-cu12 11.6.1.9
nvidia-cusparse-cu12 12.3.1.170
nvidia-cusparselt-cu12 0.6.2
nvidia-nccl-cu12 2.21.5
nvidia-nvjitlink-cu12 12.4.127
nvidia-nvtx-cu12 12.4.127
opencv-python 4.11.0.86
opencv-python-headless 4.11.0.86
opendatalab 0.0.10
openmim 0.3.9
openxlab 0.1.2
ordered-set 4.1.0
oss2 2.17.0
overrides 7.7.0
packaging 24.2
pandas 2.2.3
pandocfilters 1.5.1
parso 0.8.4
pathspec 0.12.1
pexpect 4.9.0
pillow 11.1.0
pip 23.3
platformdirs 4.3.6
plotly 6.0.0
pluggy 1.5.0
plyfile 1.1
prettytable 3.15.1
prometheus_client 0.21.1
prompt_toolkit 3.0.50
propcache 0.3.0
protobuf 5.29.3
psutil 7.0.0
ptyprocess 0.7.0
pure_eval 0.2.3
pycocotools 2.0.8
pycodestyle 2.12.1
pycparser 2.22
pycryptodome 3.21.0
pyDeprecate 0.3.2
pyflakes 3.2.0
Pygments 2.19.1
pyparsing 3.2.1
pyquaternion 0.9.9
pytest 8.3.4
python-dateutil 2.9.0.post0
python-json-logger 3.2.1
pytorch-lightning 1.6.0
pytz 2023.4
PyWavelets 1.6.0
PyYAML 6.0.2
pyzmq 26.2.1
referencing 0.36.2
requests 2.32.3
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rich 13.4.2
rpds-py 0.23.1
scikit-image 0.19.3
scikit-learn 1.6.1
scipy 1.13.1
Send2Trash 1.8.3
setuptools 59.5.0
Shapely 1.8.5
six 1.17.0
sniffio 1.3.1
soupsieve 2.6
stack-data 0.6.3
sympy 1.13.1
tabulate 0.9.0
tensorboard 2.19.0
tensorboard-data-server 0.7.2
termcolor 2.5.0
terminado 0.18.1
terminaltables 3.1.10
threadpoolctl 3.5.0
tifffile 2024.8.30
tinycss2 1.4.0
tomli 2.2.1
torch 1.9.0+cu111
torchmetrics 1.6.1
torchvision 0.10.0+cu111
tornado 6.4.2
tqdm 4.65.2
traitlets 5.14.3
trimesh 2.35.39
triton 3.2.0
types-python-dateutil 2.9.0.20241206
typing_extensions 4.12.2
tzdata 2025.1
uri-template 1.3.0
urllib3 1.26.20
wcwidth 0.2.13
webcolors 24.11.1
webencodings 0.5.1
websocket-client 1.8.0
Werkzeug 3.1.3
wheel 0.45.1
widgetsnbextension 4.0.13
yapf 0.43.0
yarl 1.18.3
zipp 3.21.0
2. conda环境创建,pytorch安装
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
参考https://pytorch.org/get-started/previous-versions/
3. mmdet3d mmdetection3d-1.0.0rc4安装:
官方安装链接:
https://mmdetection3d.readthedocs.io/en/latest/get_started.html
我们不能参照这个安装,这个安装的都是最新的,我们需要安装特定版本,踩坑无数得出的经验:
pip install -U openmim
mim install 'mmdet==2.28.0'
mim install 'mmcv-full==1.5.3'
mim install 'mmsegmentation==0.30.0'
cd到/work/mmdetection3d-1.0.0rc4目录下:
pip install -v -e .
注意MMEngine不需要安装,chatgpt说:
MMEngine 是 OpenMMLab 2.0 系列的核心库,主要用于 OpenMMLab 2.0 及以上的框架(如 MMDetection 3.x、MMSegmentation 1.x 等)。对于 OpenMMLab 1.x 系列(如 MMDetection 2.x、MMSegmentation 0.x 等),并不需要 MMEngine,因为这些框架是基于 MMCV 构建的。
4. ./BEVDepth-main/requirements.txt 库安装
requirements.txt里面一个个安装
注意安装numba或者其他库的时候会偷偷更新pytorch的cuda版本,我是自己安装pytorch1.9-cuda11版本的,安装其他库的时候会把pytorch更新成cuda12的。发现torch被自动更新了就需要重新执行:
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
5. pytorch-lightning==1.6.0安装报错与解决
ollecting pytorch-lightning==1.6.0
Using cached pytorch_lightning-1.6.0-py3-none-any.whl.metadata (33 kB)
WARNING: Ignoring version 1.6.0 of pytorch-lightning since it has invalid metadata:
Requested pytorch-lightning==1.6.0 from https://files.pythonhosted.org/packages/09/18/cee67f4849dea9a29b7af7cdf582246bcba9eaa73d9443e138a4172ec786/pytorch_lightning-1.6.0-py3-none-any.whl has invalid metadata: .* suffix can only be used with == or != operators
torch (>=1.8.*)
~~~~~~^
Please use pip<24.1 if you need to use this version.
ERROR: Could not find a version that satisfies the re
安转pytorch-lightning==1.6.0安装不上,提示要把pip降级24以下版本
pip install pip==23.3
6. 执行python setup.py develop,需要cd 到BEVDepth-main目录下
依赖库安装好后需要根据BEVDepth github主页说的:
Install BEVDepth(gpu required).
python setup.py develop
7. 执行训练命令(当然前提是把数据准备好)
python ./bevdepth/exps/nuscenes/fusion/bev_depth_fusion_lss_r50_256x704_128x128_24e.py --amp_backend native -b 2 --gpus 1
8. 报错 numba.np.ufunc
File "/home/anconda_install/envs/pytorch1.9_py3.9_now/lib/python3.9/site-packages/numba/np/ufunc/decorators.py", line 3, in
from numba.np.ufunc import _internal
SystemError: initialization of _internal failed without raising an exception
chatgpt说是numba和numpy不兼容,
pip install numba==0.55.0 numpy==1.21.0
9. 报错 networkx from fractions import gcd
再执行训练命令报错:
File "/data/anconda_install/envs/pytorch1.9_py3.9_now/lib/python3.9/site-packages/networkx/algorithms/dag.py", line 23, in
from fractions import gcd
chatgpt给出好几个解决方案,我选择了修改文件方案:
/home/anconda_install/envs/pytorch1.9_py3.9_now/lib/python3.9/site-packages/networkx/algorithms/dag.py
把dag.py里面的from fractions import gcd改成from math import gcd
再执行训练命令就跑起来了