cuda11.8 bevfusion(mit) mmdetection训练环境搭建
3、numpy 提示就是“AttributeError: module ‘numpy’ has no attribute ‘bool’”。安装完后如果出现问题1,再进行修改。
大致安装命令如下:
conda create -n mmdet3d python=3.8
#安装torch, 版本号要与cuda对应
pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu118
#安装mmcv-full, cu118/torch2.2.0, cu 和 torch 版本要对应
pip install mmcv-full==1.7.2 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.2.0/index.html
pip install mmdet==2.20.0
pip install numpy==1.22 -i https://pypi.tuna.tsinghua.edu.cn/simple
#4.安装 cumm-cuxxx spconv-cuxxx
pip install cumm-cu118
pip install spconv-cu118
pip install mmengine
以上是我使用的版本
最难安装的是MMCV, 要安装mmcv-full, 否则可能代码不兼容。
常见报错问题及解决:
1、File “/usr/local/miniconda3/envs/llm/lib/python3.8/site-packages/mmdet/init.py”, line 16, in assert (mmcv_version >= digit_version(mmcv_minimum_version)
AssertionError: MMCV==2.2.0 is used but incompatible. Please install mmcv>=2.0.0rc4, <2.2.0.
mmcv 报版本问题,直接修改代码 python3.8/site-packages/mmdet/init.py:
mmcv_minimum_version = '1.3.17'
mmcv_maximum_version = '1.7.2'
mmcv_version = digit_version(mmcv.__version__)
2、File “/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/_functions.py”, line 117, in _get_stream
if device.type == “cpu”:
AttributeError: ‘int’ object has no attribute ‘type’
#自定义一个函数
def safe_get_stream(device):
if isinstance(device, int):
device = torch.device(f'cuda:{device}')
return _get_stream(device)
#改写原先的_get_stream方法
class Scatter:
@staticmethod
def forward(target_gpus: List[int], input: Union[List, Tensor]) -> tuple:
input_device = get_input_device(input)
streams = None
if input_device == -1 and target_gpus != [-1]:
# Perform CPU to GPU copies in a background stream
streams = [safe_get_stream(device) for device in target_gpus]
outputs = scatter(input, target_gpus, streams)
# Synchronize with the copy stream
if streams is not None:
synchronize_stream(outputs, target_gpus, streams)
return tuple(outputs) if isinstance(outputs, list) else (outputs, )
3、numpy 提示就是“AttributeError: module ‘numpy’ has no attribute ‘bool’”。
# 卸载当前NumPy版本
pip uninstall numpy
# 安装指定版本的NumPy
pip install numpy==2.22.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
4、ImportError: libtorch_cuda_cu.so: cannot open shared object file: No such file or directory, 更改mmcv-full 版本,使得mmcv-full 与torch 和 cuda 版本一致,例如我的:
pip install mmcv-full==1.7.2 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.2.0/index.html
安装完后如果出现问题1,再进行修改。

欢迎来到由智源人工智能研究院发起的Triton中文社区,这里是一个汇聚了AI开发者、数据科学家、机器学习爱好者以及业界专家的活力平台。我们致力于成为业内领先的Triton技术交流与应用分享的殿堂,为推动人工智能技术的普及与深化应用贡献力量。
更多推荐
所有评论(0)