Created
February 2, 2018 14:19
-
-
Save KellenSunderland/b325a5ba208001f0e4877464fefde155 to your computer and use it in GitHub Desktop.
Autotune repro.
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 mxnet as mx | |
from collections import namedtuple | |
import numpy as np | |
import cv2 | |
Batch = namedtuple('Batch', ['data']) | |
from scipy.misc import imread, imresize | |
import time | |
import os | |
from mxnet.gluon.model_zoo import vision | |
for auto_tune in ("0","1"): | |
os.environ["MXNET_CUDNN_AUTOTUNE_DEFAULT"]=auto_tune | |
resnet50 = vision.resnet50_v1(pretrained=True,ctx=mx.gpu()) | |
img = imread("/home/ubuntu/repos/mxnet-ssd/data/demo/dog.jpg") | |
img = imresize(img,[512,512]) | |
img = np.swapaxes(img, 0, 2) | |
img = np.swapaxes(img, 1, 2) | |
img = mx.nd.array(img[np.newaxis, :],ctx=mx.gpu()) | |
warmup=resnet50.forward(img).asnumpy() | |
start = time.time() | |
N = 50 | |
for i in range(N): | |
a = resnet50.forward(img).asnumpy() | |
end = time.time() | |
dt = end-start | |
print("with autotune = " + str(os.environ["MXNET_CUDNN_AUTOTUNE_DEFAULT"]) + ", took " + str(dt) + " for " + str(N) + " runs, avg per image = " + str(dt/float(N))) | |
#with autotune = 0, took 2.5871667861938477 for 50 runs, avg per image = 0.05174333572387695 | |
#with autotune = 1, took 0.810204029083252 for 50 runs, avg per image = 0.016204080581665038 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment