| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >=3.10 | 实测 3.11 |
| torch / torch_npu | >=2.5 | NPU 上需安装 torch_npu(系统自带,勿装入 libs) |
| transformers | ==4.57.x | AutoModel/AutoProcessor + trust_remote_code 自定义代码加载 |
| tokenizers | >=0.22,<=0.23 | transformers 4.57 配套版本 |
| huggingface_hub | <1.0 | transformers 4.57 兼容性约束 |
| timm | 1.0.x | Florence-2 DaViT 视觉骨干依赖(timm.layers) |
| einops | 任意 | Florence-2 张量重排 |
| fastapi / uvicorn / json-numpy / opencv-python-headless | 官方自定义代码顶层 import 所需 | modeling_xvla.py 顶部引入,离线推理亦需可导入 |
| pillow / numpy | numpy==2.2.6 与系统 torch 2.7.1 兼容 | 合成观测与张量处理 |
安装命令:
pip install --no-cache-dir --target /mnt/workspace/X-VLA-WidowX/libs \
-i https://pypi.tuna.tsinghua.edu.cn/simple --no-deps \
transformers==4.57.6 "tokenizers>=0.22.0,<=0.23.0" \
"huggingface_hub>=0.34.2,<0.36.0" timm==1.0.28 einops fastapi uvicorn \
json-numpy opencv-python-headless pillow regex requests pyyaml packaging \
filelock typing-extensions safetensors pydantic starlette h11 anyio annotated-types click \
sniffio idna certifi charset_normalizer urllib3 fsspec tqdm注意:一律
--no-deps安装到模型专属 libs 目录;禁止装入 torch/torchvision/triton/nvidia-*(系统已有 torch 2.7.1+cpu + torch_npu,避免遮蔽且白占 4G+);huggingface_hub 必须锁 <1.0。
# 检查 NPU 设备
npu-smi info
# 权重已就位(含自定义模型代码 configuration_xvla.py / modeling_xvla.py 等)
ls /home/developer/models/X-VLA-WidowX/
# 模型专属依赖目录
ls /mnt/workspace/X-VLA-WidowX/libs/ | headPYTHONPATH=/mnt/workspace/X-VLA-WidowX/libs python3 inference.py --model_path /home/developer/models/X-VLA-WidowX| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model_path | str | /home/developer/models/X-VLA-WidowX | 本地权重目录(trust_remote_code 离线加载) |
| --device | str | 自动(npu > cuda > cpu) | 推理设备 |
| --instruction | str | pick up the carrot and place it on the plate | 语言任务指令 |
| --domain_id | int | 0 | 本体域 ID(选择对应 soft prompt,num_domains=30) |
| --denoise_steps | int | 10 | flow matching 迭代去噪步数(官方默认 10) |
| --rollouts | int | 2 | 策略前向轮数(每轮独立采样一次完整动作块) |
输入:
PYTHONPATH=/mnt/workspace/X-VLA-WidowX/libs python3 inference.py --model_path /home/developer/models/X-VLA-WidowX输出:
[INFO] device = npu
[INFO] model_path = /home/developer/models/X-VLA-WidowX
[INFO] 模型加载完成 load_time=xx.xxs params=xxxM (arch=XVLA soft-prompted VLA, backbone=Florence-2-large encoder, action_mode=ee6d, num_actions=30, dim_action=20, framework=transformers trust_remote_code)
[INFO] 输入预处理完成 views=3 image_input=(1, 3, 3, 224, 224) lang_tokens=(1, 50) instruction="pick up the carrot and place it on the plate"
[INFO] 动作输出 shape=(2, 30, 20), dtype=float32, (min=..., max=..., mean=...)
[INFO] 推理完成 耗时/elapsed=x.xxxs (rollouts=2, denoise_steps=10, num_actions=30, dim_action=20, device=npu)
[RESULT] status=ok device=npu 耗时/elapsed=x.xxxs


--model_path 加载(脚本设置 HF_HUB_OFFLINE=1 与 TRANSFORMERS_OFFLINE=1,local_files_only=True),推理全程离线;_has_sdp_attention 判定),未启用 flash_attention_2;[B, dim_action=20],夹爪通道在 preprocess 中被置零属官方设计;domain_id 取值需在 [0, num_domains=30) 内;