C10 error when converting cv::Mat to tensor with from_blob

elduderino15: <p>When I add <code>from_blob</code> to my code the project fails to compile. I want to create a tensor out of a <code>cv::Mat</code> but it keeps failing with the error below. Again, without <code>from_blob</code> my project compiles fine.</p>
<pre><code class="lang-auto">cv::Mat amplitudePatch = amplitude(roi);
torch::from_blob(amplitudePatch.data, 
{1, amplitudePatch.size().height, amplitudePatch.size().width, amplitudePatch.channels()},
at::TensorOptions(at::kFloat));
</code></pre>
<pre><code class="lang-auto">SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o): In function `c10::tensorTypeIdToBackend(c10::TensorTypeId)':
/usr/local/lib/python3.6/dist-packages/torch/include/c10/core/Backend.h:107: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o): In function `c10::backendToDeviceType(c10::Backend)':
/usr/local/lib/python3.6/dist-packages/torch/include/c10/core/Backend.h:169: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
/usr/local/lib/python3.6/dist-packages/torch/include/c10/core/Backend.h:171: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o): In function `c10::scalarTypeToTypeMeta(c10::ScalarType)':
/usr/local/lib/python3.6/dist-packages/torch/include/c10/core/ScalarType.h:125: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o): In function `c10::typeMetaToScalarType(caffe2::TypeMeta)':
/usr/local/lib/python3.6/dist-packages/torch/include/c10/core/ScalarType.h:151: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o):/usr/local/lib/python3.6/dist-packages/torch/include/c10/core/Device.h:93: more undefined references to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)' follow
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o): In function `at::Context::getDeviceFromPtr(void*, c10::DeviceType)':
/usr/local/lib/python3.6/dist-packages/torch/include/ATen/Context.h:47: undefined reference to `c10::DeviceTypeName[abi:cxx11](c10::DeviceType, bool)'
/usr/local/lib/python3.6/dist-packages/torch/include/ATen/Context.h:47: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o): In function `at::from_blob(void*, c10::ArrayRef&lt;long&gt;, c10::ArrayRef&lt;long&gt;, std::function&lt;void (void*)&gt; const&amp;, c10::TensorOptions const&amp;)':
/usr/local/lib/python3.6/dist-packages/torch/include/ATen/Functions.h:1099: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o): In function `torch::autograd::make_variable(at::Tensor, bool, bool)':
/usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/autograd/variable.h:524: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o): In function `c10::intrusive_ptr&lt;c10::StorageImpl, c10::detail::intrusive_target_default_null_type&lt;c10::StorageImpl&gt; &gt;::retain_()':
/usr/local/lib/python3.6/dist-packages/torch/include/c10/util/intrusive_ptr.h:183: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o): In function `c10::intrusive_ptr&lt;c10::TensorImpl, c10::UndefinedTensorImpl&gt;::retain_()':
/usr/local/lib/python3.6/dist-packages/torch/include/c10/util/intrusive_ptr.h:183: undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
SunlightNoiseClassifier/libSunlightNoiseClassifier.a(SunlightNoiseClassifier.cpp.o):/usr/local/lib/python3.6/dist-packages/torch/include/c10/util/intrusive_ptr.h:183: more undefined references to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)' follow
collect2: error: ld returned 1 exit status
</code></pre>

elduderino15: <p>Issues solved with this bug report:</p>
<aside class="onebox githubissue">
  <header class="source">
      <a href="https://github.com/pytorch/pytorch/issues/32500" target="_blank" rel="nofollow noopener">github.com/pytorch/pytorch</a>
  </header>
  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewbox="0 0 14 16" aria-hidden="true"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/pytorch/pytorch/issues/32500" target="_blank" rel="nofollow noopener">CMake find_package returns corrupted library list </a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2020-01-22" data-time="19:27:53" data-timezone="UTC">07:27PM - 22 Jan 20 UTC</span>
      </div>


      <div class="user">
        <a href="https://github.com/thomashrabeBC" target="_blank" rel="nofollow noopener">
          <img alt="thomashrabeBC" src="https://avatars3.githubusercontent.com/u/50608543?v=4" class="onebox-avatar-inline" width="20" height="20">
          thomashrabeBC
        </a>
      </div>
    </div>
  </div>
</div>

<div class="github-row">
  <p class="github-content">🐛 Bug
Use PyTorch model in C++, compilation breaks when using the default route.
CMake find_package(Torch REQUIRED)
returns corrupted TORCH_LIBRARIES list
torch
torch_library
/usr/local/lib/python3.6/dist-packages/torch/lib/libc10.so
/usr/local/cuda/lib64/stubs/libcuda.so
/usr/local/cuda/lib64/libnvrtc.so
/usr/local/cuda/lib64/libnvToolsExt.so
/usr/local/cuda/lib64/libcudart.so
/usr/local/lib/python3.6/dist-packages/torch/lib/libc10_cuda.so
It should not contain...</p>
</div>

<div class="labels">
    <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">module: binaries</span>
    <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">module: build</span>
    <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">triaged</span>
</div>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>