Skip to content

Commit

Permalink
Release tf_gpu_cuda12.6_cudnn9.4_avx2_mkl_trt10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
agkphysics committed Sep 29, 2024
1 parent fba0310 commit 3f56e9a
Show file tree
Hide file tree
Showing 12 changed files with 6,210 additions and 123 deletions.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ optimised TensorFlow wheel with TensorRT support.

Each release page also has the checksums of the attached files.

## `manylinux_2_28_x86_64` wheels
The following wheels were compiles in the `manylinux_2_28_x86_64`
container described below. These are required to have more recent CUDA
compatibility since Nvidia stopped releasing updates for CentOS 7 based
releases.

| TF | Python | GPU | CUDA | cuDNN | AVX2 | MKL/oneDNN | TensorRT | Links |
|-|-|-|-|-|-|-|-|-|
| 2.16.2 | 3.9-3.12 | 5.2-9.0 | 12.6 | 9.4 | :heavy_check_mark: | :heavy_check_mark: | 10.4 | [Release](https://github.com/agkphysics/tensorflow-wheels/releases/tag/tf_gpu_cuda12.6_cudnn9.4_avx2_mkl_trt10.4) |

## `manylinux2014_x86_64` wheels
The following wheels were compiled in the `manylinux2014_x86_64`
container described below. These should have better glibc
Expand Down Expand Up @@ -39,31 +49,32 @@ The following wheels were compiled on an Ubuntu 20.04 system
| 1.15.0 | 3.8 | 7.x | 10.2 | 7 | :heavy_check_mark: | :heavy_check_mark: | 6 | [Release](https://github.com/agkphysics/tensorflow-wheels/releases/tag/tf_1.15.0_gpu_cm7x_cuda102_cudnn7_avx2_mkl_trt6) |
| 1.14.1 | 3.8 | 7.x | 10.2 | 7 | :heavy_check_mark: | :heavy_check_mark: | 6 | [Release](https://github.com/agkphysics/tensorflow-wheels/releases/tag/tf_1.14.1_gpu_cm7x_cuda102_cudnn7_avx2_mkl_trt6) |

## `manylinux2014_x86_64` Docker container
The [Dockerfile](./docker/Dockerfile) is based on `manylinux2014_x86_64`
and can be built with the following command, from within the `docker/`
directory:
## Docker containers
The Dockerfiles under `docker/` are based on `manylinux*` and can be
built with the following command, from within the `docker/` directory:
```
docker build -t tf_build .
docker build -t tf_build -f Dockerfile.<manylinux_ver> .
```
The container can be run like so:
The container can then be run like so:
```
docker run --gpus all -it --rm --tmpfs /tmp:exec -v /path/to/tensorflow:/build -u $(id -u):$(id -g) -e USER=$(id -u) tf_build
```

Then, you can run the build script:
```
cd /path/to/tensorflow
bash build-tf2-gpu-avx2-mkl.sh -p 11
bash build-tf2-gpu-avx2-mkl.sh -p 12
```

The other scripts assume a directory structure as follows:
```
.../
tensorflow/
build-tf2-gpu-avx2-mkl.sh
keras/
build-keras.sh
text/
build-text.sh
io/
build-io.sh
wheels/
tensorflow/
*.whl
Expand Down
60 changes: 60 additions & 0 deletions build-io.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/sh

set -e

usage() {
echo "Usage: $0 -p <py3_ver> -t <tf_ver>"
echo " -p <py3_ver> Python version to use (6-12)"
echo " -t <tf_ver> TensorFlow version to use (2.3.0, 2.4.0, etc.)"
}

if [ $# -lt 4 ]; then
usage
exit
fi

while getopts "ht:p:" opt; do
case $opt in
p)
py3_ver=$OPTARG
;;
t)
tf_ver=$OPTARG
;;
h)
usage
exit
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit
;;
esac
done
if [ "$py3_ver" -lt 6 ] || [ "$py3_ver" -gt 12 ]; then
echo "Python version must be between 6 and 12"
usage
exit
fi

rm -rf venvs
python3.$py3_ver -m venv venvs/py3$py3_ver
. venvs/py3${py3_ver}/bin/activate

# Get most recent wheel
tf_wheel=$(ls ../wheels/tensorflow/tensorflow-${tf_ver}-cp3${py3_ver}-*-linux_x86_64.whl)
echo "Installing TensorFlow wheel $tf_wheel"
pip install -q "$tf_wheel"
pip uninstall -q -y tensorflow-io tensorflow-io-gcs-filesystem

bazel clean --expunge
python tools/build/configure.py
bazel build --config=linux --config=optimization --copt="-mavx" --copt="-mavx2" --copt="-Wno-error=dangling-pointer=" --copt="-Wno-error=array-bounds=" --copt="-Wno-error=array-parameter=" --copt="-I/usr/include/tirpc" //tensorflow_io/... //tensorflow_io_gcs_filesystem/...
python setup.py bdist_wheel --data bazel-bin --project tensorflow-io
python setup.py bdist_wheel --data bazel-bin --project tensorflow-io-gcs-filesystem
mv dist/tensorflow_io*.whl ../wheels/io
bazel clean --expunge

deactivate
rm -rf venvs
57 changes: 0 additions & 57 deletions build-keras.sh

This file was deleted.

57 changes: 57 additions & 0 deletions build-text.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh

set -e

usage() {
echo "Usage: $0 -p <py3_ver> -t <tf_ver>"
echo " -p <py3_ver> Python version to use (6-12)"
echo " -t <tf_ver> TensorFlow version to use (2.3.0, 2.4.0, etc.)"
}

if [ $# -lt 4 ]; then
usage
exit
fi

while getopts "ht:p:" opt; do
case $opt in
p)
py3_ver=$OPTARG
;;
t)
tf_ver=$OPTARG
;;
h)
usage
exit
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit
;;
esac
done
if [ "$py3_ver" -lt 6 ] || [ "$py3_ver" -gt 12 ]; then
echo "Python version must be between 6 and 12"
usage
exit
fi

rm -rf venvs
python3.$py3_ver -m venv venvs/py3$py3_ver
. venvs/py3${py3_ver}/bin/activate

# Get most recent wheel
tf_wheel=$(ls ../wheels/tensorflow/tensorflow-${tf_ver}-cp3${py3_ver}-*-linux_x86_64.whl)
echo "Installing TensorFlow wheel $tf_wheel"
pip install -q --ignore-requires-python "$tf_wheel"
pip uninstall -q -y tensorflow-text

bazel clean --expunge
./oss_scripts/run_build.sh
mv tensorflow_text-*.whl ../wheels/text
bazel clean --expunge

deactivate
rm -rf venvs
52 changes: 32 additions & 20 deletions build-tf2-gpu-avx2-mkl.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
#!/bin/sh
#!/bin/bash

set -e

usage() {
echo "Usage: $0 -p <py3_ver> [-b]"
echo " -p <py3_ver> Python version to use (6-11)"
echo " -b Warm build (don't clean)"
echo " -p Python version to use (8-12)"
echo " -b Warm build (don't clean)"
echo " -d Debug mode"
}

if [ $# -lt 2 ]; then
usage
exit
fi

while getopts "hbp:" opt; do
while getopts "hbdp:" opt; do
case $opt in
p)
py3_ver=$OPTARG
;;
b)
warm_build=1
;;
d)
debug_mode=1
;;
h)
usage
exit
Expand All @@ -32,31 +36,24 @@ while getopts "hbp:" opt; do
;;
esac
done
if [ "$py3_ver" -lt 6 ] || [ "$py3_ver" -gt 11 ]; then
echo "Python version must be between 6 and 11"
if [ "$py3_ver" -lt 8 ] || [ "$py3_ver" -gt 12 ]; then
echo "Python version must be between 6 and 12"
usage
exit
fi

echo "Using Python 3.$py3_ver environment"
if [ "$warm_build" = 1 ]; then
source venvs/py3${py3_ver}/bin/activate
else
rm -rf venvs
python3.${py3_ver} -m venv venvs/py3${py3_ver}
source venvs/py3${py3_ver}/bin/activate
pip install -q -r py_build_reqs.txt
_tag=$(git describe --tags)
tf_ver=$(echo "$_tag" | sed -n -E -e 's/^v2\.([0-9]+).*/\1/p')
if [ "$tf_ver" = "7" ]; then
pip install -q keras-preprocessing
fi
fi

PYTHON_BIN_PATH=$(which python)
export PYTHON_BIN_PATH
export USE_DEFAULT_PYTHON_LIB_PATH=1
export TF_NEED_JEMALLOC=1
export TF_NEED_KAFKA=0
export TF_NEED_KAFKA=1
export TF_NEED_OPENCL_SYCL=0
export TF_NEED_OPENCL=0
export TF_NEED_AWS=1
Expand All @@ -68,15 +65,19 @@ export TF_NEED_GDR=0
export TF_NEED_VERBS=0
export TF_NEED_MPI=0
export TF_NEED_TENSORRT=1
_tensorrt_maj=$(sed -n -E -e 's/^#define NV_TENSORRT_MAJOR\s+([0-9]+).*/\1/p' /usr/include/NvInferVersion.h)
_tensorrt_min=$(sed -n -E -e 's/^#define NV_TENSORRT_MINOR\s+([0-9]+).*/\1/p' /usr/include/NvInferVersion.h)
export TF_TENSORRT_VERSION=${_tensorrt_maj}.${_tensorrt_min}
export TF_NEED_NGRAPH=0
export TF_NEED_IGNITE=0
export TF_NEED_ROCM=0
export TF_NEED_CLANG=1
export CLANG_COMPILER_PATH=/usr/bin/clang
export TF_SET_ANDROID_WORKSPACE=0
export TF_DOWNLOAD_CLANG=0
_nccl_maj=$(sed -n -E -e 's/^#define NCCL_MAJOR\s*(.*).*/\1/p' /usr/include/nccl.h)
_nccl_min=$(sed -n -E -e 's/^#define NCCL_MINOR\s*(.*).*/\1/p' /usr/include/nccl.h)
_nccl_maj=$(sed -n -E -e 's/^#define NCCL_MAJOR\s+([0-9]+).*/\1/p' /usr/include/nccl.h)
_nccl_min=$(sed -n -E -e 's/^#define NCCL_MINOR\s+([0-9]+).*/\1/p' /usr/include/nccl.h)
export TF_NCCL_VERSION="${_nccl_maj}.${_nccl_min}"
export TF_IGNORE_MAX_BAZEL_VERSION=1
export NCCL_INSTALL_PATH=/usr
GCC_HOST_COMPILER_PATH=$(which gcc)
export GCC_HOST_COMPILER_PATH
Expand All @@ -93,13 +94,24 @@ export TF_CUDA_VERSION
TF_CUDNN_VERSION=$(sed -n -E -e 's/^#define CUDNN_MAJOR\s*(.*).*/\1/p' /usr/include/cudnn_version.h)
export TF_CUDNN_VERSION
export TF_CUDA_COMPUTE_CAPABILITIES=sm_52,sm_53,sm_60,sm_61,sm_62,sm_70,sm_72,sm_75,sm_80,sm_86,sm_87,sm_89,sm_90,compute_90
export CC_OPT_FLAGS="-march=haswell -O3"
export TF_PYTHON_VERSION=3.${py3_ver}
echo "TF_PYTHON_VERSION=$TF_PYTHON_VERSION"
PYTHON_BIN_PATH=$(which python)
export PYTHON_BIN_PATH
echo "PYTHON_BIN_PATH=$PYTHON_BIN_PATH"
export USE_DEFAULT_PYTHON_LIB_PATH=1
export CC_OPT_FLAGS="-march=haswell -mavx2 -O3"

echo $(python --version)

if [ "$warm_build" != 1 ]; then
bazel clean --expunge
fi
if [ "$debug_mode" = 1 ]; then
bazel_opts=(-s)
fi
./configure
bazel build --config=mkl --config=avx2_linux -c opt //tensorflow/tools/pip_package:build_pip_package
bazel build "${bazel_opts[@]}" --verbose_failures --config=avx_linux -c opt //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package ../wheels/tensorflow

if [ "$warm_build" != 1 ]; then
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile → docker/Dockerfile.manylinux2014_x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ FROM quay.io/pypa/manylinux2014_x86_64

RUN yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo \
&& yum clean all \
&& yum -y install cuda-12-2 libcudnn8-devel tensorrt-devel libnccl-devel
&& yum -y install cuda-12-4 libcudnn9-devel tensorrt-devel libnccl-devel
ENV PATH=/usr/local/cuda/bin:$PATH
RUN curl -L "https://github.com/bazelbuild/bazelisk/releases/download/v1.18.0/bazelisk-linux-amd64" -o /usr/local/bin/bazel \
RUN curl -L "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64" -o /usr/local/bin/bazel \
&& chmod +x /usr/local/bin/bazel \
&& echo "startup --output_user_root=/tmp/bazel" > /etc/bazel.bazelrc
ENV BAZELISK_HOME=/tmp/bazelisk USER=build
Expand Down
12 changes: 12 additions & 0 deletions docker/Dockerfile.manylinux_2_28_x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM quay.io/pypa/manylinux_2_28_x86_64

RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo \
&& dnf clean all \
&& dnf -y install cuda-toolkit-12-6 libcudnn9-devel tensorrt-devel libnccl-devel clang libtirpc-devel
RUN curl -L "https://github.com/bazelbuild/bazelisk/releases/download/v1.21.0/bazelisk-linux-amd64" -o /usr/local/bin/bazel \
&& chmod +x /usr/local/bin/bazel \
&& echo "startup --output_user_root=/tmp/bazel" > /etc/bazel.bazelrc
ENV BAZELISK_HOME=/tmp/bazelisk USER=build

WORKDIR /build
CMD ["/bin/bash"]
Loading

0 comments on commit 3f56e9a

Please sign in to comment.