This file contains 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
import torch | |
import numpy as np | |
import time | |
def benchmark(): | |
SIZE_GB = 1 | |
num_iters = 100 | |
def compute(): | |
a = torch.ones(int(SIZE_GB*1000*250000)).cuda() |
This file contains 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
import tensorflow as tf | |
from tensorflow.contrib.eager.python import tfe | |
tfe.enable_eager_execution() | |
context = tf.device('/gpu:0') | |
context.__enter__() | |
# download resnet_model | |
import sys, os, urllib.request | |
resnet_model_url="https://raw.githubusercontent.com/tensorflow/models/master/official/resnet/resnet_model.py" | |
response = urllib.request.urlopen(resnet_model_url) |
This file contains 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
import argparse | |
import os | |
import sys | |
from six.moves import shlex_quote | |
parser = argparse.ArgumentParser(description="Run commands") | |
parser.add_argument('-w', '--num-workers', default=1, type=int, | |
help="Number of workers") | |
parser.add_argument('-r', '--remotes', default=None, | |
help='The address of pre-existing VNC servers and ' |
This file contains 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
import numpy as np | |
import tensorflow as tf | |
import scipy | |
from tensorflow.contrib.eager.python import tfe | |
tfe.enable_eager_execution() | |
# manual numpy example | |
# X = np.array(([[0., 1], [2, 3]])) | |
# W0 = X | |
# W1 = np.array(([[0., 1], [2, 3]]))/10 |
This file contains 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
# Times: min: 440.60, median: 452.39, mean: 453.87 | |
import util as u | |
u.check_mkl() | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim |
This file contains 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
import tensorflow as tf | |
from tensorflow.python.ops import control_flow_ops | |
from tensorflow.contrib import graph_editor as ge | |
def make_conditional_initializer(v): | |
"""Makes initializer of variable var lazy, returns new conditional init | |
op.""" | |
cond = tf.is_variable_initialized(v) |
This file contains 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
def copy_initializer(from_var, to_var): | |
from tensorflow.contrib import graph_editor as ge | |
assert ge.reroute_a2b_ts(from_var.initial_value, to_var.initial_value), "No copy took place" |
This file contains 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
1. Making Pull Request | |
First, click "Fork" on github tensorflow page | |
Then in Terminal: | |
export user=yaroslavvb | |
export branch_name | |
git clone https://github.com/$user/tensorflow.git | |
cd tensorflow |
This file contains 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
# Example of profiling session.run overhead | |
# for python profiling | |
# python -m cProfile -o session-run-benchmark-feed.prof session-run-benchmark.py feed_dict | |
# python -m cProfile -o session-run-benchmark-variable.prof session-run-benchmark.py variable | |
# pip install snakeviz | |
# snakeviz session-run-benchmark-feed.prof | |
# snakeviz session-run-benchmark.prof | |
# | |
# | |
# Feed_dict: 147 usec, no feed dict, 71 usec |
This file contains 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
# GPU picking | |
# http://stackoverflow.com/a/41638727/419116 | |
# Nvidia-smi GPU memory parsing. | |
# must set | |
# CUDA_DEVICE_ORDER=PCI_BUS_ID | |
# see https://github.com/tensorflow/tensorflow/issues/152#issuecomment-273663277 | |
# Tested on nvidia-smi 370.23 | |
def run_command(cmd): |