You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行mlagents-learn报错,疑Unity版本问题求排查方案

ML-Agents 训练报错解决办法

环境版本

  • ml-agents: 0.29.0
  • ml-agents-envs: 0.29.0
  • Communicator API: 1.5.0
  • PyTorch: 1.7.1+cpu
  • Unity版本:2022.2.0b16

报错信息

运行mlagents-learn时触发以下错误,使用--force参数时仍有类似报错(无最后提示行):

Traceback (most recent call last):
  File "C:\Users\Anton\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Anton\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Anton\Desktop\Unity\Drone_Ai_v2\venv\Scripts\mlagents-learn.exe\__main__.py", line 7, in <module>
  File "c:\users\anton\desktop\unity\drone_ai_v2\venv\lib\site-packages\mlagents\trainers\learn.py", line 260, in main
    run_cli(parse_command_line())
  File "c:\users\anton\desktop\unity\drone_ai_v2\venv\lib\site-packages\mlagents\trainers\learn.py", line 256, in run_cli
    run_training(run_seed, options, num_areas)
  File "c:\users\anton\desktop\unity\drone_ai_v2\venv\lib\site-packages\mlagents\trainers\learn.py", line 75, in run_training
    checkpoint_settings.maybe_init_path,
  File "c:\users\anton\desktop\unity\drone_ai_v2\venv\lib\site-packages\mlagents\trainers\directory_utils.py", line 26, in validate_existing_directories
    "Previous data from this run ID was found. "
mlagents.trainers.exception.UnityTrainerException: Previous data from this run ID was found. Either specify a new run ID, use --resume to resume this run, or use the --force parameter to overwrite existing data.

已尝试操作

更换不同版本的mlagents和PyTorch,问题未解决,怀疑与Unity 2022.2.0b16预览版有关。


解决建议

  1. 手动清理旧训练数据
    找到项目根目录下的results文件夹,删除对应Run ID的子文件夹,再重新执行mlagents-learn命令。

  2. 指定全新Run ID
    执行命令时通过--run-id参数指定新的唯一ID,示例:

    mlagents-learn config.yaml --run-id=drone_ai_v3
    
  3. 匹配ML-Agents与Unity版本
    Unity 2022.2属于预览版,ML-Agents 0.29.0对其兼容性不足,建议:

    • 降级Unity至2020.3 LTS或2021.3 LTS稳定版本,这是ML-Agents官方推荐的适配版本
    • 升级ML-Agents至最新稳定版(如0.30+),新版本通常会适配更高版本的Unity
  4. 检查命令参数顺序
    确保--force参数位置正确,正确命令格式:

    mlagents-learn config.yaml --force
    

    参数位置错误会导致未生效。

  5. 重建虚拟环境
    重新创建虚拟环境并安装依赖,避免环境冲突:

    python -m venv venv
    venv\Scripts\activate
    pip install mlagents==0.29.0 torch==1.7.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
    

内容的提问来源于stack exchange,提问作者Anton Anton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 01:20:19