<p dir="auto">I am trying to compile tensorflow from source. I can build it <strong>successfully</strong> with CPU support only( i.e. not use <code class="notranslate">--config=cuda</code>) .</p>
<p dir="auto">But when I try to build it with GPU support, I get error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[chaowei@node07 tensorflow]$ export EXTRA_BAZEL_ARGS='-s --verbose_failures --ignore_unsupported_sandboxing --genrule_strategy=standalone --spawn_strategy=standalone --jobs 8'
[chaowei@node07 tensorflow]$ 
[chaowei@node07 tensorflow]$ /gpfs/home/chaowei/download/bazel-0.1.5/output/bazel  build -c opt --config=cuda --linkopt '-lrt' --copt=&quot;-DGPR_BACKWARDS_COMPATIBILITY_MODE&quot; --conlyopt=&quot;-std=c99&quot; //tensorflow/tools/pip_package:build_pip_package
...........
WARNING: Sandboxed execution is not supported on your system and thus hermeticity of actions cannot be guaranteed. See http://bazel.io/docs/bazel-user-manual.html#sandboxing for more information. You can turn off this warning via --ignore_unsupported_sandboxing.
INFO: Found 1 target...
ERROR: /gpfs/home/chaowei/.cache/bazel/_bazel_chaowei/2ce35f089de902cec16e4a2c6a450834/external/grpc/BUILD:485:1: C++ compilation of rule '@grpc//:grpc_unsecure' failed: gcc failed: error executing command /gpfs/home/chaowei/software/gcc-6.1.0/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 ... (remaining 39 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
external/grpc/src/core/compression/message_compress.c:41:18: fatal error: zlib.h: No such file or directory
 #include &lt;zlib.h&gt;
                  ^
compilation terminated.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 71.894s, Critical Path: 58.77s"><pre class="notranslate"><code class="notranslate">[chaowei@node07 tensorflow]$ export EXTRA_BAZEL_ARGS='-s --verbose_failures --ignore_unsupported_sandboxing --genrule_strategy=standalone --spawn_strategy=standalone --jobs 8'
[chaowei@node07 tensorflow]$ 
[chaowei@node07 tensorflow]$ /gpfs/home/chaowei/download/bazel-0.1.5/output/bazel  build -c opt --config=cuda --linkopt '-lrt' --copt="-DGPR_BACKWARDS_COMPATIBILITY_MODE" --conlyopt="-std=c99" //tensorflow/tools/pip_package:build_pip_package
...........
WARNING: Sandboxed execution is not supported on your system and thus hermeticity of actions cannot be guaranteed. See http://bazel.io/docs/bazel-user-manual.html#sandboxing for more information. You can turn off this warning via --ignore_unsupported_sandboxing.
INFO: Found 1 target...
ERROR: /gpfs/home/chaowei/.cache/bazel/_bazel_chaowei/2ce35f089de902cec16e4a2c6a450834/external/grpc/BUILD:485:1: C++ compilation of rule '@grpc//:grpc_unsecure' failed: gcc failed: error executing command /gpfs/home/chaowei/software/gcc-6.1.0/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 ... (remaining 39 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
external/grpc/src/core/compression/message_compress.c:41:18: fatal error: zlib.h: No such file or directory
 #include &lt;zlib.h&gt;
                  ^
compilation terminated.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 71.894s, Critical Path: 58.77s
</code></pre></div>
<p dir="auto"><strong>I also compile python3 from source in my computer. And when I <code class="notranslate">import zlib</code>, it works fine.</strong></p>
<p dir="auto">Here is the information of my system:<br>
<code class="notranslate">[chaowei@mgt ~]$ cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.5 (Santiago)</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[chaowei@node07 gcc-6.1.0]$ gcc -v
built-in specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/gpfs/home/chaowei/software/gcc-6.1.0/libexec/gcc/x86_64-pc-linux-gnu/6.1.0/lto-wrapper
Target：x86_64-pc-linux-gnu
Configured with：./configure --prefix=/gpfs/home/chaowei/software/gcc-6.1.0
Thread model：posix
gcc version 6.1.0 (GCC) "><pre class="notranslate"><code class="notranslate">[chaowei@node07 gcc-6.1.0]$ gcc -v
built-in specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/gpfs/home/chaowei/software/gcc-6.1.0/libexec/gcc/x86_64-pc-linux-gnu/6.1.0/lto-wrapper
Target：x86_64-pc-linux-gnu
Configured with：./configure --prefix=/gpfs/home/chaowei/software/gcc-6.1.0
Thread model：posix
gcc version 6.1.0 (GCC) 
</code></pre></div>
<p dir="auto">I wonder  why I get <code class="notranslate">zlib.h</code> error  when I only build tensorflow with GPU support.</p>
<h3 dir="auto">Environment info</h3>
<p dir="auto">Operating System: Red Hat Enterprise Linux Server release 7.2</p>
<p dir="auto">Installed version of CUDA and cuDNN: CUDA 7, cuDNN 4<br>
(please attach the output of <code class="notranslate">ls -l /path/to/cuda/lib/libcud*</code>):</p>
<p dir="auto">-rw-r--r-- 1 root root 179466 Jan 26 22:19 /usr/local/cuda/lib/libcudadevrt.a<br>
lrwxrwxrwx 1 root root     16 Jan 26 22:19 /usr/local/cuda/lib/libcudart.so -&gt; libcudart.so.7.0<br>
lrwxrwxrwx 1 root root     19 Jan 26 22:19 /usr/local/cuda/lib/libcudart.so.7.0 -&gt; libcudart.so.7.0.28<br>
-rwxr-xr-x 1 root root 303052 Jan 26 22:19 /usr/local/cuda/lib/libcudart.so.7.0.28<br>
-rw-r--r-- 1 root root 546514 Jan 26 22:19 /usr/local/cuda/lib/libcudart_static.a</p>
<p dir="auto">cuDNN is installed for the local user only.</p>
<p dir="auto">If installed from sources, provide the commit hash:</p>
<p dir="auto"><a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/tensorflow/tensorflow/commit/b289bc7a50fc0254970c60aaeba01c33de61a728/hovercard" href="https://github.com/tensorflow/tensorflow/commit/b289bc7a50fc0254970c60aaeba01c33de61a728"><tt>b289bc7</tt></a></p>
<h3 dir="auto">Steps to reproduce</h3>
<p dir="auto">I have followed the instructions at: <a href="https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#requirements" rel="nofollow">https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#requirements</a></p>
<p dir="auto">Since I am not root, I had to install everything for the local user, but it seems to have worked.</p>
<p dir="auto">I get an error at this line:</p>
<p dir="auto">bazel build -c opt --config=cuda //tensorflow/cc:tutorials_example_trainer</p>
<p dir="auto">Saying:</p>
<p dir="auto">ERROR: [...]/vlad/.cache/bazel/_bazel_vlad/6607a39fc04ec931b523fac975ff3100/external/png_archive/BUILD:23:1: Executing genrule @png_archive//:configure failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.<br>
[...]/vlad/.cache/bazel/_bazel_vlad/6607a39fc04ec931b523fac975ff3100/tensorflow/external/png_archive/libpng-1.2.53 [...]/vlad/.cache/bazel/_bazel_vlad/6607a39fc04ec931b523fac975ff3100/tensorflow<br>
/tmp/tmp.pCUaj9eIKr [...]/vlad/.cache/bazel/_bazel_vlad/6607a39fc04ec931b523fac975ff3100/tensorflow/external/png_archive/libpng-1.2.53 [...]/vlad/.cache/bazel/_bazel_vlad/6607a39fc04ec931b523fac975ff3100/tensorflow</p>
<p dir="auto">... a bunch more lines until:</p>
<p dir="auto">checking for pow... no<br>
checking for pow in -lm... yes<br>
checking for zlibVersion in -lz... no<br>
<strong>configure: error: zlib not installed</strong><br>
Target //tensorflow/cc:tutorials_example_trainer failed to build<br>
Use --verbose_failures to see the command lines of failed build steps.<br>
INFO: Elapsed time: 57.196s, Critical Path: 22.12s</p>
<h3 dir="auto">What have you tried?</h3>
<p dir="auto">I installed zlib, and the following program compiles with g++</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#include &lt;cstdio&gt;
#include &lt;zlib.h&gt;

int main()
{
    printf(&quot;Hello world&quot;);
    return 0;
}"><pre class="notranslate"><code class="notranslate">#include &lt;cstdio&gt;
#include &lt;zlib.h&gt;

int main()
{
    printf("Hello world");
    return 0;
}
</code></pre></div>
<p dir="auto">I have the following in my .bashrc:</p>
<p dir="auto">export LD_LIBRARY_PATH="$HOME/local/cuda/lib64:$LD_LIBRARY_PATH"<br>
export LD_LIBRARY_PATH="$HOME/bin/zlibdev/lib:$LD_LIBRARY_PATH"<br>
export CPATH="$HOME/local/cuda/include:$CPATH"<br>
export CPATH="$HOME/bin/zlibdev/include:$CPATH"<br>
export LIBRARY_PATH="$HOME/local/cuda/lib64:$LIBRARY_PATH"</p>
<p dir="auto">export PKG_CONFIG_PATH="$HOME/bin/zlibdev/lib/pkgconfig"</p>
<p dir="auto">Why can't bazel / tensorflow find zlib.h? It's there and accessible.</p>