forked from ROCm/tensorflow-upstream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_rocm_python3
More file actions
executable file
·73 lines (66 loc) · 2.5 KB
/
build_rocm_python3
File metadata and controls
executable file
·73 lines (66 loc) · 2.5 KB
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
#!/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-5.7.0
if [[ -n $1 ]]; then
ROCM_INSTALL_DIR=$1
fi
ROCM_PATH=$ROCM_INSTALL_DIR
# Explicitly delete the old whl packages in the /tmp/tensorflow_pkg dir
# Doing so comes in handy when the TF version number changes, because
# it will cause the last line in this script (pip3 install ...) to fail.
# Not deleting the old whl packages results in the last line installing
# TF from the previous whl pakcage (if present) and not the current one
# that was just built by this script. Since this error is not apparent, it
# can lead to a lot of frustation and lost time trying to figure why the
# changes made in the current build are not working!
TF_PKG_LOC=/tmp/tensorflow_pkg
if [[ -n $nightly ]]; then
rm -f $TF_PKG_LOC/tf_nightly_rocm*.whl
else
rm -f $TF_PKG_LOC/tensorflow*.whl
fi
PYTHON_VERSION=`python3 -c "import sys;print(f'{sys.version_info.major}.{sys.version_info.minor}')"`
export TF_PYTHON_VERSION=$PYTHON_VERSION
yes "" | TF_NEED_CLANG=0 ROCM_PATH=$ROCM_INSTALL_DIR TF_NEED_ROCM=1 PYTHON_BIN_PATH=/usr/bin/python3 ./configure
# 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 [[ -n $nightly ]]; then
bazel build $RESOURCE_OPTION --config=opt --config=rocm //tensorflow/tools/pip_package:build_pip_package --verbose_failures &&
bazel-bin/tensorflow/tools/pip_package/build_pip_package $TF_PKG_LOC --rocm --nightly_flag &&
pip3 install --upgrade $TF_PKG_LOC/tf_nightly_rocm*.whl
else
bazel build $RESOURCE_OPTION --config=opt --config=rocm //tensorflow/tools/pip_package:build_pip_package --verbose_failures &&
bazel-bin/tensorflow/tools/pip_package/build_pip_package $TF_PKG_LOC --rocm &&
pip3 install --upgrade $TF_PKG_LOC/tensorflow*.whl
fi