Getting Error in CMake Libtorch

ritesh_gupta: <p>Hi,<br>
I’m getting CMake error while doing <em>cmake -DCMAKE_PREFIX_PATH=…/…/libtorch …</em> . Yesterday I followed the same step, which is on <a href="https://pytorch.org/tutorials/advanced/cpp_export.html" rel="noopener nofollow ugc">Pytorch</a>. I’m able to build it successfully on my laptop, but when I’m doing the same I’m getting an error like<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/8/8b3abb5ba8088c9a1ff91094061e12b1d7ea22d1.png" data-download-href="https://discuss.pytorch.org/uploads/default/8b3abb5ba8088c9a1ff91094061e12b1d7ea22d1" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/2X/8/8b3abb5ba8088c9a1ff91094061e12b1d7ea22d1.png" alt="image" data-base62-sha1="jRGcs1gWiEg28dLJ88vWvDjDdEl" width="690" height="336" data-dominant-color="04393E"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">730×356 47.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>I looked all the answer which are relevant to this, but all that didn’t let me to the conclusion. Can someone help me in this regard?<br>
Thank you.</p>

yf225: <p>Have you checked and made sure that there is a libtorch installation at <code>../../libtorch</code>? Also another thing to try is to remove the <code>~/example-app/build</code> folder, recreate it again and then rerun the steps.</p>

ritesh_gupta: <p>Hi Will,<br>
I tried the above steps mentioned by you, but it is throwing same error. What to do? I have downloaded the libtorch and extracted it in specified directory.</p>

kevinhaoliu: <p>Do you download the right version of libtorch? I download a windows version on my linux machine last time.</p>

ritesh_gupta: <p>Hi Kevin,<br>
Yes i did. I also tried without CUDA version also, I’m getting the same error.</p>

yf225: <p><a class="mention" href="/u/ritesh_gupta">@ritesh_gupta</a> Could you provide the result of <code>ls ~/libtorch</code> on your machine?</p>

ritesh_gupta: <p><img src="https://discuss.pytorch.org/uploads/default/original/2X/2/2477bdebc27da4a4b033d9ccd9f16f52ce760d2f.png" alt="image" data-base62-sha1="5cBJyig0ljDBq3Af3tYLsA9GDT1" width="550" height="105"></p>

tom: <p>Wouln’t you need to point to the subdir containing the cmake files (share/cmake)?</p>

ritesh_gupta: <p>Sorry, I didn’t get you?</p>

ritesh_gupta: <p>Hi,<br>
I think error could be because of cuda. As same program without CUDA Libtorch runs perfectly well(left terminal), whereas with CUDA Libtorch throws error(right terminal). Any help would be welcome.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/f/f8276d625cdedf20cee3a98fd03b9483b89dbfa7.png" data-download-href="https://discuss.pytorch.org/uploads/default/f8276d625cdedf20cee3a98fd03b9483b89dbfa7" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/f/f8276d625cdedf20cee3a98fd03b9483b89dbfa7_2_689x390.png" alt="image" data-base62-sha1="zpgSSPZNbmD9QlY2A4re15CT75d" width="689" height="390" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/f/f8276d625cdedf20cee3a98fd03b9483b89dbfa7_2_689x390.png, https://discuss.pytorch.org/uploads/default/optimized/2X/f/f8276d625cdedf20cee3a98fd03b9483b89dbfa7_2_1033x585.png 1.5x, https://discuss.pytorch.org/uploads/default/original/2X/f/f8276d625cdedf20cee3a98fd03b9483b89dbfa7.png 2x" data-dominant-color="155063"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1299×736 189 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Thanks.</p>

yf225: <p>Thanks for debugging further. I think the answer to the previous problem is that we should use <code>cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch ..</code> instead of <code>cmake -DCMAKE_PREFIX_PATH=relative/path/to/libtorch ..</code>. Putting it here so that other users could see the solution.</p>

tom: <p>Do you have the libculibos.so in the directory it’s looking in? Or one nearby (like cuda-10)?</p>

ritesh_gupta: <p>No, I don’t have that file in both places.</p>

