QCNet

https://github.com/ZikangZhou/QCNet

包安装位置详细说明

  1. 环境本身的位置
    bash

环境主目录

/mnt/a/envs/QCNet/ # 如果 environment.yml 中指定的名称是 QCNet

/mnt/a/envs/qcnet/ # 如果名称是小写的 qcnet

  1. 包的分布位置
    当你创建 Conda 环境时,不同类型的包会被安装在不同的位置:

包类型 安装位置 说明
Python 包 /mnt/a/envs/QCNet/lib/python3.x/site-packages/ 所有通过 pip/conda 安装的 Python 包
可执行文件 /mnt/a/envs/QCNet/bin/ python、pip、以及各种命令行工具
Conda 包缓存 /mnt/a/pkgs/ 下载的 .conda/.tar.bz2 包文件(跨环境共享)
环境配置文件 /mnt/a/envs/QCNet/conda-meta/ 记录环境中安装的所有包信息

  1. 验证安装位置的方法
    bash

1. 创建环境后,查看环境列表

conda env list | grep QCNet

输出应该显示:QCNet /mnt/a/envs/QCNet

2. 激活环境

conda activate QCNet

3. 查看 Python 解释器位置

which python

输出:/mnt/a/envs/QCNet/bin/python

4. 查看 pip 安装的包位置

python -c “import site; print(site.getsitepackages())”

输出:[‘/mnt/a/envs/QCNet/lib/python3.9/site-packages’]

5. 查看特定包的位置

pip show torch

查看 Location 字段

6. 查看包缓存目录

conda info | grep “package cache”

应该显示 /mnt/a/pkgs

  1. 确认你的 Conda 配置
    根据你之前的操作,你的 Conda 配置应该是:

bash

查看当前 envs_dirs 配置

conda config –show envs_dirs

预期的输出顺序(优先级从高到低):

– /mnt/a/envs

– /mnt/a/miniconda3/envs (如果有)

– /root/miniconda3/envs

– /root/.conda/envs

  1. 完整目录结构预览
    安装完成后,你的文件系统结构应该是:

text
/mnt/a/
├── envs/
│ ├── QCNet/ # QCNet 环境
│ │ ├── bin/ # 可执行文件
│ │ ├── lib/ # Python 库
│ │ ├── conda-meta/ # 包元数据
│ │ └── …
│ └── sparse/ # 你原有的 sparse 环境
├── pkgs/
│ ├── pytorch-2.0.1-py3.9_cuda11.7_cudnn8.5.0_0.conda
│ ├── torchvision-…
│ └── … # 所有下载的包缓存
├── projects/
│ └── QCNet/ # 源代码
└── datasets/
└── argoverse2/ # 数据集

  1. 环境迁移说明
    如果你之前有已存在的环境(如 sparse),它们仍然在原来的位置:

/root/miniconda3/envs/sparse(旧位置)

/mnt/a/miniconda3/envs/sparse(可能之前迁移过)

但新创建的 QCNet 环境会严格按照你的配置,安装在 /mnt/a/envs/QCNet。

  1. 磁盘空间管理优势
    这种配置的优势:

环境集中管理:所有新建环境都在 /mnt/a/envs/ 下

包缓存共享:/mnt/a/pkgs/ 中的缓存可以被所有环境复用

节省系统盘空间:大文件都放在数据盘 /mnt/a 上

便于备份:只需备份 /mnt/a/ 目录

  1. 验证命令汇总
    安装完成后,可以用这些命令验证一切正常:

bash

确认环境位置

conda env list | grep QCNet

激活环境

conda activate QCNet

确认当前环境

which python
conda info –envs | grep “*”

确认包缓存位置

conda clean –dry-run # 查看可清理的包缓存

查看磁盘使用情况

du -sh /mnt/a/envs/QCNet
du -sh /mnt/a/pkgs
这样配置后,你就不必担心占用系统盘空间,所有 Conda 相关的大文件都会存储在 /mnt/a 数据盘上。

=====================
QCNet 安装配置指南(Conda版)
本文档将指导你在 Conda 环境中完整安装和配置 QCNet 轨迹预测框架。QCNet 是一个在 CVPR 2023 上发表的高性能多智能体轨迹预测框架,在 Argoverse 1/2 基准测试中排名第一。

