Build procedure for TensorFlow 2.4.0 (Windows10, CUDA11.1.1, cuDNN 8.0.5, Python 3.8.6)

I will leave an overview of how to build TensorFlow 2.4.0 as of December 17, 2020.

If Numpy is the latest 1.19.4, an error will occur just by importing it in the Windows environment, so use the previous 1.19.3. (This is a problem on the Windows side, and it seems that it will be fixed around January 2021)

Environmental information

This is the environment used for the build. It is in a state where the path is passed in advance, such as the CUDA and cuDNN folders.

Folder structure for build, etc.

This time, the TensorFlow source code is downloaded and built under the S: \ build \ build_tf240 folder. A Python virtual environment is also prepared for the TensorFlow build.

S:/build/build_tf240  #Working folder Root
 + tensorflow  #Source code obtained by git
 + venv        #Python virtual environment
 + wheelhouse  #Folder to store the created whl file

Build procedure

Start x64 Native Tools Command Prompt for VS 2019 and follow the steps below to build.

#Create and activate a virtual environment
python -m venv s:\build\build_tf240\venv
cd /d s:\build\build_tf240
.\venv\Scripts\activate.bat

#Installation of required packages
#Note: Numpy is the latest 1.19.If you use 4, you will get an error, so 1.19.Use 3 (Numpy 1 when using).19.Use 3)
python -m pip install --upgrade pip setuptools
pip install numpy==1.19.3
pip install six wheel
pip install keras_applications==1.0.8 --no-deps
pip install keras_preprocessing==1.1.2 --no-deps

#Source code acquisition (v2.4.0 tag specification)
git clone -b v2.4.0 https://github.com/tensorflow/tensorflow.git
cd tensorflow

#In some environments, command parameters become too long and an error occurs, so delete unnecessary environment variables.
set _OLD_VIRTUAL_PATH=

#Build configuration settings
# CUDA support: Y
# CUDA compute capabilities: 7.5 (Change according to the usage environment)
# Optimization: /arch:AVX2 (changed according to usage environment)
#Other than that, the default setting (Enter)
python ./configure.py

#Build
# TensorFlow 2.3.x+In the case of CUDA11, "DTHRUST_IGNORE_CUB_VERSION_I needed the magic of "CHECK" (skipping the CUB compatibility check), but 2.4.x is unnecessary
bazel build --config=opt --config=avx2_win --config=short_logs --config=cuda --define=no_tensorflow_py_deps=true --copt=-nvcc_options=disable-warnings //tensorflow/tools/pip_package:build_pip_package

#Create package (create package in wheelhouse folder)
#I'm worried that the screen won't refresh for a few minutes, but it's being processed properly so let's wait for a while.
bazel-bin\tensorflow\tools\pip_package\build_pip_package ..\wheelhouse

That's it. The bazel intermediate files used for the build are created in the % UserProfile% \ _bazel_% UserName% folder, and the capacity is close to 20GB, so you can delete them if you don't need them. If Bazel is running, you cannot delete it. In that case, use bazel shutdown at the command prompt, exit Bazel, and then delete it.

When using the created TensorFlow wheel package, it is recommended to install Numpy by version specification before TensorFlow with the feeling of pip install numpy == 1.19.3. The latest Numpy 1.19.4 is not available as of 12/17/2020.

Recommended Posts

Build procedure for TensorFlow 2.4.0 (Windows10, CUDA11.1.1, cuDNN 8.0.5, Python 3.8.6)
Build procedure of TensorFlow 2.2.0-rc0 (CUDA10.2 + cuDNN7.6.5) --Windows10
How to force build TensorFlow 2.3.0 for CUDA11 + cuDNN8
Python 3.6 installation procedure [for Windows]
Python project environment construction procedure (for windows)
Build TensorFlow on Windows
Installing TensorFlow on Windows Easy for Python beginners
Install Python (for Windows)
Steps to build PyTorch 1.5 for CUDA 10.2 on Windows
Build a Python extension for E-Cell 4 on Windows 7 (64bit)
Procedure for building a CDK environment on Windows (Python)
Installation notes for TensorFlow for Windows
Build Python environment on Windows
Build python environment on windows
Install dlib for Python (Windows)
Build Python3 for Windows 10 on ARM with Visual Studio 2019 (x86) on Windows 10 on ARM
Install CUDA10.1 + cuDNN7.6.5 + tensorflow-2.3.0 on Ubuntu 18.04
Build mlpy with python3.3 (64bit) (windows 64bit)
Python3 TensorFlow for Mac environment construction
Notes for using OpenCV on Windows10 Python 3.8.3.
Python 2.7, 3.4, 3.5 extension module build environment on Windows
[50 counts] Key transmission using Python for Windows
How to update to Chainer 2.0 (Windows + CUDA 8.0 + CUDNN)
"Python AI programming" starting from 0 for windows
WSL2 (Windows Subsystem for Linux) installation procedure
Quickly build a python environment for deep learning and data science (Windows)
Build python 1.0
Build a local development environment with WSL + Docker Desktop for Windows + docker-lambda + Python
(Windows) Causes and workarounds for UnicodeEncodeError on Python 3
Simply build a Python 3 execution environment on Windows
Procedure for creating a LineBot made with Python
Installed because Tensorflow has native support for Windows
Image Processing with Python Environment Setup for Windows
Procedure for creating a Python quarantine environment (venv environment)
Try using tensorflow ① Build python environment and introduce tensorflow
Notes for using TensorFlow on Bash on Ubuntu on Windows
2016-10-30 else for Python3> for:
python [for myself]
Python on Windows
python windows environment
Python installation (Windows)
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Build an interactive environment for machine learning in Python
Build a python environment for each directory with pyenv-virtualenv
Summary of tools for operating Windows GUI with Python
[Python] Local → Procedure for uploading files to S3 (boto3)
U ^ 2-Net for detecting objects of interest (Windows10, Python3.6)
Build a GVim-based Python development environment on Windows 10 (1) Installation
PIL with Python on Windows 8 (for Google App Engine)
How to build a development environment for TensorFlow (1.0.0) (Mac)
Let's Deep Learning on Windows! (VS2013 + caffe + CUDA7.5 + cudnn5.1)
For those who can't install Python on Windows XP