newbie here, first message :)
I need tensorflow with CUDA, AVX and SSE on a windows machine. As far as I understood I need to build it myself. I first tried with Anaconda, but it was a mess, so I uninstalled anything related to python and I started following step by step the official guide
I used several commands to build, for instance:
bazel build -c opt --copt=-march=native --copt=-mfpmath=both --config=cuda -k //tensorflow/tools/pip_package:build_pip_package
bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda -k //tensorflow/tools/pip_package:build_pip_package
bazel build --config=opt --config=cuda --define=no_tensorflow_py_deps=true //tensorflow/tools/pip_package:build_pip_package
The first two commands came from here and might be old.
The building always fails with this message:
ERROR: missing input file 'external/llvm-project/mlir/include/mlir/Interfaces/SideEffectInterfaces.h', owner: '#llvm-project//mlir:include/mlir/Interfaces/SideEffectInterfaces.h'
Does anybody understand what is going on here?
Also, what is the best command to build among the one I used?
Is there any way to install it in Anaconda on windows (with CUDA, avx and SSE capabilities)?
Building tensorflow on windows can be tough, there are many ways for it to fail. The procedure will vary with the version you are compiling. For the most part, the instructions on the tensorflow site are correct if followed verbatim. I think the trickiest part is matching the version of tools used to compile with version of tensorflow you are working with.
My suggestion would be to lock into a particular version of tensorflow and stick with that until you succeed. If you git clone the source from github, I would suggest git checkout r2.2. This will put you into the most recent version.
I would avoid anaconda as that presents complications with the python version you are working with. I have had good results with python 3.6.8., but it may be possible to use 3.7.
You will need a specific version of Bazel as well, 2.0.0 is what works with tensorflow r2.2. Be mindful that you need to configure the BAZEL_VC environment variable before you start compiling. It should look something like C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC. You can do a bazel clean --expunge after the variable is set to avoid some confusion.
The r2.2 tensorflow also requires MSVC 2019, it will not compile with other versions. You will need the build tools for this version as well.
The last bazel build command you showed is the correct one. Don't forget to python ./configure.py before starting a fresh compile.
If my guess is correct, the error message you are getting is from using an older version of MSVC on the later tensorflow source code, but that's just a guess.
Related
hey guys im trying to install tensorflow
c++ on windows 10 but im running into this
issue when i try to do the bazel command
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
As a basic sanity check to resolve your problem, you need to make sure you are running a specific version of TensorFlow using the recommended bazel build tool as specified in the instructions:
https://www.tensorflow.org/install/source
For example, TensorFlow v0.9 should go with Bazel tool v0.11.0. Could you provide this information for you case ?
I am trying to compile Tensorflow (tried both: full & lite) on Odroid XU4 (16GB eMMc, Ubuntu 16) but I am getting errors shown in figures: https://www.dropbox.com/sh/j86ysncze1q0eka/AAB8RZtUTkaytqfEGivbev_Ga?dl=0
I am using FlytOS as OS(http://docs.flytbase.com/docs/FlytOS/GettingStarted/OdroidGuide.html). Its customized Ubuntu 16 with OpenCV and ROS setup, makes 11GB after installation. So, I got only 2.4GB free. Therefore, I added 16GB USB as swap memory.
I have installed Bazel without using swap memory. Tried tensorflow full version and lite but failed to compile. However, I downloaded compiled tensorflow lite for Pi and successfully installed on Odroid. Since, Odroid is Octacore, therefore, to make best use of available processing power I need to compile tensorflow on Odroid.
Please let me know if any one has tensorflow compiled on Odroid XU4.
Regards,
Check this guide out. Build Tensorflow on Odroid
IT gives a detailed step by step guide and also has some troubleshooting procedures.
Summarizing the steps here:
Install prerequisites including g++, gcc-4.8, python-pip, python-dev, numpy and Oracle Java (not OpenJDK)
Use a USB/ Flash drive and add some swap memory
Build Bazel. In the compile.sh shell script, modify the run line to add memory flags
run “${JAVAC}” -J-Xms256m -J-Xmx384m -classpath “${classpath}” -sourcepath “${sourcepath}”
Get Tensorflow v1.4 specifically and run ./configure and select relevant options. Disable XLA as it's causing some problems.
Finally run Bazel command.
bazel build -c opt --copt="-funsafe-math-optimizations" --copt="-ftree-vectorize" --copt="-fomit-frame-pointer" --local_resources 8192,8.0,1.0 --verbose_failures tensorflow/tools/pip_package:build_pip_package
Now install it.
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
sudo pip2 install /tmp/tensorflow_pkg/tensorflow-1.4.0-cp27-cp27mu-linux_armv7l.whl --upgrade --ignore-installed
Test the install
python
import tensorflow
print(tensorflow.__version__)
1.4.0
I was able to compile it successfully by following the steps given there.
So, I've installed Bazel via Chocolatey, installed Python 3.5 and 2.7, installed CUDA v8, and cuDNN v6, and installed JDK 8.0, I'm now trying to custom-build TensorFlow on my Windows 10 device, with AVX, AVX 2 and CUDA. TensorFlow-GPU, the pre-built version, does work, I've already tested and run that successfully.
I've followed the instructions of other articles, both on TensorFlows' actual site (trying to adapt some sections from the Linux/Mac installs), and on here. The furthest I've made it is; cloning the Github repository via Msys2, running configure.py, then attempting to build via bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package I receive an error, the header of which is:
Error reading java.io.IOException: CreateProcess(): The system cannot find the file specified.
: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/include/cudnn.h
I've double checked, that file does exist, so I'm not sure why I'm getting this error.
EDIT: Also attempted to run via Powershell, reached the same point.
Any help would be much appreciated.
I had the exact same error while trying to build Tensorflow on Windows (using cuDNN 5.1). I fixed it by launching bazel from the msys2 terminal (instead of from the windows command prompt) and manually setting the BAZEL_SH environment variable before attempting to build.
export BAZEL_SH=c:/tools/msys64/usr/bin/bash.exe
bazel build -c opt --config=win-cuda tensorflow/cc:cc_ops
The following steps helped me to compile Tensorflow on Windows 10.
pacman -Syuu patch
ln -s "c:\python27\python.exe" /usr/bin/python
export BAZEL_SH=c:/tools/msys64/usr/bin/bash.exe
"C:\Documents and Settings\All Users\chocolatey\bin\bazel.exe" build --config=opt --config=win-cuda //tensorflow/tools/pip_package:build_pip_package
But after 1 hour of compilation I got another error:
C:\tools\msys64\tmp_bazel_dmitry\x1e5egqw\execroot\org_tensorflow\external\protobuf_archive\python\google\protobuf\internal\api_implementation.cc
: fatal error C1083: Cannot open compiler generated file: '': Invalid
argument Target //tensorflow/tools/pip_package:build_pip_package
failed to build
I try to build tensorflow-serving using bazel but I've encountered some errors during the building
ERROR:/private/var/tmp/_bazel_Kakadu/3f0c35881c95d2c43f04614911c03a57/external/local_config_cc/BUILD:49:5: in apple_cc_toolchain rule #local_config_cc//:cc-compiler-darwin_x86_64: Xcode version must be specified to use an Apple CROSSTOOL.
ERROR: Analysis of target '//tensorflow_serving/sources/storage_path:file_system_storage_path_source_proto' failed; build aborted.
I've already tried to use bazel clean and bazel clean --expunge but it didn't help and still Bazel doesn't see my xcode (I suppose) but it's completely installed. I even reinstalled it to make sure that all works fine but the error didn't disappeared
My Bazel version is
Build label: 0.5.2-homebrew
Build target: bazel-out/darwin_x86_64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Jul 13 12:29:40 2017 (1499948980)
Build timestamp: 1499948980
Build timestamp as int: 1499948980
KakaduDevs-Mac-mini:serving Kakadu$
OS is MacOS Sierra version 10.12.5
What should I do to specify Xcode version in bazel to avoid this error? It seems that the error is common but I haven't found how I can make the bazel build.
P.S I'm trying to install tensorflow-serving the way it's explained here.
https://tensorflow.github.io/serving/setup
bazel clean --expunge
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
bazel clean --expunge
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
Had the same problem, and since I am using a beta version of XCode, I had to find the installation in /Downloads/Xcode-beta.app instead.
Incidentally, the solution for me was to open XCode, go to Preferences, and select the Locations tab. The Command Line Tools drop-down was blank, and I had to press it and select a version (Xcode 9.0 in my case). I then ran bazel clean --expunge and repeated the build process without getting the error. Hope this helps someone.
It looks like xcode_configure isn't properly identifying that you have xcode installed. This can sometimes happen if you install xcode but have not yet fully opened it (it may ask you to agree to Terms and Conditions before being fully functional). If this is the problem, you'll need to bazel clean --expunge again after that...
If this doesn't help, you can get some debug information to identify what's gone wrong, by invoking (after a failed build):
cat $(bazel info output_base)/external/local_config_xcode/BUILD
This should contain some comments pertaining to failures in finding your installed xcodes.
For me it was a licensing issue for xcodebuild. After running
bazel clean --expunge
I've tried to run again bazel and I've got the instruction to run
sudo xcodebuild -license.
I have executed, accepted the license terms, run again
bazel clean --expunge
and everything has started to work again.
Hopefully it solves some of the cases.
In order to build objc, Bazel requires that you specify an xcode version - this is usually done automatically by xcode_configure. If that's not working, you can manually specify the xcode version on the command line using the --xcode_version flag.
This first time for me to install Tensorflow. I followed the instructions on official website here. I installed from source because I found some people advice to do that instead of pip installation. I used version r0.9 of tensorflow and I installed it on Ubuntu-mate 15.10. I followed all instructions. Installed python, cuda version 7.5, cudnn release 5. Nvidia GPU 5200 with compute capability of 2.1. Every thing went well until I reached bazel build step here,
Latitude-E6430:~/tensorflow$ bazel build -c opt --config=cuda //tensorflow/cc:tutorials_example_trainer
"Latetude-E6430" is the user of the machine.
I got the following errors immediately:
ERROR: /home/meqdad/tensorflow/tensorflow/core/BUILD:91:1: //tensorflow/core:protos_all_py: no such attribute 'imports' in 'py_library' rule.
ERROR: /home/meqdad/tensorflow/tensorflow/cc/BUILD:28:1: Target '//tensorflow/core:sparse_ops_op_lib' contains an error and its package is in error and referenced by '//tensorflow/cc:ops/sparse_ops_gen_cc'.
ERROR: Loading failed; build aborted.
I tried to find a solution to this problem, I was using bazel 0.1 then I upgraded to bazel 0.3. However, on the net, there is several issues like this one but non of them was related to this one. I re-installed py_library but it did nothing to solve the problem.
Please can you advice me how to move on with this step of installation.