Created
January 29, 2018 18:42
-
-
Save notoraptor/681e59d488734ee3eeedd4b29b402657 to your computer and use it in GitHub Desktop.
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
import numpy as np | |
import theano | |
import theano.tensor as T | |
import time | |
x = T.tensor4('x') | |
x = theano.shared( | |
np.random.rand(32, 128, 256, 256).astype(theano.config.floatX), | |
'x') | |
filters = theano.shared( | |
np.random.rand(256, 128, 8, 8).astype(theano.config.floatX), | |
'filters') | |
# B x 1 x 1 x T | |
y = theano.gpuarray.dnn.dnn_conv( | |
img=x, | |
kerns=filters, | |
border_mode='half', | |
precision='float32') | |
f = theano.function([], y) | |
y_ = f() | |
#f.sync_shared() | |
t0 = time.time() | |
for i in range(50): | |
print i | |
y_ = f(x_) | |
# f.sync_shared() | |
t1 = time.time() | |
print t1 - t0 | |
# rm -rf `theano-cache` | |
# export CUDA_LAUNCH_BLOCKING=1 | |
# THEANO_FLAGS=cmodule.debug=True,device=cuda,floatX=float16,dnn.conv.algo_fwd=time_once python theano_conv.py | |
# THEANO_FLAGS=cmodule.debug=True,device=cuda,floatX=float32,dnn.conv.algo_fwd=time_once python theano_conv.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment