Repository: pytorch/TensorRT

Issue:
Module tests fail because of segfault in cuDNN destructor
The tests pass functionality wise, but in the clean up, the test segfaults. It seems like this is a issue others have seen in libtorch https://github.com/pytorch/pytorch/issues/17658


Discussion:
Recent issues may be fixed in PyTorch next with this https://github.com/pytorch/pytorch/pull/36416
This issue has not seen activity for 30 days, Remove stale label or comment or this will be closed in 5 days
This issue has not seen activity for 30 days, Remove stale label or comment or this will be closed in 5 days

Resolving patch:
diff --git a/py/setup.py b/py/setup.py
--- a/py/setup.py
+++ b/py/setup.py
@@ -16,7 +16,7 @@
 
 dir_path = os.path.dirname(os.path.realpath(__file__))
 
-__version__ = '0.0.3'
+__version__ = '0.1.0a0'
 
 CXX11_ABI = False
 
@@ -158,7 +158,8 @@ def run(self):
     cpp_extension.CUDAExtension('trtorch._C',
                                 ['trtorch/csrc/trtorch_py.cpp'],
                                 library_dirs=[
-                                    dir_path + '/trtorch/lib/'
+                                    (dir_path + '/trtorch/lib/'),
+                                    "/opt/conda/lib/python3.6/config-3.6m-x86_64-linux-gnu"
                                 ],
                                 libraries=[
                                     "trtorch"
@@ -176,7 +177,14 @@ def run(self):
                                     "-Wno-deprecated-declarations",
                                     "-Wl,--no-as-needed",
                                     "-ltrtorch",
-                                    "-Wl,-rpath,$ORIGIN/lib"
+                                    "-Wl,-rpath,$ORIGIN/lib",
+                                    "-lpthread",
+                                    "-ldl",
+                                    "-lutil",
+                                    "-lrt",
+                                    "-lm",
+                                    "-Xlinker",
+                                    "-export-dynamic"
                                 ] + (["-D_GLIBCXX_USE_CXX11_ABI=1"] if CXX11_ABI else ["-D_GLIBCXX_USE_CXX11_ABI=0"]),
                                 undef_macros=[ "NDEBUG" ]
                             )
@@ -196,7 +204,7 @@ def run(self):
     long_description=long_description,
     ext_modules=ext_modules,
     install_requires=[
-        'torch==1.5.1',
+        'torch==1.6.0',
     ],
     setup_requires=[],
     cmdclass={
@@ -210,7 +218,7 @@ def run(self):
     license="BSD",
     packages=find_packages(),
     classifiers=[
-        "Development Status :: 3 - Alpha",
+        "Development Status :: 4 - Beta",
         "Environment :: GPU :: NVIDIA CUDA",
         "License :: OSI Approved :: BSD License",
         "Intended Audience :: Developers",
@@ -224,7 +232,7 @@ def run(self):
         "Topic :: Software Development",
         "Topic :: Software Development :: Libraries"
     ],
-    python_requires='>=3.5',
+    python_requires='>=3.6',
     include_package_data=True,
     package_data={
         'trtorch': ['lib/*.so'],


Test patch:
diff --git a/tests/core/converters/test_activation.cpp b/tests/core/converters/test_activation.cpp
--- a/tests/core/converters/test_activation.cpp
+++ b/tests/core/converters/test_activation.cpp
@@ -112,7 +112,7 @@ TEST(Converters, ATenHardTanhCustomRangeConvertsCorrectly) {
 TEST(Converters, ATenPReLUConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(1)):
+            %1 : Float(1:1)):
         %3 : Tensor = aten::prelu(%0, %1)
         return (%3))IR";
 
@@ -135,7 +135,7 @@ TEST(Converters, ATenPReLUConvertsCorrectly) {
 TEST(Converters, ATenPReLUMultiChannelConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(10)):
+            %1 : Float(10:1)):
         %3 : Tensor = aten::prelu(%0, %1)
         return (%3))IR";
 
diff --git a/tests/core/converters/test_batch_norm.cpp b/tests/core/converters/test_batch_norm.cpp
--- a/tests/core/converters/test_batch_norm.cpp
+++ b/tests/core/converters/test_batch_norm.cpp
@@ -7,10 +7,10 @@
 TEST(Converters, ATenBatchNormConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1: Float(5),
-            %2: Float(5),
-            %3: Float(5),
-            %4: Float(5)):
+            %1: Float(5:1),
+            %2: Float(5:1),
+            %3: Float(5:1),
+            %4: Float(5:1)):
         %5 : bool = prim::Constant[value=0]()
         %6 : float = prim::Constant[value=1.0000000000000001e-05]()
         %7 : float = prim::Constant[value=0.10000000000000001]()