📋 目录

  1. 系统要求
  2. 环境准备
  3. 安装 QCNet
  4. 安装 Argoverse 2 API
  5. 下载数据集
  6. 训练与评估
  7. 常见问题解决
  8. 硬件资源参考
  9. 系统要求
    在开始安装前,请确保你的系统满足以下要求:

组件 要求 说明
操作系统 Linux Windows 上部署可能会遇到兼容性问题
Python 3.7 或更高版本 推荐 Python 3.8+
CUDA 11.0 或更高版本 如果使用 GPU 训练
磁盘空间 ≥ 100GB 包含数据集(58GB)和环境
Git 最新版本 用于克隆代码仓库
注意:QCNet 必须在 Linux 环境下运行,有用户在 Windows 上尝试时遇到持续报错。

  1. 环境准备
    2.1 确认 Conda 安装
    首先确认 Conda 已正确安装:

bash
conda –version
conda info
根据你之前的配置,你的 Conda 环境目录已经设置为 /mnt/a/envs(推荐)或 /mnt/a/miniconda3/envs。为确保后续创建的环境自动存放到数据盘,建议先确认配置:

bash

查看当前环境目录配置

conda config –show envs_dirs

确保 /mnt/a/envs 在第一位(优先级最高)

conda config –prepend envs_dirs /mnt/a/envs
2.2 创建工作目录
bash

创建项目工作区(使用你的数据盘)

mkdir -p /mnt/a/projects
cd /mnt/a/projects

  1. 安装 QCNet
    3.1 克隆代码仓库
    bash

克隆官方仓库

git clone https://github.com/ZikangZhou/QCNet.git
cd QCNet
官方代码地址:https://github.com/ZikangZhou/QCNet

3.2 使用 environment.yml 创建环境(推荐)
项目提供了完整的环境配置文件,可以直接创建包含所有依赖的 Conda 环境:

bash

创建环境(环境名称默认为 QCNet)

conda env create -f environment.yml

激活环境

conda activate QCNet

验证环境中的包

conda list
这个环境配置文件包含了以下核心依赖:

PyTorch 2.0.1

PyG (PyTorch Geometric) 2.3.0

PyTorch Lightning 2.0.4

其他必要的科学计算库

3.3 手动安装(备选)
如果自动安装失败,可以手动安装核心依赖:

bash

创建新环境

conda create -n qcnet python=3.9
conda activate qcnet

安装 PyTorch(根据你的 CUDA 版本选择命令)

CUDA 11.0 版本

conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch

安装 PyTorch Geometric

pip install torch-geometric

安装 PyTorch Lightning

pip install pytorch-lightning

  1. 安装 Argoverse 2 API
    QCNet 使用 Argoverse 2 运动预测数据集,需要安装官方 API。

4.1 标准安装方法
bash

参考官方文档:https://argoverse.github.io/user-guide/getting_started.html

pip install av2
4.2 备选安装方法(解决常见错误)
如果直接使用 pip install av2 遇到错误,可以采用源码安装方式:

bash

克隆 API 仓库

git clone https://github.com/argoverse/av2-api
cd av2-api

更新依赖(解决常见编译错误)

cargo update

安装

pip install -e .

返回 QCNet 目录

cd /mnt/a/projects/QCNet
常见错误:ERROR: Could not build wheels for av2 – 使用上述源码安装方法可以解决

  1. 下载数据集
    5.1 数据集信息
    Argoverse 2 运动预测数据集大小约为 58GB。建议下载到你的数据盘 /mnt/a/ 下。

5.2 下载步骤
bash

创建数据集目录

mkdir -p /mnt/a/datasets/argoverse2
cd /mnt/a/datasets/argoverse2
下载方式:

官方下载:访问 Argoverse 2 官网 注册并下载

使用 AWS CLI(如果有权限):

bash

安装 AWS CLI

pip install awscli

下载数据集(需要配置 AWS 凭证)

aws s3 sync s3://argoverse/datasets/av2.0/ /mnt/a/datasets/argoverse2/
5.3 验证数据集结构
确保数据集目录结构如下:

text
/mnt/a/datasets/argoverse2/
├── train/
├── val/
├── test/
└── map_files/

  1. 训练与评估
    6.1 配置数据路径
    在训练前,需要确保数据路径配置正确。可以通过命令行参数指定,或修改配置文件。

6.2 训练模型
使用以下命令开始训练:

bash

进入 QCNet 目录

cd /mnt/a/projects/QCNet

训练命令(请根据实际情况调整路径)

python train_qcnet.py \
–root /mnt/a/datasets/argoverse2/ \
–train_batch_size 4 \
–val_batch_size 4 \
–test_batch_size 4 \
–devices 8 \
–dataset argoverse_v2 \
–num_historical_steps 50 \
–num_future_steps 60 \
–num_recurrent_steps 3 \
–pl2pl_radius 150 \
–time_span 10 \
–pl2a_radius 50 \
–a2a_radius 50 \
–num_t2m_steps 30 \
–pl2m_radius 150 \
–a2m_radius 150
重要提示:

首次运行:数据预处理可能需要 几个小时

检查点保存:训练过程中的检查点会自动保存在 lightning_logs/ 目录

批次大小:如需重现论文结果,请确保总批次大小为 32(可通过调整 devices 和 batch_size 实现)

6.3 验证模型
bash
python val.py \
–model QCNet \
–root /mnt/a/datasets/argoverse2/ \
–ckpt_path /path/to/your_checkpoint.ckpt
6.4 测试模型
bash
python test.py \
–model QCNet \
–root /mnt/a/datasets/argoverse2/ \
–ckpt_path /path/to/your_checkpoint.ckpt
生成的 parquet 文件可提交到 Argoverse 2 排行榜。

6.5 性能指标参考
QCNet 在 Argoverse 2 验证集上的预期性能:

指标 K=1 K=6
minADE – 0.72
minFDE 4.32 1.25
MR – 0.16

  1. 常见问题解决
    7.1 环境配置问题
    问题:conda env create -f environment.yml 失败

解决方案:

检查网络连接,必要时使用代理

尝试手动安装(见 3.3 节)

确保 Conda 已更新:conda update conda

7.2 Argoverse API 安装失败
问题:ERROR: Could not build wheels for av2

解决方案:使用源码安装方法

bash
git clone https://github.com/argoverse/av2-api
cd av2-api
cargo update
pip install -e .
7.3 训练报错或性能不佳
解决方案:

检查 GPU 资源是否充足

查看日志文件中的具体错误信息

调整批量大小适应你的 GPU 内存

确认数据路径配置正确

访问 GitHub 仓库的 Issues 页面寻求帮助

7.4 路径配置问题
结合你之前的 Conda 配置,确保在训练时注意路径一致:

bash

确认当前激活的环境

conda info –envs | grep “*”

如果激活的不是 QCNet 环境,手动激活

conda activate QCNet # 或 qcnet(取决于你创建时的名称)

检查 Python 解释器位置

which python # 应该指向 /mnt/a/envs/QCNet/bin/python

  1. 硬件资源参考
    8.1 训练资源需求
    根据搜索结果,训练 QCNet 需要较高的硬件配置:

资源项 需求 说明
GPU 内存 约 160GB(总计) 建议使用多卡训练
推荐 GPU 8 × NVIDIA GeForce RTX 3090 每卡 24GB 显存
训练时间 数小时到数天 取决于硬件配置
8.2 资源不足时的调整策略
如果硬件资源有限,可以:

减少半径参数(如 –pl2pl_radius、–a2a_radius)

减少层数

降低批量大小(但注意总批次大小会影响模型性能)

8.3 数据盘使用建议
结合你之前的存储配置,推荐以下目录结构:

text
/mnt/a/ # 数据盘(大容量)
├── envs/ # Conda 环境(已配置)
│ ├── QCNet/ # QCNet 环境
│ └── sparse/ # 你的原有环境
├── projects/ # 代码项目
│ └── QCNet/ # QCNet 源码
├── datasets/ # 数据集
│ └── argoverse2/ # Argoverse 2 数据集(58GB)
└── pkgs/ # Conda 包缓存
总结
通过本文档,你应该能够成功在 Conda 环境中安装和配置 QCNet。整个流程包括:

环境准备:配置 Conda 环境目录到你的数据盘 /mnt/a/

安装 QCNet:使用 environment.yml 一键创建环境

安装 Argoverse API:处理可能的安装错误

下载数据集:准备 58GB 的训练数据

训练模型:根据硬件资源调整参数开始训练