ritesh_gupta: <p>Thanks Will, But the screenshot I posted has an absolute path, not a relative path. Also any idea on how to correct the library error? I tried giving <div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/c/c378480511936e0aca60f89531a1cfd999f0f604.png" data-download-href="https://discuss.pytorch.org/uploads/default/c378480511936e0aca60f89531a1cfd999f0f604" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/c/c378480511936e0aca60f89531a1cfd999f0f604_2_690x138.png" alt="image" data-base62-sha1="rTcO74PilHWCpvQ2wIKYpiIIHsM" width="690" height="138" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/c/c378480511936e0aca60f89531a1cfd999f0f604_2_690x138.png, https://discuss.pytorch.org/uploads/default/optimized/2X/c/c378480511936e0aca60f89531a1cfd999f0f604_2_1035x207.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/c/c378480511936e0aca60f89531a1cfd999f0f604_2_1380x276.png 2x" data-dominant-color="084961"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2031×408 71.2 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div> by following the command given at <a href="https://devtalk.nvidia.com/default/topic/1031567/jetson-tx2/library-in-hidden-by-files-in-/" class="inline-onebox" rel="noopener nofollow ugc">Library in ... hidden by files in ... - Jetson TX2 - NVIDIA Developer Forums</a> but to no luck.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/a/acb9ea3b07bdc605eee5a046c26db854089d10b0.png" data-download-href="https://discuss.pytorch.org/uploads/default/acb9ea3b07bdc605eee5a046c26db854089d10b0" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/a/acb9ea3b07bdc605eee5a046c26db854089d10b0_2_690x269.png" alt="image" data-base62-sha1="oE0rDZOvG6msLd4p8evXWm17DB6" width="690" height="269" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/a/acb9ea3b07bdc605eee5a046c26db854089d10b0_2_690x269.png, https://discuss.pytorch.org/uploads/default/original/2X/a/acb9ea3b07bdc605eee5a046c26db854089d10b0.png 1.5x, https://discuss.pytorch.org/uploads/default/original/2X/a/acb9ea3b07bdc605eee5a046c26db854089d10b0.png 2x" data-dominant-color="0D4E64"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1026×401 61.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

yf225: <p><a class="mention" href="/u/ritesh_gupta">@ritesh_gupta</a> Did you make sure that CUDA is correctly installed on your machine?</p>

ritesh_gupta: <p><a class="mention" href="/u/yf225">@yf225</a> I’m using DGX server which already has preinstalled CUDA. I can run the pytorch model on GPU. So I think so the installation of CUDA is an issue out here.</p>

beyondpie: <p><a class="mention" href="/u/ritesh_gupta">@ritesh_gupta</a><br>
Does the link below help you? I think you need to check to make sure that /usr/local/cuda/ or /usr/local/cuda-10.0  you are using.<br>
<aside class="onebox githubissue">
  <header class="source">
      <a href="https://github.com/pytorch/pytorch/issues/15476" target="_blank" rel="nofollow noopener">github.com/pytorch/pytorch</a>
  </header>
  <article class="onebox-body">
    <a href="https://github.com/ly7969" rel="nofollow noopener">
<img src="https://avatars1.githubusercontent.com/u/40926783?v=2&amp;s=96" class="thumbnail onebox-avatar" width="60" height="60">
</a>

<h4><a href="https://github.com/pytorch/pytorch/issues/15476" target="_blank" rel="nofollow noopener">Issue: Loading a PyTorch Model in C++ tutorial fails with No rule to make target '/usr/local/cuda/lib64/libculibos.a'</a></h4>

<div class="date" style="margin-top:10px;">
	<div class="user" style="margin-top:10px;">
	opened by <a href="https://github.com/ly7969" target="_blank" rel="nofollow noopener">ly7969</a>
	on <a href="https://github.com/pytorch/pytorch/issues/15476" target="_blank" rel="nofollow noopener">2018-12-21</a>
	</div>
	<div class="user">
	</div>
</div>

<pre class="content" style="white-space: pre-wrap;">hi all
Follow the tutorial(Loading a PyTorch Model in C++)
1.cmake
-- Caffe2: CUDA detected: 10.0
-- Caffe2: CUDA nvcc is: /usr/local/cuda-10.0/bin/nvcc
-- Caffe2: CUDA toolkit...</pre>

<div class="labels">
 	<span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">high priority</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;">module: cpp</span>
 	<span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">module: cuda</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>
</p>