Skip to content

Instantly share code, notes, and snippets.

@chiragjn
Last active September 6, 2021 00:29
Show Gist options
  • Save chiragjn/ea47c10fe55ade94d882ae7d248f0ac7 to your computer and use it in GitHub Desktop.
Save chiragjn/ea47c10fe55ade94d882ae7d248f0ac7 to your computer and use it in GitHub Desktop.
Compile tensorflow 2.6.0 against cuda 10.1

Run dev container

docker run --gpus all -itd --name tf_cu101_build tensorflow/tensorflow:latest-devel-gpu-py3

Inside it

Update deps

apt update
apt install cuda-nvprune-10-1
pip install -U numpy==1.19.2 pip six==1.15.0

Set env

export TMP=/tmp
export TF_NEED_TENSORRT=0

Update bazel

cd "/usr/local/lib/bazel/bin" && curl -LO https://releases.bazel.build/3.7.2/release/bazel-3.7.2-linux-x86_64 && chmod +x bazel-3.7.2-linux-x86_64

Clone source

cd ~
mkdir dist
git clone https://github.com/tensorflow/tensorflow
cd tensorflow/
git checkout r2.6

Configure it

bazel clean
./configure

Build

bazel build --verbose_failures --config=cuda --config=mkl --config=avx_linux --config=avx2_linux --config=opt //tensorflow/tools/pip_package:build_pip_package

Make pip package

./bazel-bin/tensorflow/tools/pip_package/build_pip_package /root/dist

copy out the package to host from /root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment