Last active
February 26, 2019 00:24
-
-
Save constantlycoding/8d30936af2e2c098af6d877151576933 to your computer and use it in GitHub Desktop.
Building TensorFlow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Install Chocolatey | |
| # Install CUDA Toolkit 10.0 | |
| # Install cuDNN | |
| # Install Visual Studio Build Tools (C++) | |
| # Include VC++ 2015.3 v14.00 (v140) toolset for desktop | |
| # Install Miniconda | |
| cinst miniconda3 --params "/AddToPath:1" -y | |
| # Create Python environment | |
| conda create -n tensorflow_build python=3.6 --yes | |
| conda activate tensorflow_build | |
| # Install packages | |
| conda install six numpy wheel --yes | |
| pip install keras_applications==1.0.6 --no-deps | |
| pip install keras_preprocessing==1.0.5 --no-deps | |
| # Install Bazel (installs MSYS2) | |
| cinst bazel --version 0.19.0 -y | |
| # In MSYS2 bash | |
| # Synchronize packages, | |
| # download a fresh copy of the master package database from the server | |
| # upgrades all packages that are out-of-date | |
| pacman -Syu | |
| # Install patch and unzip | |
| pacman -S patch unzip | |
| # Install Git | |
| cinst git --params "/SChannel" -y | |
| # Download source | |
| git clone https://github.com/tensorflow/tensorflow.git | |
| cd tensorflow | |
| git checkout v1.12.0 | |
| # Patch eigen | |
| third_party: | |
| Add eigen_half.patch file | |
| tensorflow/workspace.bzl: | |
| ... | |
| tf_http_archive( | |
| name = "eigen_archive", | |
| build_file = clean_dep("//third_party:eigen.BUILD"), | |
| sha256 = "d956415d784fa4e42b6a2a45c32556d6aec9d0a3d8ef48baee2522ab762556a9", | |
| strip_prefix = "eigen-eigen-fd6845384b86", | |
| urls = [ | |
| "https://mirror.bazel.build/bitbucket.org/eigen/eigen/get/fd6845384b86.tar.gz", | |
| "https://bitbucket.org/eigen/eigen/get/fd6845384b86.tar.gz", | |
| ], | |
| patch_file = clean_dep("//third_party:eigen_half.patch"), # add this line | |
| ) | |
| ... | |
| # Configure | |
| python configure.py | |
| You have bazel 0.19.0 installed. | |
| Please specify the location of python. [Default is C:\tools\miniconda3\envs\tensorflow_build\python.exe]: | |
| Please input the desired Python library path to use. Default is [C:\tools\miniconda3\envs\tensorflow_build\lib\site-packages] | |
| Do you wish to build TensorFlow with Apache Ignite support? [Y/n]: | |
| Do you wish to build TensorFlow with XLA JIT support? [y/N]: | |
| Do you wish to build TensorFlow with ROCm support? [y/N]: | |
| Do you wish to build TensorFlow with CUDA support? [y/N]: y | |
| Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 9.0]: 10.0 | |
| Please specify the location where CUDA 10.0 toolkit is installed. Refer to README.md for more details. [Default is C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0]: | |
| Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: | |
| Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0]: | |
| Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 3.5,7.0]: 6.1 | |
| Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is /arch:AVX]: /arch:AVX /arch:AVX2 | |
| Would you like to override eigen strong inline for some C++ compilation to reduce the compilation time? [Y/n]: | |
| # Fix Bazel bug | |
| .bazelrc: | |
| import d:/code/python/tensorflow/tools/bazel.rc # add this line | |
| import d:/code/python/tensorflow/.tf_configure.bazelrc | |
| # Set environment variables | |
| set BAZEL_SH=C:\tools\msys64\usr\bin\bash.exe | |
| set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC | |
| # Build | |
| bazel build -c opt --config=opt --verbose_failures --define=no_tensorflow_py_deps=true //tensorflow/tools/pip_package:build_pip_package | |
| bazel-bin\tensorflow\tools\pip_package\build_pip_package tmp\tensorflow_pkg | |
| # Install package | |
| pip install tmp\tensorflow_pkg\tensorflow-1.12.0-cp36-cp36m-win_amd64.whl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment