Building cpp example with libtorch fails with both LibTorch built from source and from the website

username: flint-stone
cooked: <p>Hello! I’m trying to build pytorch cpp MNIST example from <a href="https://github.com/pytorch/examples/tree/master/cpp/mnist" rel="nofollow noopener">here</a>. However, I can’t seem to build the example through README. I tried both building libtorch from source and a libtorch downloaded from the website.</p>
<p>When I build libtorch from source, I follow the example from this <a href="https://github.com/pytorch/pytorch/blob/master/docs/libtorch.rst" rel="nofollow noopener">README</a>. Basically, I did:</p>
<pre><code class="lang-auto">cd pytorch
mkdir build_libtorch &amp;&amp; cd build_libtorch
python ../tools/build_libtorch.py
</code></pre>
<p>In the example I built it with</p>
<pre><code class="lang-auto">cd mnist
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/home/pytorch/build_libtorch/build/ ..
make
</code></pre>
<p>I got a cmake error:</p>
<pre><code class="lang-auto">-- The C compiler identification is GNU 8.4.0
-- The CXX compiler identification is GNU 8.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /home/pytorch/build_libtorch/build/Caffe2Config.cmake:14 (include):
  include could not find load file:

    /home/pytorch/build_libtorch/build/public/utils.cmake
Call Stack (most recent call first):
  /home/pytorch/build_libtorch/build/TorchConfig.cmake:40 (find_package)
  CMakeLists.txt:4 (find_package)


CMake Error at /home/pytorch/build_libtorch/build/Caffe2Config.cmake:17 (include):
  include could not find load file:

    /home/pytorch/build_libtorch/build/public/threads.cmake
Call Stack (most recent call first):
  /home/pytorch/build_libtorch/build/TorchConfig.cmake:40 (find_package)
  CMakeLists.txt:4 (find_package)


CMake Error at /home/pytorch/build_libtorch/build/Caffe2Config.cmake:22 (include):
  include could not find load file:

    /home/pytorch/build_libtorch/build/public/gflags.cmake
Call Stack (most recent call first):
  /home/pytorch/build_libtorch/build/TorchConfig.cmake:40 (find_package)
  CMakeLists.txt:4 (find_package)


CMake Error at /home/pytorch/build_libtorch/build/Caffe2Config.cmake:24 (message):
  Your installed Caffe2 version uses gflags but the gflags library cannot be
  found.  Did you accidentally remove it, or have you set the right
  CMAKE_PREFIX_PATH and/or GFLAGS_ROOT_DIR? If you do not have gflags, you
  will need to install gflags and set the library path accordingly.
Call Stack (most recent call first):
  /home/pytorch/build_libtorch/build/TorchConfig.cmake:40 (find_package)
  CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/pytorch-examples/cpp/mnist/build/CMakeFiles/CMakeOutput.log".
</code></pre>
<p>Meanwhile, I also tried to build the example with libtorch downloaded from the website (nightly build).<br>
cmake was through successfully but I got the following message</p>
<pre><code class="lang-auto">Unzipped /mydata/lexu/pytorch-examples/cpp/mnist/build/data/t10k-labels-idx1-ubyte.gz ...
-- Configuring done
CMake Warning at CMakeLists.txt:18 (add_executable):
  Cannot generate a safe runtime search path for target mnist because there
  is a cycle in the constraint graph:

    dir 0 is [/mydata/lexu/libtorch/lib]
    dir 1 is [/usr/local/cuda/lib64/stubs]
    dir 2 is [/usr/local/cuda/lib64]
      dir 3 must precede it due to runtime library [libnvToolsExt.so.1]
    dir 3 is [/mydata/lexu/anaconda3/lib]
      dir 2 must precede it due to runtime library [libnvToolsExt.so.1]

  Some of these libraries may not be found correctly.


-- Generating done
-- Build files have been written to: /mydata/lexu/pytorch-examples/cpp/mnist/build
</code></pre>
<p>However, building with the nighly built cause the following error:</p>
<pre><code class="lang-auto">/home/libtorch/include/torch/csrc/api/include/torch/data/iterator.h:68:25: error: binding reference of type ‘torch::data::Example&lt;&gt;&amp;’ to ‘const torch::data::Example&lt;&gt;’ discards qualifiers
     return batch_.value();
                         ^
In file included from /home/libtorch/include/c10/core/ScalarType.h:6,
                 from /home/libtorch/include/c10/core/Scalar.h:9,
                 from /home/libtorch/include/ATen/core/TensorBody.h:7,
                 from /home/libtorch/include/ATen/Tensor.h:11,
                 from /home/libtorch/include/ATen/Context.h:4,
                 from /home/libtorch/include/ATen/ATen.h:5,
                 from /home/libtorch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/c10/util/Optional.h: In instantiation of ‘c10::optional&lt;T&gt;&amp; c10::optional&lt;T&gt;::operator=(c10::optional&lt;T&gt;&amp;&amp;) [with T = torch::data::DataLoaderBase&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MNIST, torch::data::transforms::Normalize&lt;&gt; &gt;, torch::data::transforms::Stack&lt;torch::data::Example&lt;&gt; &gt; &gt;, torch::data::Example&lt;&gt;, std::vector&lt;long unsigned int, std::allocator&lt;long unsigned int&gt; &gt; &gt;::Result]’:
