[PYTHON] How to force build TensorFlow 2.3.0 for CUDA11 + cuDNN8

In order to use GPU with TensorFlow, it is necessary to use compatible versions of CUDA and cuDNN, and as of August 9, 2020, the latest TensorFlow 2.3.0 also supports CUDA 11 and cuDNN 8. Is not ... Therefore, building from source code will fail due to compatibility issues.

… But for those who are using “CUDA 11 + cuDNN 8” and still want to use the GPU with TensorFlow, “force” TensorFlow 2.3.0 to be built for CUDA 11 + cuDNN 8 I will leave the method. Since it is a combination of "normally not supported" versions, there is no guarantee that everything will work properly. It works fine as far as I've tried learning and inferring a simple CNN model, but it's a good idea to keep it experimental. (Temporary measures until official support for CUDA11 + cuDNN8)

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_tf230 folder. A Python virtual environment is also prepared for the TensorFlow build.

S:/build/build_tf230  #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_tf230\venv
cd /d s:\build\build_tf230
.\venv\Scripts\activate.bat

#Installation of required packages
#Note: Latest 1.19.Note that building will fail if you use x-series NumPy
python -m pip install --upgrade pip
pip install numpy==1.18.5
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.3.0 tag specification)
git clone -b v2.3.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

#When using CUDA 11, the following config.An error occurs at the 78th line of h.
# C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include\thrust\system\cuda\config.h
#The compatibility check part of the CUB version, but this check is "THRUST"_IGNORE_CUB_VERSION_You can skip it by defining "CHECK".
#THRUST with bazel parameters_IGNORE_CUB_VERSION_Build TensorFlow with CHECK enabled.
bazel build --config=opt --config=avx2_win --config=short_logs --config=cuda --define=no_tensorflow_py_deps=true --copt=-DTHRUST_IGNORE_CUB_VERSION_CHECK --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 point is to add --copt = -DTHRUST_IGNORE_CUB_VERSION_CHECK to the bazel build parameter to skip the CUDA 11 CUB compatibility check.

Recommended Posts

How to force build TensorFlow 2.3.0 for CUDA11 + cuDNN8
How to build a development environment for TensorFlow (1.0.0) (Mac)
How to update to Chainer 2.0 (Windows + CUDA 8.0 + CUDNN)
Build procedure of TensorFlow 2.2.0-rc0 (CUDA10.2 + cuDNN7.6.5) --Windows10
[TF] How to build Tensorflow in Proxy environment
Steps to build PyTorch 1.5 for CUDA 10.2 on Windows
How to learn TensorFlow for liberal arts and Python beginners
Install CUDA10.1 + cuDNN7.6.5 + tensorflow-2.3.0 on Ubuntu 18.04
[For non-programmers] How to walk Kaggle
How to install TensorFlow on CentOS 7
How to install CUDA and nvidia-driver
How to convert Tensorflow model to Lite
How to build MongoDB C driver
How to run TensorFlow 1.0 code in 2.0
How to build my own Linux server
How to build a sphinx translation environment
How to install DLIB with 2020 / CUDA enabled
How to build Hello, World on #Nix
[Python] Organizing how to use for statements
How to install Windows Subsystem For Linux
How to use Pylint for PyQt5 apps
How to use tensorflow under docker environment
How to use "deque" for Python data
How to use fingerprint authentication for KDE
How to build an environment for using multiple versions of Python on Mac
[Tensorflowjs_converter] How to convert Tensorflow model to Tensorflow.js format
For beginners to build an Anaconda environment. (Memo)
How to use MkDocs for the first time
How to make Spigot plugin (for Java beginners)
[Latest] How to build Java environment on Ubuntu
How to use Template Engine for Network Engineer
How to run CNN in 1 system notation in Tensorflow 2
How to use data analysis tools for beginners
How to write a ShellScript Bash for statement
How to create a shortcut command for LINUX
[ESXi (vCenter)] How to add NIC for CentOS 7.3
[PyTorch] Sample ⑧ ~ How to build a complex model ~
Learn how to inflate images from TensorFlow code
[For beginners] How to study programming Private memo
How to find the correlation for categorical variables
How to set CPU affinity for process threads
How to check for missing values (Kaggle: House Prices)
How to build two CentOS7 environments / Windows10 + VirtualBox + Vagrant
[BigQuery] How to use BigQuery API for Python -Table creation-
[For beginners] How to use say command in python!
[For beginners] How to study Python3 data analysis exam
How to run python in virtual space (for MacOS)
[Go] How to create a custom error for Sentry
How to use TensorFlow on GPUs less than Titan
How to make unit tests Part.2 Class design for tests
How to share folders with Docker and Windows with tensorflow
How to build a Django (python) environment on docker
I thought about how to learn programming for free.
How to create a local repository for Linux OS
How to (force) pdf conversion of IPython Notebook slides
Python # How to check type and type for super beginners
How to build a Python environment on amazon linux 2
Compare how to write processing for lists by language
[Introduction to Python] How to write repetitive statements using for statements
[How to!] Learn and play Super Mario with Tensorflow !!
[TF] How to save and load Tensorflow learning parameters