diff --git a/tests/core/converters/test_concat.cpp b/tests/core/converters/test_concat.cpp
--- a/tests/core/converters/test_concat.cpp
+++ b/tests/core/converters/test_concat.cpp
@@ -31,7 +31,7 @@ TEST(Converters, ATenCatPureTensorConvertsCorrectly) {
 TEST(Converters, ATenCatDiffTensorConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(5)):
+            %1 : Float(5:1)):
         %2 : Tensor[] = prim::ListConstruct(%0, %1)
         %3 : int = prim::Constant[value=0]()
         %4 : Tensor = aten::cat(%2, %3)
diff --git a/tests/core/converters/test_conv_deconv.cpp b/tests/core/converters/test_conv_deconv.cpp
--- a/tests/core/converters/test_conv_deconv.cpp
+++ b/tests/core/converters/test_conv_deconv.cpp
@@ -39,8 +39,8 @@ void conv_test_helper(std::string graph_ir) {
 TEST(Converters, ATenConvolutionConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(8, 3, 5, 5),
-            %2 : Float(8)):
+            %1 : Float(8:45, 3:15, 5:5, 5:1),
+            %2 : Float(8:1)):
         %3 : int = prim::Constant[value=1]()
         %4 : int = prim::Constant[value=0]()
         %5 : int = prim::Constant[value=1]()
@@ -81,7 +81,7 @@ TEST(Converters, ATenConvolutionConvertsCorrectly) {
 TEST(Converters, ATenConvolutionNoBiasConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(4, 1, 3, 3)):
+            %1 : Float(4:9, 1:9, 3:3, 3:1)):
         %2 : None = prim::Constant()
         %3 : int = prim::Constant[value=1]()
         %4 : int = prim::Constant[value=0]()
@@ -120,8 +120,8 @@ TEST(Converters, ATenConvolutionNoBiasConvertsCorrectly) {
 TEST(Converters, ATenConvolutionWithStrideConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(4, 3, 3, 3),
-            %2 : Float(4)):
+            %1 : Float(4:27, 3:9, 3:3, 3:1),
+            %2 : Float(4:1)):
         %3 : int = prim::Constant[value=3]()
         %4 : int = prim::Constant[value=0]()
         %5 : int = prim::Constant[value=1]()
@@ -163,8 +163,8 @@ TEST(Converters, ATenConvolutionWithStrideConvertsCorrectly) {
 TEST(Converters, ATenConvolutionWithPaddingConvertsCorrectly) {
    const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(4, 3, 4, 4),
-            %2 : Float(4)):
+            %1 : Float(4:48, 3:16, 4:4, 4:1),
+            %2 : Float(4:1)):
         %3 : int = prim::Constant[value=1]()
         %4 : int = prim::Constant[value=2]()
         %5 : int = prim::Constant[value=1]()
@@ -206,8 +206,8 @@ TEST(Converters, ATenConvolutionWithPaddingConvertsCorrectly) {
 TEST(Converters, ATenConvTransposeConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(8, 3, 3, 3),
-            %2 : Float(8)):
+            %1 : Float(8:27, 3:9, 3:3, 3:1),
+            %2 : Float(8:1)):
         %3 : int = prim::Constant[value=1]()
         %4 : int = prim::Constant[value=0]()
         %5 : int = prim::Constant[value=1]()
@@ -248,7 +248,7 @@ TEST(Converters, ATenConvTransposeConvertsCorrectly) {
 TEST(Converters, ATenConvTransposeNoBiasConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(4, 1, 3, 3)):
+            %1 : Float(4:9, 1:9, 3:3, 3:1)):
         %2 : None = prim::Constant()
         %3 : int = prim::Constant[value=1]()
         %4 : int = prim::Constant[value=0]()
@@ -287,8 +287,8 @@ TEST(Converters, ATenConvTransposeNoBiasConvertsCorrectly) {
 TEST(Converters, ATenConvTransposeWithStrideConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(4, 3, 3, 3),
-            %2 : Float(4)):
+            %1 : Float(4:27, 3:9, 3:3, 3:1),
+            %2 : Float(4:1)):
         %3 : int = prim::Constant[value=3]()
         %4 : int = prim::Constant[value=0]()
         %5 : int = prim::Constant[value=1]()
@@ -330,8 +330,8 @@ TEST(Converters, ATenConvTransposeWithStrideConvertsCorrectly) {
 TEST(Converters, ATenConvTransposeWithPaddingConvertsCorrectly) {
    const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(4, 3, 4, 4),
-            %2 : Float(4)):
+            %1 : Float(4:48, 3:16, 4:4, 4:1),
+            %2 : Float(4:1)):
         %3 : int = prim::Constant[value=1]()
         %4 : int = prim::Constant[value=2]()
         %5 : int = prim::Constant[value=1]()
diff --git a/tests/core/converters/test_linear.cpp b/tests/core/converters/test_linear.cpp
--- a/tests/core/converters/test_linear.cpp
+++ b/tests/core/converters/test_linear.cpp
@@ -7,7 +7,7 @@
 TEST(Converters, ATenLinearNoBiasConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(3, 2)):
