Skip to content

Instantly share code, notes, and snippets.

@ahmedengu
Last active February 14, 2020 04:13
Show Gist options
  • Save ahmedengu/7a15e8119557015db33727632f3e2768 to your computer and use it in GitHub Desktop.
Save ahmedengu/7a15e8119557015db33727632f3e2768 to your computer and use it in GitHub Desktop.
Installing and running H2O Driverless AI on google colab and access it using ngrok
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Driverless_AI.ipynb",
"version": "0.3.2",
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/ahmedengu/7a15e8119557015db33727632f3e2768/driverless_ai.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"metadata": {
"id": "Qwgpk8oIPVkb",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"Dont forget to update AUTH_TOKEN to equal your ngrok key\n",
"\n",
"Also update LICENSE_KEY to equal driverless ai key\n",
"\n",
"To use driverless go to the link printed below\n",
"\n",
"Driverless auth: Username: h2oai Password: h2oai"
]
},
{
"metadata": {
"id": "KFs57E-6hM8l",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"LICENSE_KEY = \"LICENSE_KEY\"\n",
"\n",
"# install driverless\n",
"!mkdir /root/.driverlessai\n",
"! echo $LICENSE_KEY >> /root/.driverlessai/license.sig\n",
"\n",
"! apt-get update\n",
"!apt-get install -y libcairo2 libpango1.0-0 opencl-headers clinfo ocl-icd-opencl-dev\n",
"! mkdir -p /etc/OpenCL/vendors && echo \"libnvidia-opencl.so.1\" > /etc/OpenCL/vendors/nvidia.icd\n",
"\n",
"!wget https://s3.amazonaws.com/artifacts.h2o.ai/releases/ai/h2o/dai/rel-1.4.2-9/x86_64-centos7/dai-1.4.2-linux-x86_64.sh\n",
"!chmod 755 dai-1.4.2-linux-x86_64.sh\n",
"!./dai-1.4.2-linux-x86_64.sh\n",
"\n",
"\n",
"# install ngrok\n",
"! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip\n",
"! unzip -qq -n ngrok-stable-linux-amd64.zip"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "8MnDqhLPDsP1",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"NGROK_AUTH = \"NGROK_AUTH\"\n",
"\n",
"from time import sleep\n",
"from IPython.display import clear_output\n",
"import requests\n",
"import json\n",
"\n",
"# keep everything running\n",
"i=0\n",
"while True:\n",
" try:\n",
" # start driverless\n",
" if len(get_ipython().getoutput('ps -ef | grep h2oai')) <= 2:\n",
" !nvidia-persistenced \n",
" !nvidia-smi -pm 1\n",
" !/content/dai-1.4.2-linux-x86_64/run-dai.sh\n",
" sleep(5)\n",
"\n",
" ngrok_link = json.loads(requests.get('http://localhost:4040/api/tunnels').text)['tunnels'][0]['public_url']\n",
" print(ngrok_link)\n",
" print(\"Username: h2oai Password: h2oai\")\n",
" sleep(10)\n",
" requests.get(ngrok_link)\n",
" except (KeyboardInterrupt, SystemExit):\n",
" raise\n",
" except:\n",
" # create ngrok port\n",
" get_ipython().system_raw('./ngrok authtoken $NGROK_AUTH && ./ngrok http 12345 &')\n",
" i+=1\n",
" if i >=5:\n",
" clear_output(wait=True)\n",
" i=0\n"
],
"execution_count": 0,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment