Repository: pytorch
Issue: Libtorch with deeplabv3_resnet101 will not forward.
Labels: module: crash,module: cpp,triaged

## 🐛 Bug

When i convert the `deeplabv3_resnet101` model and use it in Libtorch, it gives a segmentation fault on forwarding.

## To Reproduce

Steps to reproduce the behavior:

1. convert the model using python:

```
import torch
import torchvision
from torchvision import models

deeplap_model = models.segmentation.deeplabv3_resnet101(pretrained=True)
deeplap_model.cuda()
deeplap_model.eval()

class wrapper(torch.nn.Module):
    def __init__(self, model):
        super(wrapper, self).__init__()
        self.model = model
    
    def forward(self, input):
        results = []
        output = self.model(input)
        for k, v in output.items():
            results.append(v)
        return tuple(results)

model = wrapper(deeplap_model)

example = torch.rand(1, 3, 224, 224).cuda()
#example = torch.rand(1, 3, 224, 224)
# Use torch.jit.trace to generate a torch.jit.ScriptModule via tracing.
traced_script_module = torch.jit.trace(model, example)


traced_script_module.save("model.pt")
```

2.

Load the model in c++ and run an image through it.

```
std::shared_ptr<torch::jit::script::Module> module = torch::jit::load("model.pt");
module->to(torch::kCUDA);
assert(module != nullptr);
std::cout << "ok\n";


std::vector<torch::jit::IValue> inputs;
cv::Mat image;
image = cv::imread("pic.jpeg", 1);
cv::Mat image_resized;
cv::resize(image, image_resized, cv::Size(224, 224));
cv::cvtColor(image_resized, image_resized, cv::COLOR_BGR2RGB);
cv::Mat image_resized_float;
image_resized.convertTo(image_resized_float, CV_32F, 1.0 / 255);

auto img_tensor = torch::from_blob(image_resized_float.data, { 1, 224, 224, 3 }, torch::kFloat32);
cout << "img tensor loaded..\n";
img_tensor = img_tensor.permute({ 0, 3, 1, 2 });
img_tensor[0][0] = img_tensor[0][0].sub(0.485).div(0.229);
img_tensor[0][1] = img_tensor[0][1].sub(0.456).div(0.224);
img_tensor[0][2] = img_tensor[0][2].sub(0.406).div(0.225);

// to GPU
img_tensor = img_tensor.to(at::kCUDA);

torch::Tensor out_tensor2 = module->forward({ img_tensor }).toTensor(); //SEGFAULT
```

3.

Try with dummy test data:

```
std::shared_ptr<torch::jit::script::Module> module = torch::jit::load("model.pt");
	module->to(torch::kCUDA);
	assert(module != nullptr);
	std::cout << "ok\n";


	std::vector<torch::jit::IValue> inputs;
	inputs.emplace_back(torch::rand({ 64, 3, 224, 224 }));

	module->forward(inputs).toTensor();  //SEGFAULT
```



## Expected behavior

I would expect that i could run images, or data through the converted model in c++ and see the segmentation results.

## Environment

PyTorch version: 1.1.0
Is debug build: No
CUDA used to build PyTorch: 10.0

OS: Microsoft Windows 10 Home
GCC version: Could not collect
CMake version: version 3.12.3

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: 10.0.130
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin\cudnn64_7.dll

Versions of relevant libraries:
[pip3] numpy==1.16.4
[pip3] torch==1.1.0
[pip3] torchvision==0.3.0