1.准备Anaconda 下载路径 Free Download | Anaconda
2.准备Unity版本2022.3.14f1c1
3.下载Unity学习代理ML-Agents Release 21 下载路径Releases · Unity-Technologies/ml-agents · GitHub
4.打开安装好的 Anacond Powershell Prompt 准备配置python环境
5.安装组件
5.1 conda create -n mlagents python=3.10.12
5.2 conda activate mlagents(安装python3.10.12环境并打开)
5.3 pip3 install torch~=1.13.1 -f https://download.pytorch.org/whl/torch_stable.html(会安装失败一些插件)
或者使用命令 pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117
(启用清华源单独安装组件)
5.4 pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple(启用清华源下载)
5.5 python -m pip install mlagents==1.0.0 --no-dependencies(--no-dependencies 表示不安装其他依赖)
5.6 python -m pip install mlagents-envs==1.0.0 --no-dependencies
5.7 pip install attr
5.8 pip install cattrs==1.1.0
5.9 pip install pyyaml
5.10 pip install google-auth
5.11 pip install protobuf==3.20.1
5.12 pip install Pillow
5.13 pip install grpcio==1.48.2
5.14 pip install h5py
5.15 pip install numpy==1.23.2
5.16 pip install tensorboard
5.17 pip install grpcio==1.48.2
5.18 pip install huggingface-hub==0.14
5.19 pip install onnx==1.12.0
5.20 pip install cloudpickle
5.21 pip install protobuf==3.19.6
5.22 pip install pettingzoo==1.15.0
5.23 pip install pypiwin32==223
//测试运行
mlagents-learn --force
6.unity打开下载好的ML-Agents-release_21项目并打开SoccerTwos场景
7.定位到ML-Agents-release_21 配置文件进行学习
定位到配置文件列如:CD C:\Users\ZXH\Desktop\ml-agents-release_21\config\poca
运行学习文件列如:mlagents-learn SoccerTwos.yaml --run-id=test3 --force
8.运行Unity可以看到学习效果
9.关于conda的常用命令
1、创建一个虚拟环境: conda create -n 环境名 python=版本(可以是python3\python3.9,根据自己需要)
2、查看自己创建的虚拟环境: conda info --envs
3、激活某一虚拟环境: activate 虚拟环境名
4、退出某一虚拟环境: conda deactivate ##注意这里不需要加入虚拟环境名
5、conda安装包: conda install 包名
6、conda环境中也可以使用pip
7、删除指定包: conda uninstall/remove 包名
8、删除整个环境以及所属的所有包: conda remove -n 环境名 --all