xref: /aosp_15_r20/external/pytorch/.ci/docker/common/install_protobuf.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1#!/bin/bash
2
3set -ex
4
5pb_dir="/usr/temp_pb_install_dir"
6mkdir -p $pb_dir
7
8# On the nvidia/cuda:9-cudnn7-devel-centos7 image we need this symlink or
9# else it will fail with
10#   g++: error: ./../lib64/crti.o: No such file or directory
11ln -s /usr/lib64 "$pb_dir/lib64"
12
13curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz" --retry 3
14
15tar -xvz --no-same-owner -C "$pb_dir" --strip-components 1 -f protobuf-all-3.17.3.tar.gz
16NPROC=$[$(nproc) - 2]
17pushd "$pb_dir" && ./configure && make -j${NPROC} && make -j${NPROC} check && sudo make -j${NRPOC} install && sudo ldconfig
18popd
19rm -rf $pb_dir
20