/home/libtorch/include/torch/csrc/api/include/torch/data/detail/sequencers.h:93:39:   required from ‘c10::optional&lt;T&gt; torch::data::detail::sequencers::OrderedSequencer&lt;Result&gt;::next(typename torch::data::detail::sequencers::Sequencer&lt;Result&gt;::ResultProducer) [with Result = torch::data::DataLoaderBase&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MNIST, torch::data::transforms::Normalize&lt;&gt; &gt;, torch::data::transforms::Stack&lt;torch::data::Example&lt;&gt; &gt; &gt;, torch::data::Example&lt;&gt;, std::vector&lt;long unsigned int, std::allocator&lt;long unsigned int&gt; &gt; &gt;::Result; typename torch::data::detail::sequencers::Sequencer&lt;Result&gt;::ResultProducer = std::function&lt;c10::optional&lt;torch::data::DataLoaderBase&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MNIST, torch::data::transforms::Normalize&lt;&gt; &gt;, torch::data::transforms::Stack&lt;torch::data::Example&lt;&gt; &gt; &gt;, torch::data::Example&lt;&gt;, std::vector&lt;long unsigned int, std::allocator&lt;long unsigned int&gt; &gt; &gt;::Result&gt;()&gt;]’
/home/libtorch/include/torch/csrc/api/include/torch/data/detail/sequencers.h:71:20:   required from here
/home/libtorch/include/c10/util/Optional.h:396:23: error: passing ‘const torch::data::DataLoaderBase&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MNIST, torch::data::transforms::Normalize&lt;&gt; &gt;, torch::data::transforms::Stack&lt;torch::data::Example&lt;&gt; &gt; &gt;, torch::data::Example&lt;&gt;, std::vector&lt;long unsigned int, std::allocator&lt;long unsigned int&gt; &gt; &gt;::Result’ as ‘this’ argument discards qualifiers [-fpermissive]
       contained_val() = std::move(*rhs);
