Skip to content

Commit

Permalink
Move gpu docker build clang.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 615609135
  • Loading branch information
gharibian authored and tensorflow-copybara committed Mar 14, 2024
1 parent b6247c8 commit 611c5a9
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 22 deletions.
19 changes: 17 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,23 @@ build:release --copt=-msse4.2
build:cuda --repo_env TF_NEED_CUDA=1
build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain
build:cuda --@local_config_cuda//:enable_cuda
build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true
build:cuda --action_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_35,sm_50,sm_60,sm_70,sm_75,compute_80"

# Options used to build with CUDA clang
build:cuda_clang --config=cuda
build:cuda_clang --copt=-Wno-gnu-offsetof-extensions
build:cuda_clang --copt=-Wno-error=unused-command-line-argument
build:cuda_clang --host_copt=-Wno-error=unused-command-line-argument
build:cuda_clang --repo_env TF_NEED_TENSORRT=1
build:cuda_clang --action_env=TF_CUDA_CLANG="1"
build:cuda_clang --@local_config_cuda//:cuda_compiler=clang
build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_50,sm_60,sm_70,sm_80,compute_90"

build:cuda_clang --action_env=TF_CUDA_VERSION="12"
build:cuda_clang --action_env=TF_CUDNN_VERSION="8"
build:cuda_clang --action_env=CUDA_TOOLKIT_PATH="/usr/local/cuda-12.2"
build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/dt9/usr/bin/gcc"
build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang"
build:cuda_clang --action_env=LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"

# Options used to build with TPU support.
build:tpu --define=with_tpu_support=true --define=framework_shared_object=false
Expand Down
34 changes: 14 additions & 20 deletions tensorflow_serving/tools/docker/Dockerfile.devel-gpu
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ LABEL tensorflow_serving_github_branchtag=${TF_SERVING_VERSION_GIT_BRANCH}
LABEL tensorflow_serving_github_commit=${TF_SERVING_VERSION_GIT_COMMIT}

ENV CUDNN_VERSION=8.9.4.25
ENV TF_TENSORRT_VERSION=8.6.1.6
ENV TF_TENSORRT_VERSION=8.6.1
ENV CUDA=12.2

RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub && \
apt-get update && apt-get install -y --no-install-recommends \
COPY setup.sources.sh /setup.sources.sh
RUN /setup.sources.sh

RUN apt-get update && apt-get install -y --no-install-recommends \
automake \
build-essential \
ca-certificates \
Expand All @@ -43,6 +45,9 @@ RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/
libcurand-dev-12-2 \
libcusolver-dev-12-2 \
libcusparse-dev-12-2 \
clang-17 \
llvm-17 \
lld-17 \
curl \
git \
libfreetype6-dev \
Expand All @@ -66,16 +71,11 @@ RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/
python-distutils-extra && \
find /usr/local/cuda-12.2/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete

RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64/7fa2af80.pub && \
echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64 /" > /etc/apt/sources.list.d/tensorRT.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
libnvinfer8=${TF_TENSORRT_VERSION}-1+cuda12.0 \
libnvinfer-dev=${TF_TENSORRT_VERSION}-1+cuda12.0 \
libnvinfer-plugin-dev=${TF_TENSORRT_VERSION}-1+cuda12.0 \
libnvinfer-plugin8=${TF_TENSORRT_VERSION}-1+cuda12.0 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*;
RUN apt-get install -y --no-install-recommends \
libnvinfer-plugin8=8.6.1.6-1+cuda12.0 \
libnvinfer8=8.6.1.6-1+cuda12.0 \
libnvinfer-dev=8.6.1.6-1+cuda12.0 \
libnvinfer-plugin-dev=8.6.1.6-1+cuda12.0

# Install python 3.9.
RUN add-apt-repository ppa:deadsnakes/ppa && \
Expand Down Expand Up @@ -121,12 +121,6 @@ RUN mkdir /bazel && \
ENV CI_BUILD_PYTHON python
ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs:/usr/include/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH

ENV TF_NEED_CUDA 1
ENV TF_NEED_TENSORRT 1
ENV TENSORRT_INSTALL_PATH=/usr/lib/x86_64-linux-gnu
ENV TF_CUDA_VERSION=12.2
ENV TF_CUDNN_VERSION=8

# Fix paths so that CUDNN can be found: https://github.com/tensorflow/tensorflow/issues/8264
WORKDIR /
RUN mkdir /usr/lib/x86_64-linux-gnu/include/ && \
Expand Down Expand Up @@ -154,7 +148,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}"

RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \
bazel build --color=yes --curses=yes --config=cuda --copt="-fPIC"\
bazel build --color=yes --curses=yes --config=cuda_clang --copt="-fPIC"\
${TF_SERVING_BAZEL_OPTIONS} \
--verbose_failures \
--output_filter=DONT_MATCH_ANYTHING \
Expand Down
52 changes: 52 additions & 0 deletions tensorflow_serving/tools/docker/setup.sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

# Sets up custom apt sources for our TF serving images.

# Prevent apt install tzinfo from asking our location (assumes UTC)
export DEBIAN_FRONTEND=noninteractive

# Set up shared custom sources
apt-get update
apt-get install -y gnupg ca-certificates

# Deadsnakes: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F23C5A6CF475977595C89F51BA6932366A755776

# Explicitly request Nvidia repo keys
# See: https://forums.developer.nvidia.com/t/invalid-public-key-for-cuda-apt-repository/212901/11
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub

# LLVM/Clang: https://apt.llvm.org/
apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key

# Set up custom sources
cat >/etc/apt/sources.list.d/custom.list <<SOURCES
# Nvidia CUDA packages: 18.04 has more available than 20.04, and we use those
deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /
# More Python versions: Deadsnakes
deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main
deb-src http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main
# LLVM/Clang repository
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
SOURCES

apt-get update

0 comments on commit 611c5a9

Please sign in to comment.