<h2 dir="auto">Issue description</h2>
<p dir="auto">When I compile external C++ app with CMake using Caffe2 dependency, ATen header is missing.</p>
<blockquote>
<p dir="auto">fatal error: ATen/core/Macros.h: No such file or directory</p>
</blockquote>
<p dir="auto">Seems like ATen headers are not properly copied to /usr/local/include while other headers are well installed.<br>
Reproduced with Caffe2 with Ubuntu 16.04/CUDA 8/CuDNN 7 Dockerfile <a href="https://github.com/pytorch/pytorch/blob/master/docker/caffe2/ubuntu-16.04-cuda8-cudnn7-all-options/Dockerfile">here</a>.</p>
<p dir="auto">I was able to resolve the issue by adding the following line to the Dockerfile.</p>
<blockquote>
<p dir="auto">RUN cp -RL /usr/pytorch/aten/src/ATen /usr/local/include/</p>
</blockquote>
<h2 dir="auto">Code example</h2>
<p dir="auto">I used /usr/local/include as my Caffe2 include directory in my FindCaffe2.cmake as below.</p>
<blockquote>
<p dir="auto">find_path(Caffe2_INCLUDE_DIR NAMES caffe2 onnx google eigen3 ATen HINTS /usr/local/include)</p>
</blockquote>
<p dir="auto">I include four header files in my app, and it makes compile error.</p>
<blockquote>
<p dir="auto">#include &lt;caffe2/core/init.h&gt;<br>
#include &lt;caffe2/core/net.h&gt;<br>
#include &lt;caffe2/core/context_gpu.h&gt;<br>
#include &lt;caffe2/utils/proto_utils.h&gt;</p>
</blockquote>
<h2 dir="auto">System Info</h2>
<p dir="auto">Ubuntu 16.04 / CUDA 8.0 / CuDNN 7.1 on Docker.</p>
<ul dir="auto">
<li>PyTorch or Caffe2: Caffe2</li>
<li>How you installed PyTorch (conda, pip, source): source</li>
<li>Build command you used (if compiling from source): built Dockerfile.</li>
<li>OS: Ubuntu 16.04</li>
<li>PyTorch version: master</li>
<li>Python version: 2</li>
<li>CUDA/cuDNN version: 8.0/7.1</li>
<li>GPU models and configuration: GTX 1080 Ti</li>
<li>GCC version (if compiling from source): 5.4</li>
<li>CMake version: 3.5.1</li>
<li>Versions of any other relevant libraries:</li>
</ul>
<h2 dir="auto">Issue Description</h2>
<p dir="auto">I git clone pytorch to <code class="notranslate">$PYTORCH_HOME</code>, and installed it using cmake to directory <code class="notranslate">$PYTORCH_HOME/build/install</code>. The ATen core headers were installed to <code class="notranslate">$PYTORCH_HOME/build/install/include/ATen/core/core/*.h</code> instead of <code class="notranslate">$PYTORCH_HOME/build/install/include/ATen/core/*.h</code> (<strong>I think this is abnormal, because compiling custom operators requires <code class="notranslate">&lt;ATen/core/*.h&gt;</code>. See below.</strong>).</p>
<p dir="auto">The result of <code class="notranslate">tree $PYTORCH_HOME/build/install/include/ATen</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ATen
`-- core
    `-- core
        |-- AlignOf.h
        |-- ArrayRef.h
        |-- ATenCoreTest.h
        |-- Backtrace.h
        |-- C++17.h
        |-- CoreAPI.h
        |-- DeviceType.h
        |-- Error.h
        |-- Half.h
        |-- Half-inl.h
        |-- IdWrapper.h
        |-- intrusive_ptr.h
        |-- optional.h
        |-- SmallVector.h
        `-- UniqueVoidPtr.h"><pre class="notranslate"><code class="notranslate">ATen
`-- core
    `-- core
        |-- AlignOf.h
        |-- ArrayRef.h
        |-- ATenCoreTest.h
        |-- Backtrace.h
        |-- C++17.h
        |-- CoreAPI.h
        |-- DeviceType.h
        |-- Error.h
        |-- Half.h
        |-- Half-inl.h
        |-- IdWrapper.h
        |-- intrusive_ptr.h
        |-- optional.h
        |-- SmallVector.h
        `-- UniqueVoidPtr.h
</code></pre></div>
<p dir="auto">In the <a href="https://github.com/facebookresearch/DensePose">DensePose</a> project which uses Caffe2, when I built custom operators:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# In DensePose project
mkdir build &amp;&amp; cd build
cmake .. -DCaffe2_DIR=$PYTORCH_HOME/build/install/share/cmake/Caffe2
make"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> In DensePose project</span>
mkdir build <span class="pl-k">&amp;&amp;</span> <span class="pl-c1">cd</span> build
cmake .. -DCaffe2_DIR=<span class="pl-smi">$PYTORCH_HOME</span>/build/install/share/cmake/Caffe2
make</pre></div>
<p dir="auto">The <code class="notranslate">make</code> command threw error of not finding <code class="notranslate">&lt;ATen/core/Error.h&gt;</code> for <code class="notranslate">caffe2/core/logging.h</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Scanning dependencies of target caffe2_detectron_custom_ops
[ 12%] Building CXX object CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/pool_points_interp.cc.o
In file included from /home/users/houjing.huang/Software/pytorch/build/install/include/caffe2/core/allocator.h:6:0,
                 from /home/users/houjing.huang/Software/pytorch/build/install/include/caffe2/core/context.h:9,
                 from /home/users/houjing.huang/Project/DensePose/detectron/ops/pool_points_interp.h:13,
                 from /home/users/houjing.huang/Project/DensePose/detectron/ops/pool_points_interp.cc:10:
/home/users/houjing.huang/Software/pytorch/build/install/include/caffe2/core/logging.h:10:29: fatal error: ATen/core/Error.h: No such file or directory
 #include &lt;ATen/core/Error.h&gt;
                             ^
compilation terminated.
make[2]: *** [CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/pool_points_interp.cc.o] Error 1
make[1]: *** [CMakeFiles/caffe2_detectron_custom_ops.dir/all] Error 2
make: *** [all] Error 2"><pre class="notranslate"><code class="notranslate">Scanning dependencies of target caffe2_detectron_custom_ops
[ 12%] Building CXX object CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/pool_points_interp.cc.o
In file included from /home/users/houjing.huang/Software/pytorch/build/install/include/caffe2/core/allocator.h:6:0,
                 from /home/users/houjing.huang/Software/pytorch/build/install/include/caffe2/core/context.h:9,
                 from /home/users/houjing.huang/Project/DensePose/detectron/ops/pool_points_interp.h:13,
                 from /home/users/houjing.huang/Project/DensePose/detectron/ops/pool_points_interp.cc:10:
/home/users/houjing.huang/Software/pytorch/build/install/include/caffe2/core/logging.h:10:29: fatal error: ATen/core/Error.h: No such file or directory
 #include &lt;ATen/core/Error.h&gt;
                             ^
compilation terminated.
make[2]: *** [CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/pool_points_interp.cc.o] Error 1
make[1]: *** [CMakeFiles/caffe2_detectron_custom_ops.dir/all] Error 2
make: *** [all] Error 2
</code></pre></div>
<p dir="auto">I found these lines in file <code class="notranslate">$PYTORCH_HOME/build/install_manifest.txt</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/ATenCoreTest.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/AlignOf.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/ArrayRef.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/Backtrace.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/C++17.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/CoreAPI.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/DeviceType.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/Error.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/Half-inl.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/Half.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/IdWrapper.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/SmallVector.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/UniqueVoidPtr.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/intrusive_ptr.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/optional.h"><pre class="notranslate"><code class="notranslate">/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/ATenCoreTest.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/AlignOf.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/ArrayRef.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/Backtrace.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/C++17.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/CoreAPI.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/DeviceType.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/Error.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/Half-inl.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/Half.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/IdWrapper.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/SmallVector.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/UniqueVoidPtr.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/intrusive_ptr.h
/mnt/data-1/data/houjing.huang/Software/pytorch/build/install/include/ATen/core/core/optional.h
</code></pre></div>
<h2 dir="auto">System Info</h2>
<ul dir="auto">
<li>
<p dir="auto">PyTorch or Caffe2: Caffe2</p>
</li>
<li>
<p dir="auto">How you installed PyTorch (conda, pip, source): source, referring to <a href="https://caffe2.ai/docs/getting-started.html?platform=centos&amp;configuration=cloud" rel="nofollow">caffe2.ai</a></p>
</li>
<li>
<p dir="auto">Build command to install Pytorch/Caffe2 (if compiling from source):</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
mkdir build &amp;&amp; cd build
cmake \
-DCUDA_TOOLKIT_ROOT_DIR=$HOME/Software/cuda-8.0 \
-DCMAKE_INSTALL_PREFIX=${PWD}/install ..
make -j12 install"><pre class="notranslate">git clone --recursive https://github.com/pytorch/pytorch
<span class="pl-c1">cd</span> pytorch
mkdir build <span class="pl-k">&amp;&amp;</span> <span class="pl-c1">cd</span> build
cmake \
-DCUDA_TOOLKIT_ROOT_DIR=<span class="pl-smi">$HOME</span>/Software/cuda-8.0 \
-DCMAKE_INSTALL_PREFIX=<span class="pl-smi">${PWD}</span>/install ..
make -j12 install</pre></div>
</li>
<li>
<p dir="auto">OS: CentOS Linux release 7.4.1708</p>
</li>
<li>
<p dir="auto">PyTorch version: master branch, commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pytorch/pytorch/commit/f57e4ce1d59aab53e48b0ae93a7ef7e9a4dc1e2e/hovercard" href="https://github.com/pytorch/pytorch/commit/f57e4ce1d59aab53e48b0ae93a7ef7e9a4dc1e2e"><tt>f57e4ce</tt></a></p>
</li>
<li>
<p dir="auto">Python version: 2.7</p>
</li>
<li>
<p dir="auto">CUDA/cuDNN version: CUDA 8.0, cuDNN 7</p>
</li>
<li>
<p dir="auto">GPU models and configuration:</p>
</li>
<li>
<p dir="auto">GCC version (if compiling from source): 4.8.5</p>
</li>
<li>
<p dir="auto">CMake version: 3.12.0</p>
</li>
<li>
<p dir="auto">Versions of any other relevant libraries: DensePose master branch, commit <a href="https://github.com/facebookresearch/DensePose/tree/e118a4c352cbaf849d70f47886ce3f6cba76116e">e118a4</a></p>
</li>
</ul>
<h2 dir="auto">Log Files When Installing Pytorch/Caffe2</h2>
<ul dir="auto">
<li>The log of pytorch <code class="notranslate">cmake ..</code>: <a href="https://github.com/huanghoujing/pytorch-caffe2-cmake-log/blob/master/cmake_output_houjing.huang.txt">log</a></li>
<li>The log of pytorch <code class="notranslate">make -j12 install</code>: <a href="https://github.com/huanghoujing/pytorch-caffe2-cmake-log/blob/master/make_install_output_houjing.huang.txt">log</a></li>
<li><a href="https://github.com/huanghoujing/pytorch-caffe2-cmake-log/blob/master/install_manifest.txt"><code class="notranslate">install_manifest.txt</code></a></li>
</ul>
<h2 dir="auto">Is It A BUG?</h2>
<p dir="auto">I manually copied <code class="notranslate">$PYTORCH_HOME/build/install/include/ATen/core/core/*.h</code> to <code class="notranslate">$PYTORCH_HOME/build/install/include/ATen/core/*.h</code> and then it's ok to build custom operators and run the tests.</p>
<p dir="auto">It seems a bug of Pytorch/Caffe2 <code class="notranslate">make install</code>?</p>