足球环境github链接:https://github.com/google-research/football
System: Ubuntu 16.04
在安装谷歌足球游戏环境的时候可能会出现各种各样的问题。足球环境的Github主页也提供了另一种安装方式,通过Docker安装。
Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的、可移植的、自给自足的容器。开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机)、bare metal、OpenStack 集群和其他的基础应用平台。
简单来说,谷歌提供了包含安装足球环境所需的必要环境在一个Docker配置文件中,安装好Docker后,一条命令就可以创建包含足球环境的整套配置的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.
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
.
git clone https://github.com/google-research/football.git
cd football
docker build --build-arg DOCKER_BASE=ubuntu:18.04 --build-arg DEVICE=cpu . -t gfootball
docker run -it gfootball bash
docker build --build-arg DOCKER_BASE=tensorflow/tensorflow:1.12.0-gpu-py3 --build-arg DEVICE=gpu . -t gfootball
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.
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.