In file included from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:121:10: note:   in call to ‘torch::data::DataLoaderBase&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MNIST, torch::data::transforms::Normalize&lt;&gt; &gt;, torch::data::transforms::Stack&lt;torch::data::Example&lt;&gt; &gt; &gt;, torch::data::Example&lt;&gt;, std::vector&lt;long unsigned int, std::allocator&lt;long unsigned int&gt; &gt; &gt;::Result&amp; torch::data::DataLoaderBase&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MNIST, torch::data::transforms::Normalize&lt;&gt; &gt;, torch::data::transforms::Stack&lt;torch::data::Example&lt;&gt; &gt; &gt;, torch::data::Example&lt;&gt;, std::vector&lt;long unsigned int, std::allocator&lt;long unsigned int&gt; &gt; &gt;::Result::operator=(const torch::data::DataLoaderBase&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MapDataset&lt;torch::data::datasets::MNIST, torch::data::transforms::Normalize&lt;&gt; &gt;, torch::data::transforms::Stack&lt;torch::data::Example&lt;&gt; &gt; &gt;, torch::data::Example&lt;&gt;, std::vector&lt;long unsigned int, std::allocator&lt;long unsigned int&gt; &gt; &gt;::Result&amp;)’
   struct Result : Sequenced {
          ^~~~~~
In file included from /home/libtorch/include/c10/core/ScalarType.h:6,
                 from /home/libtorch/include/c10/core/Scalar.h:9,
                 from /home/libtorch/include/ATen/core/TensorBody.h:7,
                 from /home/libtorch/include/ATen/Tensor.h:11,
                 from /home/libtorch/include/ATen/Context.h:4,
                 from /home/libtorch/include/ATen/ATen.h:5,
                 from /home/libtorch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/c10/util/Optional.h: In instantiation of ‘c10::optional&lt;T&gt;&amp; c10::optional&lt;T&gt;::operator=(c10::optional&lt;T&gt;&amp;&amp;) [with T = torch::data::Example&lt;&gt;]’:
/home/libtorch/include/torch/csrc/api/include/torch/data/iterator.h:56:12:   required from ‘void torch::data::detail::ValidIterator&lt;Batch&gt;::next() [with Batch = torch::data::Example&lt;&gt;]’
/home/libtorch/include/torch/csrc/api/include/torch/data/iterator.h:50:8:   required from here
/home/libtorch/include/c10/util/Optional.h:396:23: error: passing ‘const torch::data::Example&lt;&gt;’ as ‘this’ argument discards qualifiers [-fpermissive]
       contained_val() = std::move(*rhs);
In file included from /home/libtorch/include/torch/csrc/api/include/torch/data/datasets/base.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/datasets.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/torch/csrc/api/include/torch/data/example.h:12:8: note:   in call to ‘torch::data::Example&lt;&gt;&amp; torch::data::Example&lt;&gt;::operator=(const torch::data::Example&lt;&gt;&amp;)’
 struct Example {
        ^~~~~~~
In file included from /home/libtorch/include/c10/core/ScalarType.h:6,
                 from /home/libtorch/include/c10/core/Scalar.h:9,
                 from /home/libtorch/include/ATen/core/TensorBody.h:7,
                 from /home/libtorch/include/ATen/Tensor.h:11,
                 from /home/libtorch/include/ATen/Context.h:4,
                 from /home/libtorch/include/ATen/ATen.h:5,
                 from /home/libtorch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/c10/util/Optional.h: In instantiation of ‘c10::optional&lt;T&gt;&amp; c10::optional&lt;T&gt;::operator=(c10::optional&lt;T&gt;&amp;&amp;) [with T = torch::ExpandingArray&lt;3&gt;]’:
/home/libtorch/include/torch/csrc/api/include/torch/nn/options/pooling.h:428:8:   required from ‘void torch::nn::Cloneable&lt;Derived&gt;::clone_(torch::nn::Module&amp;, const c10::optional&lt;c10::Device&gt;&amp;) [with Derived = torch::nn::FractionalMaxPool3dImpl]’
/home/libtorch/include/torch/csrc/api/include/torch/nn/cloneable.h:81:8:   required from here
/home/libtorch/include/c10/util/Optional.h:396:23: error: passing ‘const torch::ExpandingArray&lt;3&gt;’ as ‘this’ argument discards qualifiers [-fpermissive]
       contained_val() = std::move(*rhs);
In file included from /home/libtorch/include/torch/csrc/api/include/torch/nn/options/conv.h:6,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn/functional/conv.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn/functional.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:7,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/torch/csrc/api/include/torch/expanding_array.h:23:7: note:   in call to ‘torch::ExpandingArray&lt;3&gt;&amp; torch::ExpandingArray&lt;3&gt;::operator=(const torch::ExpandingArray&lt;3&gt;&amp;)’
 class ExpandingArray {
       ^~~~~~~~~~~~~~
In file included from /home/libtorch/include/c10/core/ScalarType.h:6,
                 from /home/libtorch/include/c10/core/Scalar.h:9,
                 from /home/libtorch/include/ATen/core/TensorBody.h:7,
                 from /home/libtorch/include/ATen/Tensor.h:11,
                 from /home/libtorch/include/ATen/Context.h:4,
                 from /home/libtorch/include/ATen/ATen.h:5,
                 from /home/libtorch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/c10/util/Optional.h: In instantiation of ‘c10::optional&lt;T&gt;&amp; c10::optional&lt;T&gt;::operator=(c10::optional&lt;T&gt;&amp;&amp;) [with T = torch::ExpandingArray&lt;3, double&gt;]’:
/home/libtorch/include/torch/csrc/api/include/torch/nn/options/pooling.h:428:8:   required from ‘void torch::nn::Cloneable&lt;Derived&gt;::clone_(torch::nn::Module&amp;, const c10::optional&lt;c10::Device&gt;&amp;) [with Derived = torch::nn::FractionalMaxPool3dImpl]’
/home/libtorch/include/torch/csrc/api/include/torch/nn/cloneable.h:81:8:   required from here
/home/libtorch/include/c10/util/Optional.h:396:23: error: passing ‘const torch::ExpandingArray&lt;3, double&gt;’ as ‘this’ argument discards qualifiers [-fpermissive]
       contained_val() = std::move(*rhs);
In file included from /home/libtorch/include/torch/csrc/api/include/torch/nn/options/conv.h:6,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn/functional/conv.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn/functional.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:7,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/torch/csrc/api/include/torch/expanding_array.h:23:7: note:   in call to ‘torch::ExpandingArray&lt;3, double&gt;&amp; torch::ExpandingArray&lt;3, double&gt;::operator=(const torch::ExpandingArray&lt;3, double&gt;&amp;)’
 class ExpandingArray {
       ^~~~~~~~~~~~~~
In file included from /home/libtorch/include/c10/core/ScalarType.h:6,
                 from /home/libtorch/include/c10/core/Scalar.h:9,
                 from /home/libtorch/include/ATen/core/TensorBody.h:7,
                 from /home/libtorch/include/ATen/Tensor.h:11,
                 from /home/libtorch/include/ATen/Context.h:4,
                 from /home/libtorch/include/ATen/ATen.h:5,
                 from /home/libtorch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/c10/util/Optional.h: In instantiation of ‘c10::optional&lt;T&gt;&amp; c10::optional&lt;T&gt;::operator=(c10::optional&lt;T&gt;&amp;&amp;) [with T = torch::ExpandingArray&lt;2&gt;]’:
/home/libtorch/include/torch/csrc/api/include/torch/nn/options/pooling.h:428:8:   required from ‘void torch::nn::Cloneable&lt;Derived&gt;::clone_(torch::nn::Module&amp;, const c10::optional&lt;c10::Device&gt;&amp;) [with Derived = torch::nn::FractionalMaxPool2dImpl]’
/home/libtorch/include/torch/csrc/api/include/torch/nn/cloneable.h:81:8:   required from here
/home/libtorch/include/c10/util/Optional.h:396:23: error: passing ‘const torch::ExpandingArray&lt;2&gt;’ as ‘this’ argument discards qualifiers [-fpermissive]
       contained_val() = std::move(*rhs);
In file included from /home/libtorch/include/torch/csrc/api/include/torch/nn/options/conv.h:6,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn/functional/conv.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn/functional.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:7,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/torch/csrc/api/include/torch/expanding_array.h:23:7: note:   in call to ‘torch::ExpandingArray&lt;2&gt;&amp; torch::ExpandingArray&lt;2&gt;::operator=(const torch::ExpandingArray&lt;2&gt;&amp;)’
 class ExpandingArray {
       ^~~~~~~~~~~~~~
In file included from /home/libtorch/include/c10/core/ScalarType.h:6,
                 from /home/libtorch/include/c10/core/Scalar.h:9,
                 from /home/libtorch/include/ATen/core/TensorBody.h:7,
                 from /home/libtorch/include/ATen/Tensor.h:11,
                 from /home/libtorch/include/ATen/Context.h:4,
                 from /home/libtorch/include/ATen/ATen.h:5,
                 from /home/libtorch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/c10/util/Optional.h: In instantiation of ‘c10::optional&lt;T&gt;&amp; c10::optional&lt;T&gt;::operator=(c10::optional&lt;T&gt;&amp;&amp;) [with T = torch::ExpandingArray&lt;2, double&gt;]’:
/home/libtorch/include/torch/csrc/api/include/torch/nn/options/pooling.h:428:8:   required from ‘void torch::nn::Cloneable&lt;Derived&gt;::clone_(torch::nn::Module&amp;, const c10::optional&lt;c10::Device&gt;&amp;) [with Derived = torch::nn::FractionalMaxPool2dImpl]’
/home/libtorch/include/torch/csrc/api/include/torch/nn/cloneable.h:81:8:   required from here
/home/libtorch/include/c10/util/Optional.h:396:23: error: passing ‘const torch::ExpandingArray&lt;2, double&gt;’ as ‘this’ argument discards qualifiers [-fpermissive]
       contained_val() = std::move(*rhs);
In file included from /home/libtorch/include/torch/csrc/api/include/torch/nn/options/conv.h:6,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn/functional/conv.h:3,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn/functional.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/nn.h:4,
                 from /home/libtorch/include/torch/csrc/api/include/torch/all.h:7,
                 from /home/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/pytorch-examples/cpp/mnist/mnist.cpp:1:
/home/libtorch/include/torch/csrc/api/include/torch/expanding_array.h:23:7: note:   in call to ‘torch::ExpandingArray&lt;2, double&gt;&amp; torch::ExpandingArray&lt;2, double&gt;::operator=(const torch::ExpandingArray&lt;2, double&gt;&amp;)’
 class ExpandingArray {
       ^~~~~~~~~~~~~~
CMakeFiles/mnist.dir/build.make:62: recipe for target 'CMakeFiles/mnist.dir/mnist.cpp.o' failed
make[2]: *** [CMakeFiles/mnist.dir/mnist.cpp.o] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/mnist.dir/all' failed
make[1]: *** [CMakeFiles/mnist.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
</code></pre>
<p>Any hints on what’s going on?</p>
<p>Thanks!</p>

username: flint-stone
cooked: <p>Got the libtorch built from source worked – now it produces the exact same make error as the official libtorch.</p>

username: Majid_Geravand
cooked: <p><a class="mention" href="/u/flint-stone">@flint-stone</a> I have the same issue but not with provided example with this example <a href="https://github.com/dendisuhubdy/libtorch_examples" rel="nofollow noopener">dendisuhubdy_libtorch_examples</a> and complex network. Could you solve the problem?</p>
<p>log file:</p>
<p>– The C compiler identification is GNU 7.5.0<br>
– The CXX compiler identification is GNU 7.5.0<br>
– Check for working C compiler: /usr/bin/cc<br>
– Check for working C compiler: /usr/bin/cc – works<br>
– Detecting C compiler ABI info<br>
– Detecting C compiler ABI info - done<br>
– Detecting C compile features<br>
– Detecting C compile features - done<br>
– Check for working CXX compiler: /usr/bin/c++<br>
– Check for working CXX compiler: /usr/bin/c++ – works<br>
– Detecting CXX compiler ABI info<br>
– Detecting CXX compiler ABI info - done<br>
– Detecting CXX compile features<br>
– Detecting CXX compile features - done<br>
– Looking for pthread.h<br>
– Looking for pthread.h - found<br>
– Looking for pthread_create<br>
– Looking for pthread_create - not found<br>
– Looking for pthread_create in pthreads<br>
– Looking for pthread_create in pthreads - not found<br>
– Looking for pthread_create in pthread<br>
– Looking for pthread_create in pthread - found<br>
– Found Threads: TRUE<br>
– Found CUDA: /usr/local/cuda-10.2 (found version “10.2”)<br>
– Caffe2: CUDA detected: 10.2<br>
– Caffe2: CUDA nvcc is: /usr/local/cuda-10.2/bin/nvcc<br>
– Caffe2: CUDA toolkit directory: /usr/local/cuda-10.2<br>
– Caffe2: Header version is: 10.2<br>
– Found CUDNN: /usr/lib/x86_64-linux-gnu/libcudnn.so<br>
– Found cuDNN: v7.6.5  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libcudnn.so)<br>
– Autodetected CUDA architecture(s):  5.2<br>
– Added CUDA NVCC flags for: -gencode;arch=compute_52,code=sm_52<br>
– Found Torch: /home/ubuntu/libtorch/libtorch/lib/libtorch.so<br>
– Found OpenCV: /usr/local (found version “3.4.9”)<br>
– OpenCV library status:<br>
–     config: /usr/local/share/OpenCV<br>
–     version: 3.4.9<br>
–     libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab<br>
–     include path: /usr/local/include;/usr/local/include/opencv<br>
– Downloading MNIST dataset<br>
/home/ubuntu/libtorch_examples/build/…/data/mnist/train-images-idx3-ubyte.gz already exists, skipping …<br>
/home/ubuntu/libtorch_examples/build/…/data/mnist/train-images-idx3-ubyte already exists, skipping …<br>
/home/ubuntu/libtorch_examples/build/…/data/mnist/train-labels-idx1-ubyte.gz already exists, skipping …<br>
/home/ubuntu/libtorch_examples/build/…/data/mnist/train-labels-idx1-ubyte already exists, skipping …<br>
/home/ubuntu/libtorch_examples/build/…/data/mnist/t10k-images-idx3-ubyte.gz already exists, skipping …<br>
/home/ubuntu/libtorch_examples/build/…/data/mnist/t10k-images-idx3-ubyte already exists, skipping …<br>
/home/ubuntu/libtorch_examples/build/…/data/mnist/t10k-labels-idx1-ubyte.gz already exists, skipping …<br>
/home/ubuntu/libtorch_examples/build/…/data/mnist/t10k-labels-idx1-ubyte already exists, skipping …<br>
– Configuring done<br>
– Generating done<br>
– Build files have been written to: /home/ubuntu/libtorch_examples/build<br>
Scanning dependencies of target mnist<br>
[ 14%] Building CXX object src/CMakeFiles/mnist.dir/mnist.cpp.o<br>
Scanning dependencies of target dcgan<br>
[ 28%] Building CXX object src/CMakeFiles/dcgan.dir/dcgan.cpp.o<br>
Scanning dependencies of target yolov3<br>
[ 42%] Building CXX object src/CMakeFiles/yolov3.dir/darknet.cpp.o<br>
[ 57%] Building CXX object src/CMakeFiles/yolov3.dir/yolov3.cpp.o<br>
In file included from /home/ubuntu/libtorch_examples/src/mnist.cpp:8:0:<br>
/home/ubuntu/libtorch_examples/include/mnist.h:55:13: error: ‘FeatureDropout’ in namespace ‘torch::nn’ does not name a type<br>
torch::nn::FeatureDropout conv2_drop;<br>
^~~~~~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/include/mnist.h: In constructor ‘Net::Net()’:<br>
/home/ubuntu/libtorch_examples/include/mnist.h:37:33: error: ‘conv2_drop’ was not declared in this scope<br>
register_module(“conv2_drop”, conv2_drop);<br>
^~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/include/mnist.h:37:33: note: suggested alternative: ‘conv2’<br>
register_module(“conv2_drop”, conv2_drop);<br>
^~~~~~~~~~<br>
conv2<br>
/home/ubuntu/libtorch_examples/include/mnist.h: In member function ‘at::Tensor Net::forward(at::Tensor)’:<br>
/home/ubuntu/libtorch_examples/include/mnist.h:45:22: error: ‘conv2_drop’ was not declared in this scope<br>
torch::max_pool2d(conv2_drop-&gt;forward(conv2-&gt;forward(x)), 2));<br>
^~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/include/mnist.h:45:22: note: suggested alternative: ‘conv2’<br>
torch::max_pool2d(conv2_drop-&gt;forward(conv2-&gt;forward(x)), 2));<br>
^~~~~~~~~~<br>
conv2<br>
/home/ubuntu/libtorch_examples/src/mnist.cpp: In function ‘void test(Net&amp;, c10::Device, DataLoader&amp;, size_t)’:<br>
/home/ubuntu/libtorch_examples/src/mnist.cpp:55:4: error: ‘Reduction’ has not been declared<br>
Reduction::Sum)<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/mnist.cpp: In function ‘int main(int, const char**)’:<br>
/home/ubuntu/libtorch_examples/src/mnist.cpp:106:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]<br>
for (size_t epoch = 1; epoch &lt;= options.epochs; ++epoch) {<br>



^


~~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp: In function ‘int main(int, const char**)’:<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:47:23: error: ‘using Conv2dOptions = struct torch::nn::ConvOptions&lt;2&gt; {aka struct torch::nn::ConvOptions&lt;2&gt;}’ has no member named ‘with_bias’<br>
.with_bias(false)<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:49:11: error: ‘BatchNorm’ is not a member of ‘torch::nn’<br>
nn::BatchNorm(256),<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:49:11: note: suggested alternative: ‘BatchNorm3d’<br>
nn::BatchNorm(256),<br>
^~~~~~~~~<br>
BatchNorm3d<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:55:23: error: ‘struct torch::nn::ConvOptions&lt;2&gt;’ has no member named ‘with_bias’<br>
.with_bias(false)<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:57:11: error: ‘BatchNorm’ is not a member of ‘torch::nn’<br>
nn::BatchNorm(128),<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:57:11: note: suggested alternative: ‘BatchNorm3d’<br>
nn::BatchNorm(128),<br>
^~~~~~~~~<br>
BatchNorm3d<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:63:23: error: ‘struct torch::nn::ConvOptions&lt;2&gt;’ has no member named ‘with_bias’<br>
.with_bias(false)<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:65:11: error: ‘BatchNorm’ is not a member of ‘torch::nn’<br>
nn::BatchNorm(64),<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:65:11: note: suggested alternative: ‘BatchNorm3d’<br>
nn::BatchNorm(64),<br>
^~~~~~~~~<br>
BatchNorm3d<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:71:23: error: ‘struct torch::nn::ConvOptions&lt;2&gt;’ has no member named ‘with_bias’<br>
.with_bias(false)<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:79:60: error: ‘struct torch::nn::ConvOptions&lt;2&gt;’ has no member named ‘with_bias’<br>
nn::Conv2dOptions(1, 64, 4).stride(2).padding(1).with_bias(false)),<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:83:62: error: ‘struct torch::nn::ConvOptions&lt;2&gt;’ has no member named ‘with_bias’<br>
nn::Conv2dOptions(64, 128, 4).stride(2).padding(1).with_bias(false)),<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:84:11: error: ‘BatchNorm’ is not a member of ‘torch::nn’<br>
nn::BatchNorm(128),<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:84:11: note: suggested alternative: ‘BatchNorm3d’<br>
nn::BatchNorm(128),<br>
^~~~~~~~~<br>
BatchNorm3d<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:88:63: error: ‘struct torch::nn::ConvOptions&lt;2&gt;’ has no member named ‘with_bias’<br>
nn::Conv2dOptions(128, 256, 4).stride(2).padding(1).with_bias(false)),<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:89:11: error: ‘BatchNorm’ is not a member of ‘torch::nn’<br>
nn::BatchNorm(256),<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:89:11: note: suggested alternative: ‘BatchNorm3d’<br>
nn::BatchNorm(256),<br>
^~~~~~~~~<br>
BatchNorm3d<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:93:61: error: ‘struct torch::nn::ConvOptions&lt;2&gt;’ has no member named ‘with_bias’<br>
nn::Conv2dOptions(256, 1, 3).stride(1).padding(0).with_bias(false)),<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:109:64: error: ‘struct torch::optim::AdamOptions’ has no member named ‘beta1’; did you mean ‘betas’?<br>
generator-&gt;parameters(), torch::optim::AdamOptions(2e-4).beta1(0.5));<br>
^~~~~<br>
betas<br>
/home/ubuntu/libtorch_examples/src/dcgan.cpp:111:68: error: ‘struct torch::optim::AdamOptions’ has no member named ‘beta1’; did you mean ‘betas’?<br>
discriminator-&gt;parameters(), torch::optim::AdamOptions(2e-4).beta1(0.5));<br>
^~~~~<br>
betas<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp: In function ‘int split(const string&amp;, std::vector&lt;int, std::allocator &gt;&amp;, std::__cxx11::string)’:<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:77:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]<br>
for(int i = 0; i &lt; tmp.size(); i++)<br>

