Created
November 29, 2019 12:12
-
-
Save saippuakauppias/73be5c2b3af3dc4d00d643e00167d2d5 to your computer and use it in GitHub Desktop.
TensorBoard + ngrok tunnel: access to tf logs from anywhere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
authtoken: <copy key from https://dashboard.ngrok.com/auth> | |
log_level: error | |
log: stderr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# path to tensorboard logs | |
LOGS_DIR="checkpoint/run1" | |
# ngrok.yml need contains `log_level` and `log`, because api not working without it | |
# https://github.com/inconshreveable/ngrok/issues/313 | |
ROOT=`pwd` | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' # No Color | |
if [ ! -f "${ROOT}/ngrok-stable-linux-amd64.zip" ] | |
then | |
echo 'download ngrok...' | |
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip | |
fi | |
if [ ! -f "${ROOT}/ngrok" ] | |
then | |
echo 'unzip ngrok...' | |
unzip ngrok-stable-linux-amd64.zip | |
fi | |
CHECK_TB=`ps | grep tensorboar` | |
if [ -z "${CHECK_TB}" ] | |
then | |
echo 'run tensorboard...' | |
tensorboard --logdir ${LOGS_DIR} --host 0.0.0.0 --port 6006 > /dev/null 2>&1 & | |
fi | |
CHECK_NGROK=`ps | grep ngrok` | |
if [ -z "${CHECK_NGROK}" ] | |
then | |
./ngrok http -config=ngrok.yml 6006 > /dev/null 2>&1 & | |
for i in {1..10} | |
do | |
sleep 1 | |
CHECK_NGROK=`ps | grep ngrok` | |
if [ ! -z "${CHECK_NGROK}" ] | |
then | |
sleep 1 # fix 'IndexError: list index out of range' | |
break | |
fi | |
done | |
fi | |
echo -e "${GREEN}Ngrok tunnel:${NC}" | |
curl -s http://127.0.0.1:4040/api/tunnels | python3 -c \ | |
"import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment