通过Docker安装谷歌足球游戏环境

2019 年 7 月 7 日 CreateAMind

通过Docker安装谷歌足球游戏环境

足球环境github链接:https://github.com/google-research/football

System: Ubuntu 16.04

在安装谷歌足球游戏环境的时候可能会出现各种各样的问题。足球环境的Github主页也提供了另一种安装方式,通过Docker安装。

Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的、可移植的、自给自足的容器。开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机)、bare metal、OpenStack 集群和其他的基础应用平台。

简单来说,谷歌提供了包含安装足球环境所需的必要环境在一个Docker配置文件中,安装好Docker后,一条命令就可以创建包含足球环境的整套配置的Docker容器。通过容器可以直接进入安装好足球环境的“虚拟”系统中。


Step 1 — Installing Docker

The Docker installation package available in the official Ubuntu  16.04 repository may not be the latest version. To get this latest  version, install Docker from the official Docker repository. This  section shows you how to do just that.

First, in order to ensure the downloads are valid, add the GPG key for the official Docker repository to your system:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add the Docker repository to APT sources:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Next, update the package database with the Docker packages from the newly added repo:

sudo apt-get update

Make sure you are about to install from the Docker repo instead of the default Ubuntu 16.04 repo:

apt-cache policy docker-ce

You should see output similar to the follow:

Output of apt-cache policy docker-ce

docker-ce:
Installed: (none)
Candidate: 18.06.1~ce~3-0~ubuntu
Version table:
    18.06.1~ce~3-0~ubuntu 500
      500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

Notice that docker-ce is not installed, but the candidate for installation is from the Docker repository for Ubuntu 16.04 (xenial).

Finally, install Docker:

sudo apt-get install -y docker-ce

Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it's running:

sudo systemctl status docker

The output should be similar to the following, showing that the service is active and running:

Output● docker.service - Docker Application Container Engine
  Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
  Active: active (running) since Thu 2018-10-18 20:28:23 UTC; 35s ago
    Docs: https://docs.docker.com
Main PID: 13412 (dockerd)
  CGroup: /system.slice/docker.service
          ├─13412 /usr/bin/dockerd -H fd://
          └─13421 docker-containerd --config /var/run/docker/containerd/containerd.toml

Installing Docker now gives you not just the Docker service (daemon) but also the docker command line utility, or the Docker client. We'll explore how to use the docker command later in this tutorial.

Step 2 — Executing the Docker Command Without Sudo (Optional)

By default, running the docker command requires root privileges — that is, you have to prefix the command with sudo. It can also be run by a user in the docker group, which is automatically created during the installation of Docker. If you attempt to run the docker command without prefixing it with sudo or without being in the docker group, you'll get an output like this:

Outputdocker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.

If you want to avoid typing sudo whenever you run the docker command, add your username to the docker group:

sudo usermod -aG docker ${USER}

To apply the new group membership, you can log out of the server and back in, or you can type the following:

su - ${USER}

You will be prompted to enter your user's password to continue.  Afterwards, you can confirm that your user is now added to the docker group by typing:

id -nG
Outputsammy sudo docker

If you need to add a user to the docker group that you're not logged in as, declare that username explicitly using:

sudo usermod -aG docker username

The rest of this article assumes you are running the docker command as a user in the docker user group. If you choose not to, please prepend the commands with sudo.


Step 3 — Running gfootball in Docker

git clone https://github.com/google-research/football.git

cd football

CPU version (未使用)

  1. Build with docker build --build-arg DOCKER_BASE=ubuntu:18.04 --build-arg DEVICE=cpu . -t gfootball

  2. Enter the image with docker run -it gfootball bash

GPU version

  1. Build with docker build --build-arg DOCKER_BASE=tensorflow/tensorflow:1.12.0-gpu-py3 --build-arg DEVICE=gpu . -t gfootball

  2. Enter the image with docker run --runtime=nvidia -it gfootball bash

    (Github主页上这条命令是这样的:docker run -it gfootball bash ,这样运行Docker的话会导致CUDA相关错误)

After entering the image, you can run sample training with python3 -m gfootball.examples.run_ppo2. Unfortunately, rendering is not supported inside the docker.

配置环境问题:

nvidia-smi命令输出的CUDA版本和nvcc -V命令输出的CUDA版本不一样,是出错了吗?

In short. Driver API version installed by the driver, in the output from nvidia-smi. This has no connection to the installed CUDA runtime version which in the output from nvcc -V.

CUDA has 2 primary APIs, the runtime and the driver API.  Both have a corresponding version (e.g. 8.0, 9.0, etc.)  

The necessary support for the driver API (e.g. libcuda.so on linux) is installed by the GPU driver installer.

The necessary support for the runtime API (e.g. libcudart.so on linux, and also nvcc) is installed by the CUDA toolkit installer (which may also have a GPU driver installer bundled in it).

In any event, the (installed) driver API version may not always match  the (installed) runtime API version, especially if you install a GPU  driver independently from installing CUDA (i.e. the CUDA toolkit).

The nvidia-smi tool gets installed by the GPU driver  installer, and generally has the GPU driver in view, not anything  installed by the CUDA toolkit installer.

Recently (somewhere between 410.48 and 410.73 driver version on  linux) the powers-that-be at NVIDIA decided to add reporting of the CUDA  Driver API version installed by the driver, in the output from nvidia-smi.

This has no connection to the installed CUDA runtime version.

nvcc, the CUDA compiler-driver tool that is installed  with the CUDA toolkit, will always report the CUDA runtime version that  it was built to recognize.  It doesn't know anything about what driver  version is installed, or even if a GPU driver is installed.

Therefore, by design, these two numbers don't necessarily match, as they are reflective of two different things.



登录查看更多
11

相关内容

Docker - An open platform for distributed applications for developers and sysadmins.
【ICMR2020】持续健康状态接口事件检索
专知会员服务
17+阅读 · 2020年4月18日
《动手学深度学习》(Dive into Deep Learning)PyTorch实现
专知会员服务
115+阅读 · 2019年12月31日
Keras作者François Chollet推荐的开源图像搜索引擎项目Sis
专知会员服务
29+阅读 · 2019年10月17日
2019年机器学习框架回顾
专知会员服务
35+阅读 · 2019年10月11日
机器学习入门的经验与建议
专知会员服务
90+阅读 · 2019年10月10日
TensorFlow 2.0 学习资源汇总
专知会员服务
66+阅读 · 2019年10月9日
MIT新书《强化学习与最优控制》
专知会员服务
270+阅读 · 2019年10月9日
谷歌足球游戏环境使用介绍
CreateAMind
31+阅读 · 2019年6月27日
自然语言处理 | 使用Spacy 进行自然语言处理
机器学习和数学
18+阅读 · 2018年8月22日
基于TensorFlow的深度学习实战
七月在线实验室
9+阅读 · 2018年4月25日
如何运用Python建一个聊天机器人?
七月在线实验室
17+阅读 · 2018年1月23日
分布式TensorFlow入门指南
机器学习研究会
4+阅读 · 2017年11月28日
从零开始:深度学习软件环境安装指南
机器之心
5+阅读 · 2017年10月2日
Learning Implicit Fields for Generative Shape Modeling
Arxiv
10+阅读 · 2018年12月6日
VIP会员
相关VIP内容
【ICMR2020】持续健康状态接口事件检索
专知会员服务
17+阅读 · 2020年4月18日
《动手学深度学习》(Dive into Deep Learning)PyTorch实现
专知会员服务
115+阅读 · 2019年12月31日
Keras作者François Chollet推荐的开源图像搜索引擎项目Sis
专知会员服务
29+阅读 · 2019年10月17日
2019年机器学习框架回顾
专知会员服务
35+阅读 · 2019年10月11日
机器学习入门的经验与建议
专知会员服务
90+阅读 · 2019年10月10日
TensorFlow 2.0 学习资源汇总
专知会员服务
66+阅读 · 2019年10月9日
MIT新书《强化学习与最优控制》
专知会员服务
270+阅读 · 2019年10月9日
相关资讯
谷歌足球游戏环境使用介绍
CreateAMind
31+阅读 · 2019年6月27日
自然语言处理 | 使用Spacy 进行自然语言处理
机器学习和数学
18+阅读 · 2018年8月22日
基于TensorFlow的深度学习实战
七月在线实验室
9+阅读 · 2018年4月25日
如何运用Python建一个聊天机器人?
七月在线实验室
17+阅读 · 2018年1月23日
分布式TensorFlow入门指南
机器学习研究会
4+阅读 · 2017年11月28日
从零开始:深度学习软件环境安装指南
机器之心
5+阅读 · 2017年10月2日
Top
微信扫码咨询专知VIP会员