^
~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:81:1: warning: no return statement in function returning non-void [-Wreturn-type]<br>
}<br>
^<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp: In function ‘torch::nn::Conv2dOptions conv_options(int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, bool)’:<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:138:18: error: ‘torch::ExpandingArray&lt;2&gt; torch::nn::ConvOptions&lt;2&gt;::stride_’ is private within this context<br>
conv_options.stride_ = stride;<br>
^~~~~~~<br>
In file included from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/functional/conv.h:3:0,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/functional.h:4,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn.h:4,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/all.h:7,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/torch.h:3,<br>
from /home/ubuntu/libtorch_examples/include/darknet.h:11,<br>
from /home/ubuntu/libtorch_examples/src/darknet.cpp:11:<br>
/home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/options/conv.h:122:42: note: declared private here<br>
TORCH_ARG(ExpandingArray, stride) = 1;<br>
^<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:139:18: error: ‘torch::ExpandingArray&lt;2&gt; torch::nn::ConvOptions&lt;2&gt;::padding_’ is private within this context<br>
conv_options.padding_ = padding;<br>
^~~~~~~~<br>
In file included from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/functional/conv.h:3:0,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/functional.h:4,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn.h:4,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/all.h:7,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/torch.h:3,<br>
from /home/ubuntu/libtorch_examples/include/darknet.h:11,<br>
from /home/ubuntu/libtorch_examples/src/darknet.cpp:11:<br>
/home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/options/conv.h:128:43: note: declared private here<br>
TORCH_ARG(ExpandingArray, padding) = 0;<br>
^<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:140:18: error: ‘int64_t torch::nn::ConvOptions&lt;2&gt;::groups_’ is private within this context<br>
conv_options.groups_ = groups;<br>
^~~~~~~<br>
In file included from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/functional/conv.h:3:0,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/functional.h:4,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn.h:4,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/all.h:7,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/torch.h:3,<br>
from /home/ubuntu/libtorch_examples/include/darknet.h:11,<br>
from /home/ubuntu/libtorch_examples/src/darknet.cpp:11:<br>
/home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/options/conv.h:138:32: note: declared private here<br>
TORCH_ARG(int64_t, groups) = 1;<br>
^<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:141:18: error: ‘using Conv2dOptions = struct torch::nn::ConvOptions&lt;2&gt; {aka struct torch::nn::ConvOptions&lt;2&gt;}’ has no member named ‘with_bias_’; did you mean ‘bias_’?<br>
conv_options.with_bias_ = with_bias;<br>
^~~~~~~~~~<br>
bias_<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp: In function ‘torch::nn::BatchNormOptions bn_options(int64_t)’:<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:147:16: error: ‘bool torch::nn::BatchNormOptions::affine_’ is private within this context<br>
bn_options.affine_ = true;<br>
^~~~~~~<br>
In file included from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/functional/batchnorm.h:3:0,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/functional.h:3,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn.h:4,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/all.h:7,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/torch.h:3,<br>
from /home/ubuntu/libtorch_examples/include/darknet.h:11,<br>
from /home/ubuntu/libtorch_examples/src/darknet.cpp:11:<br>
/home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/nn/options/batchnorm.h:29:29: note: declared private here<br>
TORCH_ARG(bool, affine) = true;<br>
^~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:148:16: error: ‘struct torch::nn::BatchNormOptions’ has no member named ‘stateful_’<br>
bn_options.stateful_ = true;<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp: In member function ‘at::Tensor UpsampleLayer::forward(at::Tensor)’:<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:172:21: warning: ‘using IntList = class c10::ArrayRef’ is deprecated [-Wdeprecated-declarations]<br>
torch::IntList sizes = x.sizes();<br>
^~~~~<br>
In file included from /home/ubuntu/libtorch/libtorch/include/c10/util/Exception.h:6:0,<br>
from /home/ubuntu/libtorch/libtorch/include/c10/core/Device.h:5,<br>
from /home/ubuntu/libtorch/libtorch/include/c10/core/Allocator.h:6,<br>
from /home/ubuntu/libtorch/libtorch/include/ATen/ATen.h:3,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/types.h:3,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/data/dataloader.h:3,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/data.h:3,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/all.h:4,<br>
from /home/ubuntu/libtorch/libtorch/include/torch/csrc/api/include/torch/torch.h:3,<br>
from /home/ubuntu/libtorch_examples/include/darknet.h:11,<br>
from /home/ubuntu/libtorch_examples/src/darknet.cpp:11:<br>
/home/ubuntu/libtorch/libtorch/include/c10/util/ArrayRef.h:278:1: note: declared here<br>
C10_DEFINE_DEPRECATED_USING(IntList, ArrayRef&lt;int64_t&gt;)<br>
^<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp: In member function ‘at::Tensor DetectionLayer::predict_transform(at::Tensor, int, std::vector&lt;float, std::allocator &gt;, int, c10::Device)’:<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:240:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]<br>
for (int i = 0; i &lt; anchors.size(); i++)<br>

