Building Tensorflow on Windows is really a tough thing and there should be many problems to solve. Thus, this script automates the process of building on Windows, which does the following things for you:
- Installation of Dependencies
- Management of Environment Variables
- Patching (For more information, view wiki)
This script has tested on v1.12.0 and v1.11.0.
You may need to do some preparations below:
-
If you need to build GPU version, you need to follow this official guide to install GPU support.
-
If you need to build C++ API, you should add symbols that you need into
patches\tf_exported_symbols_msvc.lds. If you don't know what symbols you need, never mind and skip this step. When you use the built C++ API, the linker will probably give you link errors, telling what symbols you need.
- Clone this repository or directly download it.
- Run the script in the repository directory with administrator rights.
.\build.ps1 -BazelBuildParameters <parameter_string> [optional_parameters]
- The output files should be in
source\bazel-binordepsfolder.
-
-BazelBuildParameters <string>MandatoryA string which is passed to Bazel to build Tensorflow.
If you want to build a PyPI wheel, you need
//tensorflow/tools/pip_package:build_pip_package.If you want to build a C API, you need
//tensorflow:libtensorflow.so.If you want to build a C++ API, you need
//tensorflow:libtensorflow_cc.so.For more information, click here.
-
-BuildCppAPIOptionalThis is needed when buiding C++ API.
-
-BuildCppProtoBufOptionalDenote it to build Protocol Buffer when building C++ API.
-
-ReserveSourceOptionalDenote it when you confirm that you have a valid tensorflow repository in
sourcefolder and do not want to re-clone it in the next building. -
-ReserveVenvOptionalDenote it when you confirm that you have a valid virtual environment in
venvfolder and do not recreate one. -
-IgnoreDepsVersionIssuesOptionalDenote it to ignore the warnings due to different versions of dependencies you have installed.
-
-InstallDefaultDepsOptionalInstall default version of dependencies if not installed.
# It is an example for building C++ API with GPU support.
$parameterString = "--config=opt --config=cuda --define=no_tensorflow_py_deps=true --copt=-nvcc_options=disable-warnings //tensorflow:libtensorflow_cc.so --verbose_failures"
.\build.ps1 `
-BazelBuildParameters $parameterString `
-BuildCppAPI -BuildCppProtoBuf -ReserveSource -ReserveVenv- The absolute path of your cloned folder should not contain any special characters. Otherwise, the configure process will raise a
subprocess.CalledProcessError.
- My script is based on Steroes's work.
- My solution to build C++ API library is based on gittyupagain.
These are what I have referenced during contributing to this repo. They are probably useful for you to solve some problems and even get a better idea to build.
- Put latest news on related topics in Wiki together.
- Delete the API which builds protobuf.
- Write an example to use built results.
- Pay continuous attention to new building API on Windows.
Done
- Write a wiki about details of patches.
- Add support for other versions of Tensorflow.
- Check if a specific version of dependency is installed and give a warning if another version of it is installed.
- Refactor the structure of script.
- Change how to process the output files.
- Denote how to solve the symbol problem in C++ API.
- Let user choose what versions of dependencies to install.