Skip to content

Instantly share code, notes, and snippets.

@ebenolson
Last active August 29, 2015 14:24
Show Gist options
  • Save ebenolson/ae0330a36f0ae4e7949b to your computer and use it in GitHub Desktop.
Save ebenolson/ae0330a36f0ae4e7949b to your computer and use it in GitHub Desktop.
import numpy as np
import gc
import memory_profiler
import theano
import theano.tensor as T
from theano.sandbox.cuda.dnn import dnn_conv
X = T.tensor4()
W = T.tensor4()
f = theano.function([X, W], dnn_conv(X, W))
X0 = np.zeros((1, 1, 5, 5)).astype('float32')
W0 = np.zeros((1, 1, 5, 5)).astype('float32')
gc.collect()
gc.collect()
gc.collect()
mem0 = memory_profiler.memory_usage(-1)[0]
for _ in range(100):
for _ in range(1000):
_ = f(X0, W0)
gc.collect()
gc.collect()
gc.collect()
mem = memory_profiler.memory_usage(-1)[0]
print(mem - mem0)
@ebenolson
Copy link
Author

output:

Using gpu device 0: GeForce GTX TITAN
0.13671875
0.14453125
0.171875
0.26171875
0.35546875
0.4453125
0.53515625
0.62890625
0.71875
0.8125
0.90234375
0.99609375
1.0859375
1.17578125
1.26953125
1.359375
1.453125
1.54296875
1.63671875
1.7265625
1.8203125
1.91015625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment