NVIDIA / TensorRT

NVIDIA® TensorRT™ is an SDK for high-performance deep learning inference on NVIDIA GPUs. This repository contains the open source components of TensorRT.
https://developer.nvidia.com/tensorrt
Apache License 2.0
10.55k stars 2.1k forks source link

Warning: Encountered known unsupported method torch.randn #265

Closed kshamaramesh closed 4 years ago

kshamaramesh commented 4 years ago

Description

Environment

TensorRT Version: 5.1.5 GA GPU Type: Nvidia Driver Version: CUDA Version: 10.0 CUDNN Version: 410 Operating System + Version: Ubuntu 16.04 Python Version (if applicable): 3.5 TensorFlow Version (if applicable): PyTorch Version (if applicable): 1.3.1 Baremetal or Container (if container which image + tag):

Relevant Files

class VAEGen(nn.Module):
    # VAE architecture
    def __init__(self, input_dim):
        super(VAEGen, self).__init__()
        # dim = params['dim']
        # n_downsample = params['n_downsample']
        # n_res = params['n_res']
        # activ = params['activ']
        # pad_type = params['pad_type']

        # content encoder
        self.enc = ContentEncoder(2, 4, 3, 64, 'in', 'relu', pad_type='reflect')
        self.dec = Decoder(2, 4, self.enc.output_dim, 3, res_norm='in', activ='relu', pad_type='reflect')

    def forward(self, images):
        # This is a reduced VAE implementation where we assume the outputs are multivariate Gaussian distribution with mean = hiddens and std_dev = all ones.
        hiddens,_ = self.encode(images)
        if self.training == False:
            noise = Variable(torch.randn(hiddens.size()).cuda(hiddens.data.get_device()))
            images_recon = self.decode(hiddens + noise)
        else:
            images_recon = self.decode(hiddens)
        return images_recon, hiddens

    def encode(self, images):
        hiddens = self.enc(images)
        **noise = Variable(torch.randn(hiddens.size()).cuda(hiddens.data.get_device()))
        return hiddens, noise**

    def decode(self, hiddens):
        images = self.dec(hiddens)
        return images

Steps To Reproduce

rmccorm4 commented 4 years ago

Hi @kshamaramesh,

Can you please provide more details?

It also looks like this is cross-posted here:

So let me know if you've already fixed your issue.

rmccorm4 commented 4 years ago

Going with this solution since OP gave it a 👍 - https://github.com/NVIDIA-AI-IOT/torch2trt/issues/186#issuecomment-564184199