^
~~~~~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp: In member function ‘void Darknet::create_modules()’:<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:382:16: error: ‘BatchNorm’ is not a member of ‘torch::nn’<br>
torch::nn::BatchNorm bn = torch::nn::BatchNorm(bn_options(filters));<br>
^~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:382:16: note: suggested alternative: ‘BatchNorm3d’<br>
torch::nn::BatchNorm bn = torch::nn::BatchNorm(bn_options(filters));<br>
^~~~~~~~~<br>
BatchNorm3d<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:383:35: error: ‘bn’ was not declared in this scope<br>
module-&gt;push_back(bn);<br>
^~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:383:35: note: suggested alternative: ‘yn’<br>
module-&gt;push_back(bn);<br>
^~<br>
yn<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:469:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]<br>
for (int i = 0; i&lt; masks.size(); i++)<br>
~^~~~~~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp: In member function ‘void Darknet::load_weights(const char*)’:<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:528:10: error: ‘struct c10::TensorOptions’ has no member named ‘is_variable’<br>
.is_variable(true);<br>
^~~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:533:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]<br>
for (int i = 0; i &lt; module_list.size(); i++)<br>

^
~~~~~~~~~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:554:15: error: ‘BatchNormImpl’ is not a member of ‘torch::nn’<br>
torch::nn::BatchNormImpl *bn_imp = dynamic_cast&lt;torch::nn::BatchNormImpl *&gt;(bn_module.get());<br>
^~~~~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:554:15: note: suggested alternative: ‘BatchNorm3dImpl’<br>
torch::nn::BatchNormImpl *bn_imp = dynamic_cast&lt;torch::nn::BatchNormImpl *&gt;(bn_module.get());<br>
^~~~~~~~~~~~~<br>
BatchNorm3dImpl<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:554:30: error: ‘bn_imp’ was not declared in this scope<br>
torch::nn::BatchNormImpl *bn_imp = dynamic_cast&lt;torch::nn::BatchNormImpl *&gt;(bn_module.get());<br>
^~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:554:30: note: suggested alternative: ‘to_impl’<br>
torch::nn::BatchNormImpl *bn_imp = dynamic_cast&lt;torch::nn::BatchNormImpl <em>&gt;(bn_module.get());<br>
^~~~~~<br>
to_impl<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:554:63: error: ‘BatchNormImpl’ in namespace ‘torch::nn’ does not name a type<br>
torch::nn::BatchNormImpl *bn_imp = dynamic_cast&lt;torch::nn::BatchNormImpl *&gt;(bn_module.get());<br>
^~~~~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:554:77: error: expected ‘&gt;’ before ‘</em>’ token<br>
torch::nn::BatchNormImpl *bn_imp = dynamic_cast&lt;torch::nn::BatchNormImpl <em>&gt;(bn_module.get());<br>
^<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:554:77: error: expected ‘(’ before ‘</em>’ token<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:554:78: error: expected primary-expression before ‘&gt;’ token<br>
torch::nn::BatchNormImpl *bn_imp = dynamic_cast&lt;torch::nn::BatchNormImpl *&gt;(bn_module.get());<br>
^<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:554:96: error: expected ‘)’ before ‘;’ token<br>
torch::nn::BatchNormImpl *bn_imp = dynamic_cast&lt;torch::nn::BatchNormImpl <em>&gt;(bn_module.get());<br>
^<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:526:23: warning: unused variable ‘options’ [-Wunused-variable]<br>
at::TensorOptions options= torch::TensorOptions()<br>
^~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp: In member function ‘at::Tensor Darknet::write_results(at::Tensor, int, float, float)’:<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:738:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]<br>
for (int n = 0; n &lt; img_classes.size(); n++)<br>

^
~~~~~~~~~~~~~~~~~<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:750:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]<br>
for (int k = 0; k &lt; img_classes.size(); k++)<br>

^
~~~~~~~~~~~~~~~~~<br>
src/CMakeFiles/mnist.dir/build.make:62: recipe for target ‘src/CMakeFiles/mnist.dir/mnist.cpp.o’ failed<br>
make[2]: *** [src/CMakeFiles/mnist.dir/mnist.cpp.o] Error 1<br>
CMakeFiles/Makefile2:126: recipe for target ‘src/CMakeFiles/mnist.dir/all’ failed<br>
make[1]: *** [src/CMakeFiles/mnist.dir/all] Error 2<br>
make[1]: *** Waiting for unfinished jobs…<br>
src/CMakeFiles/dcgan.dir/build.make:62: recipe for target ‘src/CMakeFiles/dcgan.dir/dcgan.cpp.o’ failed<br>
make[2]: *** [src/CMakeFiles/dcgan.dir/dcgan.cpp.o] Error 1<br>
CMakeFiles/Makefile2:163: recipe for target ‘src/CMakeFiles/dcgan.dir/all’ failed<br>
make[1]: *** [src/CMakeFiles/dcgan.dir/all] Error 2<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp: In member function ‘std::map&lt;std::__cxx11::basic_string, std::__cxx11::basic_string &gt;</em> Darknet::get_net_info()’:<br>
/home/ubuntu/libtorch_examples/src/darknet.cpp:504:1: warning: control reaches end of non-void function [-Wreturn-type]<br>
}<br>
^<br>
src/CMakeFiles/yolov3.dir/build.make:62: recipe for target ‘src/CMakeFiles/yolov3.dir/darknet.cpp.o’ failed<br>
make[2]: *** [src/CMakeFiles/yolov3.dir/darknet.cpp.o] Error 1<br>
make[2]: *** Waiting for unfinished jobs…<br>
CMakeFiles/Makefile2:89: recipe for target ‘src/CMakeFiles/yolov3.dir/all’ failed<br>
make[1]: *** [src/CMakeFiles/yolov3.dir/all] Error 2<br>
Makefile:83: recipe for target ‘all’ failed<br>
make: *** [all] Error 2</p>

username: glaringlee
cooked: <p><a class="mention" href="/u/majid_geravand">@Majid_Geravand</a><br>
These are samples 12 months old, it might not compatible with latest libtorch. You can try libtorch 1.4 or earlier, or ask the owner of the repo which libtorch version his code is compatible with.</p>

username: Majid_Geravand
cooked: <p><a class="mention" href="/u/glaringlee">@glaringlee</a> Thanks for your answer, Could you please let me know where can I download the libtorch 1.4 binary file? I could not find it in the website. Thanks</p>

username: glaringlee
cooked: <p><a class="mention" href="/u/majid_geravand">@Majid_Geravand</a><br>
I assume you are under linux env.<br>
for pre-c++11 ABI<br>
<a href="https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.4.0%2Bcpu.zip" class="onebox" target="_blank" rel="nofollow noopener">https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.4.0%2Bcpu.zip</a><br>
for c++11 ABI<br>
<a href="https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.4.0%2Bcpu.zip" class="onebox" target="_blank" rel="nofollow noopener">https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.4.0%2Bcpu.zip</a></p>