facebook darkforest围棋ai测试

0.darkforest说明

darkforest是facebook田渊栋博士开发的深度学习围棋程序,2016的uec cup得了第二名(http://jsb.cs.uec.ac.jp/~igo/eng/)

1.docker说明
docker成立于2013.3,到2015.4公司估值10亿美金,github star进入了前十。vmware和微软成立了专门的部门支持docker,国外FLAG,国内BAT等公司都已全线跟进。

到https://hub.docker.com/explore/搜索cuda,发现下载最多的是nvidia/cuda,以下以这个docker为基础。

《Docker基础与实战》这本书不错,棒子写的,通俗易懂。亚马逊上其它的docker书籍也很多。



2.host安装驱动
./NVIDIA-Linux-x86_64-375.26.run      这是nvidia于2016.12.14发布驱动

上面的图是我的gtx1060驱动查询信息,host只需要驱动,剩下的都在docker容器中。

如果nvidia-smi运行不正常,后面的再继续没有意义。


3.安装nvidia-docker
下载地址:https://github.com/NVIDIA/nvidia-docker
dpkg -i nvidia-docker_1.0.0.rc.3-1_amd64.deb
如果不用nvidia-docker而直接用docker,容器内的nvidia-smi无法运行

4.构建容器,或者在容器中手动运行linux命令

容器脚本已上传到:https://github.com/wjx0912/dockerfile,稍后会推送到hub.docker并create auto-build

这个脚本大部分是抄袭nvidia,只有最后几行是自己写的:)

FROM nvidia/cuda:8.0-devel
LABEL maintainer "yongjian <weiqi5@qq.com>"

ADD apt/sources.list /etc/apt/sources.list

RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y git
RUN rm -rf /var/lib/apt/lists/*

ENV CUDNN_VERSION 5
LABEL com.nvidia.cudnn.version="5"

RUN CUDNN_DOWNLOAD_SUM=a87cb2df2e5e7cc0a05e266734e679ee1a2fadad6f06af82a76ed81a23b102c8 && 
    curl -fsSL http://developer.download.nvidia.com/compute/redist/cudnn/v5.1/cudnn-8.0-linux-x64-v5.1.tgz -O && 
    echo "$CUDNN_DOWNLOAD_SUM  cudnn-8.0-linux-x64-v5.1.tgz" | sha256sum -c --strict - && 
    tar -xzf cudnn-8.0-linux-x64-v5.1.tgz -C /usr/local && 
    rm cudnn-8.0-linux-x64-v5.1.tgz && 
    ldconfig

#ADD cudnn-8.0-linux-x64-v5.1.tgz /usr/local
#RUN ldconfig

RUN git clone https://github.com/torch/distro.git ~/torch --recursive
RUN cd ~/torch && bash install-deps
RUN cd ~/torch && ./install.sh

RUN luarocks install class
RUN luarocks install image
RUN luarocks install tds
RUN luarocks install cudnn

RUN git clone https://github.com/facebookresearch/darkforestGo.git ~/darforest --recursive
RUN cd ~/darforest && sh ./compile.sh

RUN echo "for test nvidia driver,    please run command: nvidia-smi"
RUN echo "for test cuda/cudnn/torch, please run command: th -lcutorch -e 'cutorch.test()'"

docker build --tag cuda_torch:0.1 .

5.下载model到darkforest文件夹

在dropbox里面,已转到百度云盘:链接:http://pan.baidu.com/s/1jIbl3gy 密码:qftu

6.运行docker

nvidia-docker run -it -v /data:/data --name cuda_torch cuda_torch:0.1 /bin/bash

如果想再开一个终端:

nvidia-docker exec -it cuda_torch /bin/bash

7.docker中运行darkforest

server:

sh cnn_evaluator.sh 1 /data/local/go

client:

th cnnPlayerMCTSV2.lua --use_formal_params --num_gpu 1 --time_limit 10

然后

  • clear_board to clear the board
  • genmove b to genmove the black move.
  • play w Q4 to play a move at Q4 for specific color.
  • quit to quit.

8.最后截个图嘚瑟一下

 
===================================================
在hub.docker.com发布了一个image,拆箱即用,一键安装:
cuda, cudnn, torch, darkforest (版本都是2017.1最新),只需要一条指令:
docker pull wjx0912/cuda_torch
 
 
 
原文地址:https://www.cnblogs.com/wjx0912/p/6235940.html