Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install tensorflow from source #251

Closed
auroua opened this issue Nov 17, 2015 · 11 comments
Closed

Install tensorflow from source #251

auroua opened this issue Nov 17, 2015 · 11 comments

Comments

@auroua
Copy link

auroua commented Nov 17, 2015

OS: xUbuntu
python-2.7
gcc 4.8
I have installed python-dev

when I build from source using

bazel build --jobs 2 -c opt //tensorflow/tools/pip_package:build_pip_package --verbose_failures

I got the following errors:

aurora@aurora-Z170X-UD5:~/workspace/tensorflow/tensorflow$ bazel build --jobs 2 -c opt //tensorflow/tools/pip_package:build_pip_package --verbose_failures
....
INFO: Found 1 target...
INFO: From Compiling tensorflow/python/client/tf_session_helper.cc:
In file included from tensorflow/python/client/tf_session_helper.cc:1:0:
./tensorflow/python/client/tf_session_helper.h:6:31: fatal error: numpy/arrayobject.h: No such file or directory
 #include "numpy/arrayobject.h"
                               ^
compilation terminated.
ERROR: /home/aurora/workspace/tensorflow/tensorflow/tensorflow/python/BUILD:698:1: C++ compilation of rule '//tensorflow/python:tf_session_helper' failed: gcc failed: error executing command 
  (cd /home/aurora/.cache/bazel/_bazel_aurora/67e9d46b2d6eaad7004805288b920919/tensorflow && \
  exec env - \
    INTERCEPT_LOCALLY_EXECUTABLE=1 \
    PATH=/home/aurora/software/anaconda2/bin:/usr/local/cuda/bin:/home/aurora/software/jdk1.8.0_25/bin:/usr/local/cuda/bin:/home/aurora/software/jdk1.8.0_25/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games \
  /usr/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 -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -iquote . -iquote bazel-out/local_linux-opt/genfiles -isystem google/protobuf/src -isystem bazel-out/local_linux-opt/genfiles/google/protobuf/src -isystem tools/cpp/gcc3 -isystem external/jpeg_archive/jpeg-9a -isystem bazel-out/local_linux-opt/genfiles/external/jpeg_archive/jpeg-9a -isystem external/png_archive/libpng-1.2.53 -isystem bazel-out/local_linux-opt/genfiles/external/png_archive/libpng-1.2.53 -isystem external/re2 -isystem bazel-out/local_linux-opt/genfiles/external/re2 -isystem third_party/gpus/cuda -isystem bazel-out/local_linux-opt/genfiles/third_party/gpus/cuda -isystem third_party/gpus/cuda/include -isystem bazel-out/local_linux-opt/genfiles/third_party/gpus/cuda/include -isystem third_party/eigen3 -isystem bazel-out/local_linux-opt/genfiles/third_party/eigen3 -I/usr/include/python2.7 -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/local_linux-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.o' -MD -MF bazel-out/local_linux-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.d -fPIC -c tensorflow/python/client/tf_session_helper.cc -o bazel-out/local_linux-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: gcc failed: error executing command 
  (cd /home/aurora/.cache/bazel/_bazel_aurora/67e9d46b2d6eaad7004805288b920919/tensorflow && \
  exec env - \
    INTERCEPT_LOCALLY_EXECUTABLE=1 \
    PATH=/home/aurora/software/anaconda2/bin:/usr/local/cuda/bin:/home/aurora/software/jdk1.8.0_25/bin:/usr/local/cuda/bin:/home/aurora/software/jdk1.8.0_25/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games \
  /usr/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 -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -iquote . -iquote bazel-out/local_linux-opt/genfiles -isystem google/protobuf/src -isystem bazel-out/local_linux-opt/genfiles/google/protobuf/src -isystem tools/cpp/gcc3 -isystem external/jpeg_archive/jpeg-9a -isystem bazel-out/local_linux-opt/genfiles/external/jpeg_archive/jpeg-9a -isystem external/png_archive/libpng-1.2.53 -isystem bazel-out/local_linux-opt/genfiles/external/png_archive/libpng-1.2.53 -isystem external/re2 -isystem bazel-out/local_linux-opt/genfiles/external/re2 -isystem third_party/gpus/cuda -isystem bazel-out/local_linux-opt/genfiles/third_party/gpus/cuda -isystem third_party/gpus/cuda/include -isystem bazel-out/local_linux-opt/genfiles/third_party/gpus/cuda/include -isystem third_party/eigen3 -isystem bazel-out/local_linux-opt/genfiles/third_party/eigen3 -I/usr/include/python2.7 -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/local_linux-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.o' -MD -MF bazel-out/local_linux-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.d -fPIC -c tensorflow/python/client/tf_session_helper.cc -o bazel-out/local_linux-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 600.219s, Critical Path: 0.40s

I have installed ananconda and the path of numpy/arrayobject.h is

/software/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy
@zhangchen-qinyinghua
Copy link

You should add
-I/software/anaconda2/lib/python2.7/site-packages/numpy/core/include
as a compiler flag in tools/cpp/CROSSBUILD in bazel.

BTW, the truth that Bazel do not recongnize the global env-vars was about to KILL me.

@ebrevdo
Copy link
Contributor

ebrevdo commented Nov 18, 2015 via email

@auroua
Copy link
Author

auroua commented Nov 18, 2015

@ebrevdo the env vars

aurora@aurora-Z170X-UD5:~/Desktop$ printenv
XDG_VTNR=7
LC_PAPER=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aurora
SELINUX_INIT=YES
LC_MONETARY=zh_CN.UTF-8
SESSION=xubuntu
GPG_AGENT_INFO=/run/user/1000/keyring-mjj0V2/gpg:0:1
GLADE_PIXMAP_PATH=:
TERM=xterm
XDG_MENU_PREFIX=xfce-
SHELL=/bin/bash
WINDOWID=62920039
LC_NUMERIC=zh_CN.UTF-8
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1741
GNOME_KEYRING_CONTROL=/run/user/1000/keyring-mjj0V2
USER=aurora
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
LC_TELEPHONE=zh_CN.UTF-8
LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/lib:/software/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy:/usr/local/cuda/lib64:/usr/local/lib:
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
GLADE_MODULE_PATH=:
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/run/user/1000/keyring-mjj0V2/ssh
DEFAULTS_PATH=/usr/share/gconf/xubuntu.default.path
SESSION_MANAGER=local/aurora-Z170X-UD5:@/tmp/.ICE-unix/1861,unix/aurora-Z170X-UD5:/tmp/.ICE-unix/1861
XDG_CONFIG_DIRS=/etc/xdg/xdg-xubuntu:/usr/share/upstart/xdg:/etc/xdg:/etc/xdg
DESKTOP_SESSION=xubuntu
PATH=/home/aurora/software/anaconda2/bin:/usr/local/cuda/bin:/home/aurora/software/jdk1.8.0_25/bin:/usr/local/cuda/bin:/home/aurora/software/jdk1.8.0_25/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
LC_IDENTIFICATION=zh_CN.UTF-8
PWD=/home/aurora/Desktop
JOB=dbus
JAVA_HOME=/home/aurora/software/jdk1.8.0_25
GNOME_KEYRING_PID=1739
LANG=en_US.UTF-8
GDM_LANG=en_US
MANDATORY_PATH=/usr/share/gconf/xubuntu.mandatory.path
LC_MEASUREMENT=zh_CN.UTF-8
IM_CONFIG_PHASE=1
GDMSESSION=xubuntu
SESSIONTYPE=
SHLVL=1
HOME=/home/aurora
XDG_SEAT=seat0
LANGUAGE=en_US
UPSTART_INSTANCE=
UPSTART_EVENTS=started xsession
LOGNAME=aurora
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-AzkSJrxWxZ
XDG_DATA_DIRS=/usr/share/xubuntu:/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share
LESSOPEN=| /usr/bin/lesspipe %s
TEXTDOMAIN=im-config
INSTANCE=
UPSTART_JOB=startxfce4
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:0.0
GLADE_CATALOG_PATH=:
XDG_CURRENT_DESKTOP=XFCE
CUDA_ROOT=/usr/local/cuda
LESSCLOSE=/usr/bin/lesspipe %s %s
LC_TIME=zh_CN.UTF-8
TEXTDOMAINDIR=/usr/share/locale/
LC_NAME=zh_CN.UTF-8
XAUTHORITY=/home/aurora/.Xauthority
COLORTERM=xfce4-terminal
_=/usr/bin/printenv

@auroua
Copy link
Author

auroua commented Nov 18, 2015

@zhangchen-qinyinghua
I follow your instruction and add this line

cxx_builtin_include_directory: "/home/aurora/software/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy"

to file

/usr/local/lib/bazel/base_workspace/tools/cpp/CROSSTOOL

I also add it to path

aurora@aurora-Z170X-UD5:~/workspace/tensorflow/tensorflow$ echo $PATH
/home/aurora/software/anaconda2/bin:/usr/local/cuda/bin:/home/aurora/software/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy:/home/aurora/software/jdk1.8.0_25/bin:/usr/local/cuda/bin:/home/aurora/software/jdk1.8.0_25/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

but I still encounter this problem

INFO: Found 1 target...
INFO: From Compiling tensorflow/python/client/tf_session_helper.cc:
In file included from tensorflow/python/client/tf_session_helper.cc:1:0:
./tensorflow/python/client/tf_session_helper.h:6:31: fatal error: numpy/arrayobject.h: No such file or directory
 #include "numpy/arrayobject.h"
                               ^
compilation terminated.
ERROR: /home/aurora/workspace/tensorflow/tensorflow/tensorflow/python/BUILD:698:1: C++ compilation of rule '//tensorflow/python:tf_session_helper' failed: gcc failed: error executing command /usr/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 -DNDEBUG -ffunction-sections ... (remaining 51 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.

I don't know how to use bazel . Is there anything wrong in my operation.
thanks

@SyncedSynapse
Copy link

Try removing numpy from the include dir. Use:

cxx_builtin_include_directory: "/home/aurora/software/anaconda2/lib/python2.7/site-packages/numpy/core/include"

@auroua
Copy link
Author

auroua commented Nov 19, 2015

@SyncedSynapse
I got the same result after remove numpy

@victorv
Copy link

victorv commented Nov 20, 2015

Try "sudo pip uninstall numpy" and "sudo pip install numpy"
If that doesn't work, try "sudo apt-get install python-numpy"

numpy probably needs to be version 1.10.1 so check this with "python", "import numpy as np", "np.version" to see the version.

@auroua
Copy link
Author

auroua commented Nov 20, 2015

@victorv
I'm using anaconda which contains numpy.
I did uninstall numpy and just executed sudo apt-get install python-numpy.
The problem disappeared.
thanks

@auroua
Copy link
Author

auroua commented Nov 20, 2015

After execute the command bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg,the generated file name is tensorflow-0.5.0-py2-none-any.whl which is different from the tutorial tensorflow-0.5.0-cp27-none-linux_x86_64.whl.
What's the different from this two files?

@victorv
Copy link

victorv commented Nov 20, 2015

Are the files different in contents? Even if they are different, it is likely the naming is just not correct on your machine.

@auroua
Copy link
Author

auroua commented Nov 21, 2015

@victorv
thanks
This issue can be closed

tensorflow-copybara pushed a commit that referenced this issue Dec 4, 2019
Closes #251

COPYBARA_INTEGRATE_REVIEW=tensorflow/mlir#251 from dfki-jugr:new_ops 0398997bf9953016898f873068e22916a062eb2b
PiperOrigin-RevId: 283750699
Change-Id: Iada2142257da7e4bade7183d84e7434a6c06707e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants