Skip to content

Commit

Permalink
Update colab notebook to using clang 9
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 327609245
Change-Id: I0419b5f9650559ba37df3981a05440ee3f80b8bb
  • Loading branch information
elkhrt authored and open_spiel@google.com committed Aug 20, 2020
1 parent 1e37890 commit 30ab4d2
Showing 1 changed file with 78 additions and 77 deletions.
155 changes: 78 additions & 77 deletions open_spiel/colabs/install_open_spiel.ipynb
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "install_open_spiel.ipynb",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "odj1Coq5H080",
"colab": {}
"id": "odj1Coq5H080"
},
"outputs": [],
"source": [
"#@title ##### License { display-mode: \"form\" }\n",
"# Copyright 2019 DeepMind Technologies Ltd. All rights reserved.\n",
Expand All @@ -36,9 +24,7 @@
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
],
"execution_count": 0,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -49,9 +35,9 @@
"source": [
"# OpenSpiel\n",
"\n",
"* This Colab get's you started with installing OpenSpiel and its dependencies.\n",
"* This Colab gets you started with installing OpenSpiel and its dependencies.\n",
"* OpenSpiel is a framework for reinforcement learning in games.\n",
"* The insturctions are adapted from [here](https://github.com/deepmind/open_spiel/blob/master/docs/install.md)."
"* The instructions are adapted from [here](https://github.com/deepmind/open_spiel/blob/master/docs/install.md)."
]
},
{
Expand All @@ -76,16 +62,16 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "9pdMX_Vs9Fcn",
"colab": {}
"id": "9pdMX_Vs9Fcn"
},
"outputs": [],
"source": [
"!python --version"
],
"execution_count": 0,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -99,56 +85,56 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "9MALNBoMYVxf",
"colab": {},
"colab_type": "code",
"colab": {}
"id": "9MALNBoMYVxf"
},
"outputs": [],
"source": [
"INSTALL_DIR = '/usr/local/open_spiel'"
],
"execution_count": 0,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "EFyY5_UGZU_5",
"colab": {},
"colab_type": "code",
"colab": {}
"id": "EFyY5_UGZU_5"
},
"outputs": [],
"source": [
"!git config --global advice.detachedHead false\n",
"!git clone https://github.com/deepmind/open_spiel $INSTALL_DIR\n",
"!git clone -b 'v2.2.4' --single-branch --depth 1 https://github.com/pybind/pybind11.git $INSTALL_DIR/pybind11\n",
"!git clone -b 'develop' --single-branch --depth 1 https://github.com/jblespiau/dds.git $INSTALL_DIR/open_spiel/games/bridge/double_dummy_solver\n",
"!git clone -b '20200225.1' --single-branch --depth 1 https://github.com/abseil/abseil-cpp.git $INSTALL_DIR/open_spiel/abseil-cpp"
],
"execution_count": 0,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "a3xXzNx8HKur",
"colab": {},
"colab_type": "code",
"colab": {}
"id": "a3xXzNx8HKur"
},
"outputs": [],
"source": [
"#@title Optional dependencies: { display-mode: \"both\" }\n",
"BUILD_WITH_HANABI = False #@param {type:\"boolean\"}\n",
"BUILD_WITH_ACPC = False #@param {type:\"boolean\"}\n",
"if BUILD_WITH_HANABI:\n",
" %env BUILD_WITH_HANABI=ON\n",
" !git clone -b 'master' --single-branch --depth 15 https://github.com/deepmind/hanabi-learning-environment.git $INSTALL_DIR/open_spiel/games/hanabi/hanabi-learning-environment\n",
" !pushd $INSTALL_DIR/open_spiel/games/hanabi/hanabi-learning-environment && git checkout 'b31c973' && popd\n",
" !pushd $INSTALL_DIR/open_spiel/games/hanabi/hanabi-learning-environment \u0026\u0026 git checkout 'b31c973' \u0026\u0026 popd\n",
"\n",
"if BUILD_WITH_ACPC:\n",
" %env BUILD_WITH_ACPC=ON\n",
" !git clone -b 'master' --single-branch --depth 1 https://github.com/jblespiau/project_acpc_server.git $INSTALL_DIR/open_spiel/games/universal_poker/acpc\n"
],
"execution_count": 0,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -162,18 +148,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "WMQkWaqNUCyB",
"colab": {},
"colab_type": "code",
"colab": {}
"id": "WMQkWaqNUCyB"
},
"outputs": [],
"source": [
"# we keep some baked-in Colab dependencies:\n",
"!sed -e '/IPython/d' -e '/pip/d' -e '/matplotlib/d' $INSTALL_DIR/requirements.txt >> /tmp/requirements.txt\n",
"!sed -e '/IPython/d' -e '/pip/d' -e '/matplotlib/d' $INSTALL_DIR/requirements.txt \u003e\u003e /tmp/requirements.txt\n",
"!pip3 install -r /tmp/requirements.txt"
],
"execution_count": 0,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -187,20 +173,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "5AFHN81u9XKr",
"colab": {}
"id": "5AFHN81u9XKr"
},
"outputs": [],
"source": [
"!apt-get install clang-9\n",
"!mkdir -p $INSTALL_DIR/build\n",
"%cd $INSTALL_DIR/build\n",
"!CXX=clang++ cmake -DPython_TARGET_VERSION=3.6 -DCMAKE_CXX_COMPILER=${CXX} ../open_spiel\n",
"!CXX=`which clang++-9` cmake -DPython_TARGET_VERSION=3.6 -DCMAKE_CXX_COMPILER=${CXX} ../open_spiel\n",
"!make -j$(nproc)\n",
"%cd /content"
],
"execution_count": 0,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -214,35 +201,35 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "XdvmS5zrAtae",
"colab": {}
"id": "XdvmS5zrAtae"
},
"outputs": [],
"source": [
"import sys\n",
"import os\n",
"sys.path.append(INSTALL_DIR)\n",
"sys.path.append(os.path.join(INSTALL_DIR, 'build/python')) # for pyspiel.so"
],
"execution_count": 0,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "ss85qWHe6qEZ",
"colab": {}
"id": "ss85qWHe6qEZ"
},
"outputs": [],
"source": [
"# verify that Python can find the open_spiel & pyspiel modules\n",
"# verify that Python can find the open_spiel \u0026 pyspiel modules\n",
"import importlib\n",
"assert importlib.util.find_spec(\"open_spiel\") is not None\n",
"assert importlib.util.find_spec(\"pyspiel\") is not None"
],
"execution_count": 0,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -256,18 +243,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "k8L1Al-HEHWD",
"colab": {}
"id": "k8L1Al-HEHWD"
},
"outputs": [],
"source": [
"# run_python_test calls the python interpreter directly thus setting PYTHONPATH\n",
"%set_env PYTHONPATH=/env/python:$INSTALL_DIR:$INSTALL_DIR/build/python\n",
"!pushd $INSTALL_DIR/build && ctest -j$(nproc) --output-on-failure ../open_spiel && popd"
],
"execution_count": 0,
"outputs": []
"!pushd $INSTALL_DIR/build \u0026\u0026 ctest -j$(nproc) --output-on-failure ../open_spiel \u0026\u0026 popd"
]
},
{
"cell_type": "markdown",
Expand All @@ -281,11 +268,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "ewMXCaUw8d9Q",
"colab": {}
"id": "ewMXCaUw8d9Q"
},
"outputs": [],
"source": [
"import numpy as np\n",
"import pyspiel\n",
Expand All @@ -296,9 +285,21 @@
"while not state.is_terminal():\n",
" state.apply_action(np.random.choice(state.legal_actions()))\n",
" print(str(state) + '\\n')"
],
"execution_count": 0,
"outputs": []
]
}
]
],
"metadata": {
"accelerator": "GPU",
"colab": {
"collapsed_sections": [],
"name": "install_open_spiel.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit 30ab4d2

Please sign in to comment.