如果遇到任何问题,建议查阅 QCNet GitHub 仓库 的 Issues 页面或参考 Argoverse 官方文档。

Table of Contents

News

[2023/07/04] The checkpoint for Argoverse 2 marginal prediction is released. Give it a try!
[2023/06/29] The code for Argoverse 2 marginal prediction is released. Enjoy it:)
[2023/06/18] QCNeXt, the extended version of QCNet, has won the championship of Argoverse 2 Multi-Agent Motion Forecasting Challenge at CVPR 2023 Workshop on Autonomous Driving (WAD).
[2023/02/28] QCNet is accepted by CVPR 2023.

Highlights

  • Scene encoder with roto-translation invariance in space: enable accurate multi-agent prediction fundamentally
  • Scene encoder with translation invariance in time: support streaming processing theoretically
  • Two-stage DETR-like trajectory decoder: facilitate multimodal and long-term prediction

Getting Started

Step 1: clone this repository:

git clone https://github.com/ZikangZhou/QCNet.git && cd QCNet

Step 2: create a conda environment and install the dependencies:

conda env create -f environment.yml
conda activate QCNet

Alternatively, you can configure the environment in your favorite way. Installing the latest version of PyTorchPyG, and PyTorch Lightning should work well.

Step 3: install the Argoverse 2 API and download the Argoverse 2 Motion Forecasting Dataset following the Argoverse 2 User Guide.

Training & Evaluation

Training

The training process consumes ~160G GPU memory. For example, you can train the model on 8 NVIDIA GeForce RTX 3090:

python train_qcnet.py --root /path/to/dataset_root/ --train_batch_size 4 --val_batch_size 4 --test_batch_size 4 --devices 8 --dataset argoverse_v2 --num_historical_steps 50 --num_future_steps 60 --num_recurrent_steps 3 --pl2pl_radius 150 --time_span 10 --pl2a_radius 50 --a2a_radius 50 --num_t2m_steps 30 --pl2m_radius 150 --a2m_radius 150

Note 1: when running the training script for the first time, it will take several hours to preprocess the data.

Note 2: during training, the checkpoints will be saved in lightning_logs/ automatically.

Note 3: you can adjust the batch size and the number of devices. To reproduce the results, you should ensure the total batch size to be 32. If you don’t have sufficient computing resource for training, you can adjust some hyperparameters, e.g., reducing the radius and the number of layers.

Validation

To evaluate on the validation set:

python val.py --model QCNet --root /path/to/dataset_root/ --ckpt_path /path/to/your_checkpoint.ckpt

Testing

To generate the prediction results on the test set:

python test.py --model QCNet --root /path/to/dataset_root/ --ckpt_path /path/to/your_checkpoint.ckpt

Submit the generated .parquet file to the Argoverse 2 leaderboard and achieve SOTA immediately!

Pretrained Models & Results

Quantitative Results

ModelDatasetSplitCheckpointminFDE (K=6)minFDE (K=1)minADE (K=6)minADE (K=1)MR (K=6)MR (K=1)brier-minFDE (K=6)
QCNetAV2ValQCNet_AV21.254.320.721.690.160.581.87
QCNetAV2TestQCNet_AV21.244.310.641.700.150.581.86

The performance is slightly better than that reported in the paper due to some incremental updates since I finished the paper:)

Qualitative Results

Citation

If you found this repository useful, please consider citing our work:

@inproceedings{zhou2023query,
  title={Query-Centric Trajectory Prediction},
  author={Zhou, Zikang and Wang, Jianping and Li, Yung-Hui and Huang, Yu-Kai},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2023}
}
@article{zhou2023qcnext,
  title={QCNeXt: A Next-Generation Framework For Joint Multi-Agent Trajectory Prediction},
  author={Zhou, Zikang and Wen, Zihao and Wang, Jianping and Li, Yung-Hui and Huang, Yu-Kai},
  journal={arXiv preprint arXiv:2306.10508},
  year={2023}
}

This repository is developed based on our previous codebase HiVT: Hierarchical Vector Transformer for Multi-Agent Motion Prediction. Please also consider citing:

@inproceedings{zhou2022hivt,
  title={HiVT: Hierarchical Vector Transformer for Multi-Agent Motion Prediction},
  author={Zhou, Zikang and Ye, Luyao and Wang, Jianping and Wu, Kui and Lu, Kejie},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2022}
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注