Skip to content

Instantly share code, notes, and snippets.

@kengz
Last active May 25, 2021 05:36
Show Gist options
  • Save kengz/6fd52a902129fb6d4509c721d71bda48 to your computer and use it in GitHub Desktop.
Save kengz/6fd52a902129fb6d4509c721d71bda48 to your computer and use it in GitHub Desktop.
SLM_Lab_Colab.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "SLM_Lab_Colab.ipynb",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/kengz/6fd52a902129fb6d4509c721d71bda48/slm_lab_colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nnGf_E2T7d__"
},
"source": [
"# SLM Lab Colab Example\n",
"\n",
">*Although useful for quick exploration, running SLM Lab fully on Colab/Jupyter is not recommended. This notebook is set up for illustrative purposes as requested by a number users.*\n",
"\n",
"See https://slm-lab.gitbook.io/slm-lab/setup/installation for the recommended way to setup and run SLM Lab.\n",
"\n",
"---\n",
"*Credit to [@piosif97](https://github.com/piosif97) for the initiative and discussion that led to this notebook.*"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "gwD6UuUE-a6D"
},
"source": [
"#### 1. Clone the repo and cd into the folder."
]
},
{
"cell_type": "code",
"metadata": {
"id": "av8zYQQxsGdm"
},
"source": [
"!git clone https://github.com/kengz/SLM-Lab.git"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "147ddSbWtJU8"
},
"source": [
"%cd /content/SLM-Lab"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "MfrncRH9-j-1"
},
"source": [
"#### 2. Run the setup script.\n",
"Note that you'd need to press \"enter\" in the interactive shell in the output cell."
]
},
{
"cell_type": "code",
"metadata": {
"id": "sdE_ZyiGtKQ7"
},
"source": [
"!./bin/setup"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "4I6_Ola1-6DL"
},
"source": [
"#### 3. Source the `lab` environment directly and run in headless mode.\n",
"\n",
"Since this evaluates as a bash session, you'd need to wait a few minutes for it to finish before Colab outputs the logs here."
]
},
{
"cell_type": "code",
"metadata": {
"id": "NzasgTwN2O91"
},
"source": [
"%%bash\n",
"# since each shell is a new bash session, this sources the Conda environment directly\n",
"export PATH=~/miniconda3/envs/lab/bin:$PATH\n",
"# and we run it in headless mode (Colab has no GUI)\n",
"# NOTE since each cell evaluates as a session,\n",
"# the logs will only be printed in the cell output when the command is finished,\n",
"# i.e. logs don't stream in here, so wait a few minutes to see the output\n",
"xvfb-run -a python run_lab.py slm_lab/spec/demo.json dqn_cartpole dev"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "WIXjhpex4gXd"
},
"source": [
""
],
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment