Unity3D ML-agents 配置中遇到的问题总结

近日打算学习一下ML-agents,在配置时遇到了一些问题,记录一下。

使用系统:Win10

Python版本:python3.5.3

1. 配置tensorflow

一开始下载了目前最新的Cuda9.2+cudnn7.1+tensorflow1.9.0,但是在尝试import tensorflow as tf时报错,找不到cudart64_90.dll, 在系统变量Path中加入它的路径C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin,不报这个错误了,import tensorflow as tf也不报错,但是在继续使用tensorflow中的方法时报错AttributeError: module 'tensorflow' has no attribute 'xxx',不论什么方法全部不存在,查阅一番后认为可能是版本原因,因此将cuda,cudnn和tensorflow全部卸载掉重新安装。

验证发现Cuda9.0+Cudnn7.0.5+Tensorflow1.8.0是可行的。(但是也只是暂时的,在python命令下可以使用,稍后再提)

2. 安装Anaconda,克隆ML-agents的git工程,将tensorflow#引入工程,这些按照网上的教程来。

3. 测试ML-agents中的3D balance ball项目,按照官网上的教程一步一步执行,训练的流程中没有出现问题,成功导出了.bytes数据文件,但是在将brain的策略调整为internal来验证时发现达不到想要的结果,板子根本不动,小球一落下来就掉下去了。用demo中自带的3DBall数据测试也是同样效果。发现在internal策略下运行时,频繁报错An item with the same key has already been added. Key: Platform (Ball3DAgent),查阅一番后认为可能是TFSharpPlugin.unitypackage这个插件的版本问题,在这个问题中给出的链接https://github.com/Unity-Technologies/ml-agents/pull/746中下载了新的tensorflow#,(网络原因,已将其上传到百度网盘,TFSharpPlugin0.4),重新导入后发现demo中给出的3DBall.bytes可以使用了,但是自己训练的.bytes还是不行,猜想1.可能是因为tensorflow的版本问题;2.可能是在我重新导入tf#后没有重新build一个新的.exe来训练。具体我没有验证,直接重新安装了官网教程中给出的tensorflow1.7,并重新build了新的.exe来训练,生成的训练数据也成功了,搞定~~

PS:之前在一个博客中看到在BrainType为Internal的情况下,除了导入Graph Model以外,还将Graph Placeholders设为1,name改成espilon,类型改为floatpoint。但是在我这边尝试下来,graph placeholders不需要修改,0就可以。设置为1并修改name和floatpoint后,反而会报错,UnityAgentsException: One of the Tensorflow placeholder cound nout be found.                 In brain Ball3DBrain, there are no FloatingPoint placeholder named epsilon。不知道为什么╮(╯_╰)╭

猜你喜欢

转载自blog.csdn.net/stone002/article/details/81505879