Open cdcseacave opened 1 year ago
you need to import the function at first
from pytorch_memlab import profile_every
still does not produce any output:
import torch
from pytorch_memlab import LineProfiler
from pytorch_memlab import profile_every
@profile_every(1)
def inner():
torch.nn.Linear(100, 100).cuda()
def outer():
linear = torch.nn.Linear(100, 100).cuda()
linear2 = torch.nn.Linear(100, 100).cuda()
inner()
with LineProfiler(outer, inner) as prof:
outer()
prof.display()
output:
ubuntu@65:~$ python prof.py
No data collected
try:
import torch
from pytorch_memlab import LineProfiler
from pytorch_memlab import profile_every
@profile_every(1)
def inner():
torch.nn.Linear(100, 100).cuda()
def outer():
linear = torch.nn.Linear(100, 100).cuda()
linear2 = torch.nn.Linear(100, 100).cuda()
inner()
outer()
ubuntu@65:~$ python prof.py
## inner
active_bytes reserved_bytes line code
all all
peak peak
80.00K 2.00M 5 @profile_every(1)
6 def inner():
120.00K 2.00M 7 torch.nn.Linear(100, 100).cuda()
for me it does not work at all I even tried your example code, without profiler does nothing, with profiler tag it does not compile, see bellow: