Hi I have model with n layer Convolution.
I just need the output till the m layer where m less then n.
Can some one help me out.
Thanks
Hi I have model with n layer Convolution.
I just need the output till the m layer where m less then n.
Can some one help me out.
Thanks
What have you tried so far?
this mathod…
nn.Sequential(*list(model.children())[:8])(img.cuda())
When I am using it after sometime there is an error throw about out of memory for cuda.
RuntimeError: CUDA error: out of memory
If you’re experiencing this OOM memory after a while, could you check, if your GPU memory usage is growing?
Also, are you storing some variables which are still attached to the computation graph?
A common mistake is to store the loss for further debugging without detaching it:
# Memory will grow
loss = criterion(output, target)
losses.append(loss)
# This should be the right way, if you don't need any ops on loss anymore
loss = criterion(output, target)
losses.append(loss.detach().item())
Thanks @ptrblck … but I am not calculating loss … I just want forward pass output. Also I am confuse about my above doubt for till m layer forward pass of model.
featmap = nn.Sequential(*list(model.children())[:8])(img.cuda())
Where it is given correct or not?
Thnaks
Do you need to call backward
at some time?
If not, you could wrap your code in a with torch.no_grad():
block to save some memory.
It depends on your forward
method, since your nn.Sequential
module will only contain the children without the actual forward
implementation.
Could you post your model code so that we could have a look?