Forums - Model does not work on GPU

2 posts / 0 new
Last post
Model does not work on GPU
john_bh
Join Date: 13 Jun 23
Posts: 5
Posted: Wed, 2023-07-26 21:21
Hi,
 
When i use the commend: snpe-net-run --container model.dlc --input_list raw_list.txt --output_dir cpu_output  , that work well;
but when i run on gpu,  use the commend : snpe-net-run --container model.dlc --input_list raw_list.txt --output_dir gpu_output --use_gpu ,
 
WARNING: linker: Warning: "/data/local/tmp/snpe_net_run_2.12/aarch64-android/lib/libc++_shared.so" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring)
WARNING: linker: Warning: "/data/local/tmp/snpe_net_run_2.12/aarch64-android/lib/libc++_shared.so" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring)
error_code=1002; error_message=Layer parameter value is invalid. error_code=1002; error_message=Layer parameter value is invalid. No backend could validate Op=deconv.2.transpose_0 Type=DepthToSpace error code=3110; error_component=Model Validation; line_no=796; thread_id=505637182800; error_component=Model Validation; line_no=283; thread_id=505740017360
 
The model define as follows:
 
import torch
import torch.nn.functional as F
import torch.nn as nn
 
class Net(nn.Module):
    def __init__(self, num_feats, depth_chanels, color_channel, kernel_size):
        super(Net, self).__init__()
        self.act = nn.LeakyReLU(negative_slope=0.2, inplace=True)
        self.conv_dp1 = nn.Conv2d(in_channels=16, out_channels=num_feats,
                                  kernel_size=kernel_size, padding=1)
        self.conv_rgb1 = nn.Conv2d(in_channels=16, out_channels=num_feats,
                                   kernel_size=kernel_size, padding=1)
 
        self.rgb_cbl2 = nn.Conv2d(in_channels=num_feats, out_channels=24, kernel_size=kernel_size, padding=1)
 
        self.MSB1 = nn.Sequential(nn.Conv2d(in_channels=num_feats, out_channels=num_feats,
                                            kernel_size=kernel_size, padding=1),
                                  self.act)
 
        self.MSB2 = nn.Sequential(nn.Conv2d(in_channels=num_feats + 24, out_channels=num_feats,
                                            kernel_size=kernel_size, padding=1),
                                  self.act)
 
        self.MSB3 = nn.Sequential(nn.Conv2d(in_channels=num_feats + 24, out_channels=num_feats,
                                            kernel_size=kernel_size, padding=1),
                                  self.act)
 
        self.deconv = nn.Sequential(
            self.act,
            nn.Conv2d(in_channels=num_feats, out_channels=16 * 4, kernel_size=kernel_size, padding=1),
            nn.PixelShuffle(4),
            nn.Conv2d(in_channels=4, out_channels=1, kernel_size=kernel_size, padding=1)
        )
 
 
    def forward(self, x):
        re_im, re_dp = x[:, 0:16, :, :],x[:, 16:, :, :]
        
        dp_in = self.act(self.conv_dp1(re_dp))
        dp1 = self.MSB1(dp_in)
 
        rgb1 = self.act(self.conv_rgb1(re_im))
        rgb2 = self.act(self.rgb_cbl2(rgb1))
 
        ca1_in = torch.cat([dp1, rgb2], dim=1)
        dp2 = self.MSB2(ca1_in)
 
        ca2_in = torch.cat([dp2, rgb2], dim=1)
 
        dp3 = self.MSB3(ca2_in)
        dp = dp_in + dp3
        out = self.deconv(dp)
 
        return out
 
 
input_shape = [1,32,120,160]
 
fdsr = Net(num_feats=32, depth_chanels=1, color_channel=3, kernel_size=3)
 
input = torch.randn(input_shape)
 
def trace_and_save(module, inputs, filename):
    torchscript_model = torch.jit.trace(module, inputs)
    torchscript_model.save(filename)
 
trace_and_save(fdsr, [input], 'model_test.pt')
 
  • Up0
  • Down0
yunxqin
Join Date: 2 Mar 23
Posts: 44
Posted: Fri, 2023-07-28 00:15

Dear developer,

You can convert the torch model to onnx model and try again.

BR.

Yunxiang

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.