forked from tensorflow/tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 95
/
build_rocm_python3
executable file
·81 lines (75 loc) · 3.28 KB
/
build_rocm_python3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
#
# prerequisites: install python3
# sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel
#
# configure with python3
# PYTHON_BIN_PATH=/usr/bin/python3 ./configure
#
# press enter all the way
#
while getopts "hrn" opt; do
case ${opt} in
h)
echo "Options:"
echo "-r Use -r to define bazel resource restriction"
exit 0
;;
r)
restriction=true
;;
n)
nightly=true
esac
done
shift "$((OPTIND-1))"
# This is not a release branch, so force a nightly build
# TODO remove this when branching for release
nightly=true
# First positional argument (if any) specifies the ROCM_INSTALL_DIR
ROCM_INSTALL_DIR=/opt/rocm/
if [[ -n $1 ]]; then
ROCM_INSTALL_DIR=$1
fi
ROCM_PATH=$ROCM_INSTALL_DIR
PYTHON_VERSION=`python3 -c "import sys;print(f'{sys.version_info.major}.{sys.version_info.minor}')"`
export TF_PYTHON_VERSION=$PYTHON_VERSION
# Explicitly define resource constraints on bazel to avoid overload on rocm-ci
if [[ -n $restriction ]]; then
RESOURCE_OPTION="--local_ram_resources=60000 --local_cpu_resources=35 --jobs=70"
else
RESOURCE_OPTION=""
fi
if [ -f /usertools/rocm.bazelrc ]; then
# Use the bazelrc files in /usertools if available
TF_PKG_LOC=bazel-bin/tensorflow/tools/pip_package/wheel_house
if [[ -n $nightly ]]; then
# Remove any previous builds and build nightly
rm -f $TF_PKG_LOC/tf_nightly_rocm*.whl
export project_name=tf_nightly_rocm
python3 tensorflow/tools/ci_build/update_version.py --nightly --rocm_version &&
bazel --bazelrc=/usertools/rocm.bazelrc build $RESOURCE_OPTION --config=rocm --repo_env=WHEEL_NAME=tf_nightly_rocm --action_env=project_name=tf_nightly_rocm --action_env=TF_PYTHON_VERSION=$PYTHON_VERSION tensorflow/tools/pip_package:wheel --verbose_failures &&
pip3 install --upgrade $TF_PKG_LOC/tf_nightly_rocm*.whl
else
# Remove any previous builds and build release
rm -f $TF_PKG_LOC/tensorflow*.whl
python3 tensorflow/tools/ci_build/update_version.py --rocm_version &&
bazel --bazelrc=/usertools/rocm.bazelrc build $RESOURCE_OPTION --config=rocm --repo_env=WHEEL_NAME=tensorflow_rocm --action_env=project_name=tensorflow_rocm --action_env=TF_PYTHON_VERSION=$PYTHON_VERSION tensorflow/tools/pip_package:wheel --verbose_failures &&
pip3 install --upgrade $TF_PKG_LOC/tensorflow*.whl
fi
else
# Legacy style: run configure then build
TF_PKG_LOC=bazel-bin/tensorflow/tools/pip_package/wheel_house
yes "" | TF_NEED_CLANG=0 ROCM_PATH=$ROCM_INSTALL_DIR TF_NEED_ROCM=1 PYTHON_BIN_PATH=/usr/bin/python3 ./configure &&
if [[ -n $nightly ]]; then
# Remove any previous builds and build nightly
rm -f $TF_PKG_LOC/tf_nightly_rocm*.whl
bazel build $RESOURCE_OPTION --config=opt --config=rocm --repo_env=WHEEL_NAME=tf_nightly_rocm --action_env=project_name=tf_nightly_rocm //tensorflow/tools/pip_package:wheel --verbose_failures &&
pip3 install --upgrade $TF_PKG_LOC/tf_nightly_rocm*.whl
else
# Remove any previous builds and build release
rm -f $TF_PKG_LOC/tensorflow*.whl
bazel build $RESOURCE_OPTION --config=opt --config=rocm --repo_env=WHEEL_NAME=tensorflow_rocm --action_env=project_name=tensorflow_rocm //tensorflow/tools/pip_package:wheel --verbose_failures &&
pip3 install --upgrade $TF_PKG_LOC/tensorflow*.whl
fi
fi