自动驾驶-M2 感知与 BEV-2.3 BEVFormer 训练实战
本节做一个重要的技术决策:不用官方仓库,自己实现精简版—— 理由在下面,这不是偷懒,是在你的硬件上唯一正确的选择。学习课程 端到端自动驾驶实战 | zhijia.dev
第一步:环境准备
conda activate ad
# 只需要这些 —— 没有 mmcv、没有版本地狱
pip install torch==2.1.2 torchvision==0.16.2 \
--index-url https://download.pytorch.org/whl/cu121
pip install tensorboard tqdm
# 验证
python -c "
import torch, torchvision
print('torch', torch.__version__)
print('cuda 可用:', torch.cuda.is_available())
print('设备:', torch.cuda.get_device_name(0))
print('算力: sm_%d%d' % torch.cuda.get_device_capability(0))
"
# 期望输出算力 sm_89,且 cuda 可用为 True
--------------------------------->
输出:
(ad) leoking@byd-desktop:~/carla/work/courses/M2/2.3$ python -c "
import torch, torchvision
print('torch', torch.__version__)
print('cuda 可用:', torch.cuda.is_available())
print('设备:', torch.cuda.get_device_name(0))
print('算力: sm_%d%d' % torch.cuda.get_device_capability(0))
"
torch 2.1.2+cu121
cuda 可用: True
设备: NVIDIA L20
算力: sm_89
第二步:理解要实现什么

第三步:模型实现
下面是完整模型。重点看 SpatialCrossAttention 那部分—— 它是论文第 4 节的直接翻译。
为者常成,行者常至
自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)