+            %1 : Float(3:2, 2:1)):
         %2 : None = prim::Constant()
         %3 : Tensor = aten::linear(%0, %1, %2)
         return (%3))IR";
@@ -34,8 +34,8 @@ TEST(Converters, ATenLinearNoBiasConvertsCorrectly) {
 TEST(Converters, ATenLinearBiasConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(2, 3),
-            %2 : Float(2)):
+            %1 : Float(2:3, 3:1),
+            %2 : Float(2:1)):
         %3 : Tensor = aten::linear(%0, %1, %2)
         return (%3))IR";
 
diff --git a/tests/core/converters/test_shuffle.cpp b/tests/core/converters/test_shuffle.cpp
--- a/tests/core/converters/test_shuffle.cpp
+++ b/tests/core/converters/test_shuffle.cpp
@@ -108,18 +108,21 @@ TEST(Converters, ATenPermuteConvertsCorrectly) {
       return (%3))IR";
 
   auto g = std::make_shared<torch::jit::Graph>();
-    torch::jit::parseIR(graph, &*g);
+  torch::jit::parseIR(graph, &*g);
 
-    auto in = at::randint(0, 5, {2, 3, 2, 3}, {at::kCUDA});
-    auto params = trtorch::core::conversion::get_named_params(g->inputs(), {});
-    auto jit_results = trtorch::tests::util::RunGraph(g, params, {in});
+  auto in = at::randint(0, 5, {2, 3, 2, 3}, {at::kCUDA});
+  auto params = trtorch::core::conversion::get_named_params(g->inputs(), {});
 
-    in = at::clone(in);
-    params = trtorch::core::conversion::get_named_params(g->inputs(), {});
-    auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in});
-    auto trt = trt_results[0].reshape_as(jit_results[0]);
+  std::cout << "Running JIT" << std::endl;
+  auto jit_results = trtorch::tests::util::RunGraph(g, params, {in});
 
-    ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt, 2e-6));
+  std::cout << "Running TRT" << std::endl;
+  in = at::clone(in);
+  params = trtorch::core::conversion::get_named_params(g->inputs(), {});
+  auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in});
+  auto trt = trt_results[0].reshape_as(jit_results[0]);
+
+  ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt, 2e-6));
 }
 
 TEST(Converters, ATenPermute3DConvertsCorrectly) {
diff --git a/tests/core/converters/test_stack.cpp b/tests/core/converters/test_stack.cpp
--- a/tests/core/converters/test_stack.cpp
+++ b/tests/core/converters/test_stack.cpp
@@ -31,7 +31,7 @@ TEST(Converters, ATenStackPureTensorConvertsCorrectly) {
 TEST(Converters, ATenStackDiffTensorConvertsCorrectly) {
     const auto graph = R"IR(
       graph(%0 : Tensor,
-            %1 : Float(4, 4, 4)):
+            %1 : Float(4:16, 4:4, 4:1)):
         %2 : Tensor[] = prim::ListConstruct(%0, %1)
         %3 : int = prim::Constant[value=1]()
         %4 : Tensor = aten::stack(%2, %3)
diff --git a/tests/py/requirements.txt b/tests/py/requirements.txt
--- a/tests/py/requirements.txt
+++ b/tests/py/requirements.txt
@@ -1 +1 @@
-torchvision==0.6.0
\ No newline at end of file
+torchvision==0.7.0
\ No newline at end of file
diff --git a/tests/util/run_graph.cpp b/tests/util/run_graph.cpp
--- a/tests/util/run_graph.cpp
+++ b/tests/util/run_graph.cpp
@@ -5,7 +5,7 @@ namespace trtorch {
 namespace tests {
 namespace util {
 
-torch::jit::Stack CreateStack(std::vector<at::Tensor>&& list) {
+torch::jit::Stack CreateStack(std::vector<torch::jit::IValue>&& list) {
     return torch::jit::Stack(
         std::make_move_iterator(list.begin()),
         std::make_move_iterator(list.end()));
@@ -16,15 +16,15 @@ std::vector<at::Tensor> RunGraph(std::shared_ptr<torch::jit::Graph>& g,
                                  core::conversion::GraphParams& params,
                                  std::vector<at::Tensor> inputs) {
     LOG_DEBUG("Running JIT version");
-    std::vector<at::Tensor> inputs_;
+    std::vector<torch::jit::IValue> inputs_;
     for (auto in : inputs) {
-        inputs_.push_back(in.clone());
+        inputs_.push_back(torch::jit::IValue(in.clone()));
     }
 
     for (auto* in : g->inputs()) {
         const auto iter = params.find(in);
         if (iter != params.end()) {
-            inputs_.push_back(iter->second.clone());
+            inputs_.push_back(iter->second);
         }
     }