今天尝试用PARL里面的代码跑一下mini-alphago的项目,是torch版本的。
下载代码和数据集
首先下载源代码,下载地址为:
https://github.com/PaddlePaddle/PARL/tree/775a6afe0f1946e40c22206a5b98f81f871eb4ec/benchmark/torch/AlphaZero
这里面的所有python文件都需要下载下来,然后下载数据集,数据集的地址为:
https://www.kaggle.com/petercnudde/1k-connect4-validation-set
把数据集放到你的代码同级的目录就行了
安装环境
我是用的是python3.7,mac
torch 1.4.0
parl 1.4.1
tqdm 4.60.0
建议用anaconda创建一个新的环境,把这三个包安装一下就行了。
训练
xparl start --port 8010 --cpu_num 5
上面的命令执行完以后,输出的日志为:
[04-14 11:53:35 MainThread @logger.py:242] Argv: /Users/wugaosheng/anaconda3/envs/alphago/bin/xparl start --port 8010 --cpu_num 5
# The Parl cluster is started at localhost:8010.
# A local worker with 5 CPUs is connected to the cluster.
# Starting the cluster monitor...
## If you want to check cluster status, please view:
http://172.24.148.88:50351
or call:
xparl status
## If you want to add more CPU resources, please call:
xparl connect --address 172.24.148.88:8010
## If you want to shutdown the cluster, please call:
xparl stop
Checking status of log_server...
# Start the log server sucessfully.
然后再执行
python main.py
就可以跑了,输出的日志为:
arning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self.np_pieces = np.zeros([self.height, self.width], dtype=np.int)
[04-14 11:53:46 MainThread @client.py:431] Remote actors log url: http://172.24.148.88:50351/logs?client_id=172.24.148.88_50454_1618372426
[04-14 11:53:46 MainThread @Coach.py:73] Starting Iter #1 ...
[04-14 11:53:46 MainThread @Coach.py:76] Step1: self-play in parallel...
然后你会发现你的电脑的风扇转速很快,声音变大了,说明正在运行哈。如果想等到训练结束,建议找个好一点的GPU机器哈。