Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@william-r-s
william-r-s / gpu_check.py
Created August 23, 2018 20:18
GPU Check - verify that your job has access to enough GPUS with free memory
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('n', type=int, nargs='?', default=1)
args = parser.parse_args()
import subprocess
subprocess.run("hostname", check=True)
import os
print("CUDA_VISIBLE_DEVICES=" +
os.environ.get("CUDA_VISIBLE_DEVICES", default=""))
@william-r-s
william-r-s / fully_connected_preloaded_var.py
Created June 25, 2017 19:16
slice_input_producer, allowing passing in input data for inference
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@william-r-s
william-r-s / gist:22d5dfb3365e26209dc348b89abc0402
Created June 13, 2017 18:12
Ploty + matplotlib in hydrogen
import matplotlib.pyplot as plt
import numpy as np
import plotly.tools as tls
from plotly import offline as py
py.init_notebook_mode()
plt.ioff()
t = np.linspace(0, 20, 500)
@william-r-s
william-r-s / tensorflow-installation.sh
Created May 26, 2017 01:33
Tensorflow Installation Tricks
#Installing CUDA 8.0, download runfiles version
#https://stackoverflow.com/questions/34670989/cuda-7-5-installation-unsupported-compiler-error
sudo apt-get install gcc-4.8
sudo update-alternatives --remove-all gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
#https://devtalk.nvidia.com/default/topic/983777/can-t-locate-installutils-pm-in-inc/
./cuda*.run --tar mxvf
sudo cp InstallUtils.pm /usr/lib/x86_64-linux-gnu/perl-base/
@william-r-s
william-r-s / trace_tensorflow.py
Last active February 17, 2017 22:25
tensorflow trace code
from tensorflow.python.client import timeline
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
sess.run([tensor], options=run_options, run_metadata=run_metadata)
# Create the Timeline object, and write it to a json
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with open('timeline.json', 'w') as f:
f.write(ctf)
@william-r-s
william-r-s / gist:192ff7f1f07ed2d67d60
Created November 19, 2014 20:32
Web scraping for audible.com wishlist (using chrome addon from http://webscraper.io/)
{"startUrl":"http://www.audible.com/wl/sortType=createdate&sortOrder=dsc&totalAsinsPerPage=1000&page=1","selectors":[{"parentSelectors":["table_row"],"type":"SelectorText","multiple":false,"id":"description","selector":"td.adbl-col-2 > div > div.a-p-r-28.adbl-prod-result.adbl-flyout-cont-marker > div.adbl-prod-social-overlay.adbl-hasActivity.adbl-flyout-marker > div > div > p","regex":"","delay":""},{"parentSelectors":["_root"],"type":"SelectorElement","multiple":true,"id":"table_row","selector":"tr:nth-of-type(n+2)","delay":""},{"parentSelectors":["table_row"],"type":"SelectorText","multiple":false,"id":"title","selector":"div.adbl-prod-title a.adbl-link","regex":"","delay":""},{"parentSelectors":["table_row"],"type":"SelectorText","multiple":false,"id":"author","selector":"div.adbl-prod-author a.adbl-link","regex":"","delay":""}],"_id":"audible"}