{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "machine_shape": "hm", "authorship_tag": "ABX9TyOGIH7rqgasim3Sz7b1rpoE", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "gpuClass": "standard", "accelerator": "GPU" }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "markdown", "source": [ "# [sgoodfriend/rl-algo-impls](https://github.com/sgoodfriend/rl-algo-impls) in Google Colaboratory\n", "## Parameters\n", "\n", "\n", "1. Wandb\n", "\n" ], "metadata": { "id": "S-tXDWP8WTLc" } }, { "cell_type": "code", "source": [ "from getpass import getpass\n", "import os\n", "os.environ[\"WANDB_API_KEY\"] = getpass(\"Wandb API key to upload metrics, videos, and models: \")" ], "metadata": { "id": "1ZtdYgxWNGwZ" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## Setup\n", "Clone [sgoodfriend/rl-algo-impls](https://github.com/sgoodfriend/rl-algo-impls) " ], "metadata": { "id": "bsG35Io0hmKG" } }, { "cell_type": "code", "source": [ "%%capture\n", "!git clone https://github.com/sgoodfriend/rl-algo-impls.git" ], "metadata": { "id": "k5ynTV25hdAf" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "Installing the correct packages:\n", "\n", "While conda and poetry are generally used for package management, the mismatch in Python versions (3.10 in the project file vs 3.8 in Colab) makes using the package yml files difficult to use. For now, instead I'm going to specify the list of requirements manually below:" ], "metadata": { "id": "jKxGok-ElYQ7" } }, { "cell_type": "code", "source": [ "%%capture\n", "!apt install python-opengl\n", "!apt install ffmpeg\n", "!apt install xvfb\n", "!apt install swig" ], "metadata": { "id": "nn6EETTc2Ewf" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "%%capture\n", "%cd /content/rl-algo-impls\n", "python -m pip install ." ], "metadata": { "id": "AfZh9rH3yQii" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## Run Once Per Runtime" ], "metadata": { "id": "4o5HOLjc4wq7" } }, { "cell_type": "code", "source": [ "import wandb\n", "wandb.login()" ], "metadata": { "id": "PCXa5tdS2qFX" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## Restart Session beteween runs" ], "metadata": { "id": "AZBZfSUV43JQ" } }, { "cell_type": "code", "source": [ "%%capture\n", "from pyvirtualdisplay import Display\n", "\n", "virtual_display = Display(visible=0, size=(1400, 900))\n", "virtual_display.start()" ], "metadata": { "id": "VzemeQJP2NO9" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "The below 5 bash scripts train agents on environments with 3 seeds each:\n", "- colab_basic.sh and colab_pybullet.sh test on a set of basic gym environments and 4 PyBullet environments. Running both together will likely take about 18 hours. This is likely to run into runtime limits for free Colab and Colab Pro, but is fine for Colab Pro+.\n", "- colab_carracing.sh only trains 3 seeds on CarRacing-v0, which takes almost 22 hours on Colab Pro+ on high-RAM, standard GPU.\n", "- colab_atari1.sh and colab_atari2.sh likely need to be run separately because each takes about 19 hours on high-RAM, standard GPU." ], "metadata": { "id": "nSHfna0hLlO1" } }, { "cell_type": "code", "source": [ "%cd /content/rl-algo-impls\n", "os.environ[\"BENCHMARK_MAX_PROCS\"] = str(1) # Can't reliably raise this to 2+, but would make it faster.\n", "!./benchmarks/colab_basic.sh\n", "!./benchmarks/colab_pybullet.sh\n", "# !./benchmarks/colab_carracing.sh\n", "# !./benchmarks/colab_atari1.sh\n", "# !./benchmarks/colab_atari2.sh" ], "metadata": { "id": "07aHYFH1zfXa" }, "execution_count": null, "outputs": [] } ] }