# convert_libero_data_to_lerobot内存泄漏致OOM，需重置hf_datas。

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-10-17-openpi-829
> 频道：pitfalls | 更新日期：2026-10-17 | 标签：auto, github-issue, openpi
> 核心摘要：Libero数据转换脚本因内存表累积导致OOM，通过在save_episode后重置dataset.hf_dataset解决内存泄漏。

# convert_libero_data_to_lerobot内存泄漏致OOM，需重置hf_datas。

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[`convert_libero_data_to_lerobot.py` uses a lot of memory.](https://github.com/Physical-Intelligence/openpi/issues/829)（GitHub Physical-Intelligence/openpi #829）

**状态**：有绕过办法

## 问题

运行`convert_libero_data_to_lerobot.py`转换数据集时内存占用过高，每处理一个episode RSS增加约150MB直至OOM。根因是`LeRobotDataset.save_episode`调用`_save_episode_table`时通过`concatenate_datasets`将新episode拼接到`self.

## 环境

lerobot@0cf8648, torch 2.7.1, datasets 3.6.0, pyarrow 20.0.0; macOS arm64 CPU验证环境

## 解决办法

1. 修改`examples/libero/convert_libero_data_to_lerobot.py`第91-97行，在每个`dataset.save_episode()`调用后立即执行`dataset.hf_dataset = dataset.create_hf_dataset()`以重置内存表，阻断`concatenate_datasets`对历史数据的重复拼接。
2. 添加回归测试`scripts/convert_libero_data_to_lerobot_test.py`，使用4 episodes×4 frames的伪RLDS数据集驱动`main()`函数，断言内存表在跨episode时保持为空且磁盘parquet输出可完整round-trip。
3. 转换完成后建议使用`lerobot-doctor check`工具验证生成数据集的episode完整性、索引连续性及视频文件完整性，防止因中断或修改导致数据损坏。

讨论原作者：@iwantlatiao 等，版权归原作者所有。
:::

## 原始参考来源 (Sources)

- [GitHub Physical-Intelligence/openpi #829：`convert_libero_data_to_lerobot.py` uses a lot of memory.](https://github.com/Physical-Intelligence/openpi/issues/829)