A link problem occurred when compiling TorchScript demo with PGI compiler

username: luc99hen
cooked: <p>Hi, guys. I was trying to play with the <a href="https://pytorch.org/tutorials/advanced/cpp_export.html" rel="noopener nofollow ugc">TorchScript C++ demo</a> and have got some issues when switching the compiler from gcc to pgi.</p>
<p>When compiling with gcc compiler, everything was fine.</p>
<p>However when I switch to pgi with this cmake command <code>cmake -DCMAKE_PREFIX_PATH=/lib/libtorch11/ -DCMAKE_MODULE_PATH=/lib/libtorch11/share/cmake/Torch -DCMAKE_CXX_COMPILER=mpiCC ..</code> (everything else is the same)</p>
<p>the configure phase also went well, but I got a link error like this while building<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/9/09818c72b47afad9ffea73fe4d256cd85e70ca77.png" data-download-href="https://discuss.pytorch.org/uploads/default/09818c72b47afad9ffea73fe4d256cd85e70ca77" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/09818c72b47afad9ffea73fe4d256cd85e70ca77_2_690x192.png" alt="image" data-base62-sha1="1m5QWkmIpBdHIdRCQgrNEa0eFoP" width="690" height="192" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/09818c72b47afad9ffea73fe4d256cd85e70ca77_2_690x192.png, https://discuss.pytorch.org/uploads/default/optimized/3X/0/9/09818c72b47afad9ffea73fe4d256cd85e70ca77_2_1035x288.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/0/9/09818c72b47afad9ffea73fe4d256cd85e70ca77.png 2x" data-dominant-color="2A2B2B"><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">1171×326 67.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></p>
<p>I don’t know it’s just the PGI compiler is incompatible with the downloaded libtorch library, or there are some extra settings missing here.</p>
<p>BTW, the libtorch version I used was <code>libtorch-cxx11-abi-shared-with-deps-1.9.0+cu111.zip</code>.</p>

username: luc99hen
cooked: <p>FYI, the output of the cmake configure phase is here.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/9/79482bf36a3368ae54e743995ca8bd753fd7e40f.png" data-download-href="https://discuss.pytorch.org/uploads/default/79482bf36a3368ae54e743995ca8bd753fd7e40f" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/9/79482bf36a3368ae54e743995ca8bd753fd7e40f_2_690x314.png" alt="image" data-base62-sha1="hiUoRBwHPH4dfZhrwm0YqkOcUa3" width="690" height="314" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/9/79482bf36a3368ae54e743995ca8bd753fd7e40f_2_690x314.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/9/79482bf36a3368ae54e743995ca8bd753fd7e40f_2_1035x471.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/7/9/79482bf36a3368ae54e743995ca8bd753fd7e40f_2_1380x628.png 2x" data-dominant-color="252525"><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">1670×761 77.4 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>