Bug? 1.5 c++ front end: torch::cuda::is_available() =false

artemmikheev: <p>I just installed torch 1.5 c++ front end (Windows, Visual Studio 2019). Cuda 10.1, latest<br>
Nvidia drivers.  This is in DEBUG version of the library.</p>
<p>Following code:</p>
<p>main() {<br>
CudaPresent = torch::cuda::is_available();<br>
}</p>
<p>CudaPresent is FALSE.</p>
<p>When I use torch 1.4 C++ front end, everything else is the same on the same PC, code is working fine<br>
and returns CudaPresent = TRUE</p>
<p>Any help super appreciated.<br>
thanks!</p>

artemmikheev: <p>Just found in some other post, adding a Linker option  -INCLUDE:?warp_size@cuda@at@<span class="mention">@YAHXZ</span><br>
worked for me too.<br>
Why is so complicated?</p>

peterjc123: <p>Well, it is because <code>torch_cuda</code> and <code>torch_cpu</code> are separated to make the linker happy. (target executable/library has a size limit) However, calling <code>torch::cuda::is_available();</code> doesn’t rely on any symbol in <code>torch_cuda</code> so the linker will optimize it away for your executable. As the result, you see <code>FALSE</code> there. Adding <code>-INCLUDE:?warp_size@cuda@at@@YAHXZ</code> forces the linker to include <code>torch_cuda</code>. If you use CMake, then you don’t need to set it manually. I just don’t expect so many users that create the VS project on their own. So we are working on to move this flag into the header to avoid confusing the user.</p>

artemmikheev: <p>Many thanks for prompt response. I was waiting for this VS integration capability for several years and it looks great right now. Thank you for your excellent work!</p>

Cosmin1: <p><a class="mention" href="/u/artemmikheev">@artemmikheev</a> at what linker option did you add “-INCLUDE:?warp_size@cuda@at@<span class="mention">@YAHXZ</span>” ?</p>

artemmikheev: <p>It is under Linker&gt;All Options&gt;Additional Options</p>

Cosmin1: <p>Thank you,I already tried that, but torch::cuda::is_available() is still 0.Any advices?</p>

Larry_Li: <p>Does this issue resolved ?  The torch::cuda::is_available() api return false on my linux system, while torch.cuda.is_available() return True.<br>
How to fix it ?</p>
<p>oot@b92d948aa67e:/workspace/code/example# ldd build/main<br>
linux-vdso.so.1 (0x00007ffd61df4000)<br>
libc10.so =&gt; /workspace/code/mytorch/pytorch/build/lib/libc10.so (0x00007f964377c000)<br>
libtorch_cpu.so =&gt; /workspace/code/mytorch/pytorch/build/lib/libtorch_cpu.so (0x00007f962dc51000)<br>
libstdc++.so.6 =&gt; /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f962da69000)<br>
libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f962da4e000)<br>
libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f962d85c000)<br>
libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007f962d70b000)<br>
libgomp.so.1 =&gt; /lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f962d6c9000)<br>
libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f962d6a6000)<br>
/lib64/ld-linux-x86-64.so.2 (0x00007f9643953000)<br>
librt.so.1 =&gt; /lib/x86_64-linux-gnu/librt.so.1 (0x00007f962d69c000)<br>
libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f962d696000)<br>
libmkl_intel_lp64.so.1 =&gt; /root/anaconda3/lib/libmkl_intel_lp64.so.1 (0x00007f962caf5000)<br>
libmkl_gnu_thread.so.1 =&gt; /root/anaconda3/lib/libmkl_gnu_thread.so.1 (0x00007f962af6a000)<br>
libmkl_core.so.1 =&gt; /root/anaconda3/lib/libmkl_core.so.1 (0x00007f9626afc000)<br>
libcupti.so.11.6 =&gt; /usr/local/cuda/lib64/libcupti.so.11.6 (0x00007f9626250000)<br>
libcudart.so.11.0 =&gt; /usr/local/cuda/lib64/libcudart.so.11.0 (0x00007f9625fac000)<br>
libutil.so.1 =&gt; /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f9625fa5000)</p>