Hi,
Here is a modified version of your code that does proper timing.
The GPU initialization takes some time, so you want to make that before measuring runtimes.
Also cuda api is asynchronous so you need to sync when measuring time.
Also there might be some variance in the runtimes depending on the gpu usage, so you might want to run more than one.
import torch
import torch.nn as nn
import time

F = 30
data = torch.randn(1,256, F, 256, 256).cuda()

def time2D():
        conv2d = nn.Conv2d(256,256,3).cuda()
        data1 = data.reshape(F,256,256,256)
        torch.cuda.synchronize()
        start = time.time()
        out = conv2d(torch.autograd.Variable(data1))
        torch.cuda.synchronize()
        end = time.time()
        print(out.size())
        print("  --- %s ---  " %(end - start))

def time3D():
        conv3d = nn.Conv3d(256,256,(3,3,3)).cuda()
        torch.cuda.synchronize()
        start = time.time()
        out = conv3d(torch.autograd.Variable(data))
        torch.cuda.synchronize()
        end = time.time()
        print(out.size())
        print("  --- %s ---  " %(end - start))

print("Initializing cuda state")
time2D()
print("going to time2D")
time2D()
print("going to time3D")
time3D()