vision: [C++ Frontend] Simple example with VGG gives memory error
🐛 Bug
Hello! I have compiled the master branch of torchvision and used the pre-built libtorch lib. I manage to run the simple HelloWorld example using the ResNet18 but I get “Unhandled exception at 0x00007FFDB7D2A799” error when using the VGG16 network. It fails both for Release and Debug configurations (while ResNet works for both of them). Any ideas? Thanks.
To Reproduce
#include <iostream>
#include <torchvision/models/vgg.h>
//#include <torchvision/models/resnet.h>
int main()
{
auto model = vision::models::VGG16();
//auto model = vision::models::ResNet18();
model->eval();
// Create a random input tensor and run it through the model.
//auto in = torch::rand({ 1, 3, 10, 10 });
auto in = torch::rand({ 10, 3, 224, 224 });
auto out = model->forward(in);
std::cout << out;
system("pause");
}
By the way as a sanity check, the equivalent python code works:
import torch
import torchvision.models as models
vgg16 = models.vgg16(pretrained=False)
vgg16.eval()
in_tensor = torch.rand(size=(10, 3, 224, 224))
out_tensor = vgg16.forward(in_tensor)
print(out_tensor)
Environment
Windows 10 Visual Studio 2017 pre-build libtorch Torchvision build from master repo CMake 3.16
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (7 by maintainers)
I opened an issue in pytorch: https://github.com/pytorch/pytorch/issues/41316.
I have implemented VGG19 model from torchvision VGG code to try to find the error by debugging.
But there is no problem with this model when executing this code
So I still don’t know why using torchvision model fails. I would say that the model is the same isn’t it?