@@ -21,3 +21,87 @@ if [[ "${BUILD_ENVIRONMENT}" == *rocm* ]]; then
2121fi
2222
2323mkdir -p "$pytest_reports_dir " || true
24+
25+ ##########################################
26+ # copied from .ci/pytorch/common_utils.sh
27+ ##########################################
28+
29+ function get_pinned_commit() {
30+ cat .github/ci_commit_pins/"${1} ".txt
31+ }
32+
33+ function pip_install_whl() {
34+ # This is used to install PyTorch and other build artifacts wheel locally
35+ # without using any network connection
36+
37+ # Convert the input arguments into an array
38+ local args=("$@ ")
39+
40+ # Check if the first argument contains multiple paths separated by spaces
41+ if [[ "${args[0]} " == * " "* ]]; then
42+ # Split the string by spaces into an array
43+ IFS=' ' read -r -a paths <<< "${args[0]} "
44+ # Loop through each path and install individually
45+ for path in "${paths[@]} "; do
46+ echo "Installing $path "
47+ python3 -mpip install --no-index --no-deps "$path "
48+ done
49+ else
50+ # Loop through each argument and install individually
51+ for path in "${args[@]} "; do
52+ echo "Installing $path "
53+ python3 -mpip install --no-index --no-deps "$path "
54+ done
55+ fi
56+ }
57+
58+ function pip_build_and_install() {
59+ local build_target=$1
60+ local wheel_dir=$2
61+
62+ local found_whl=0
63+ for file in "${wheel_dir} "/* .whl
64+ do
65+ if [[ -f "${file} " ]]; then
66+ found_whl=1
67+ break
68+ fi
69+ done
70+
71+ # Build the wheel if it doesn't exist
72+ if [ "${found_whl} " == "0 " ]; then
73+ python3 -m pip wheel \
74+ --no-build-isolation \
75+ --no-deps \
76+ -w "${wheel_dir} " \
77+ "${build_target} "
78+ fi
79+
80+ for file in "${wheel_dir} "/* .whl
81+ do
82+ pip_install_whl "${file} "
83+ done
84+ }
85+
86+ function install_torchvision() {
87+ local orig_preload
88+ local commit
89+ commit=$(get_pinned_commit vision)
90+ orig_preload=${LD_PRELOAD}
91+ if [ -n "${LD_PRELOAD} " ]; then
92+ # Silence dlerror to work-around glibc ASAN bug, see https://sourceware.org/bugzilla/show_bug.cgi?id=27653 #c9
93+ echo 'char* dlerror(void) { return "";}'|gcc -fpic -shared -o "${HOME} / dlerror.so" - x c -
94+ LD_PRELOAD=${orig_preload} : ${HOME} / dlerror.so
95+ fi
96+
97+ if [[ "${BUILD_ENVIRONMENT} " == * cuda* ]]; then
98+ # Not sure if both are needed, but why not
99+ export FORCE_CUDA=1
100+ export WITH_CUDA=1
101+ fi
102+ pip_build_and_install "git+https://github.com/pytorch/vision.git@${commit} " dist/ vision
103+
104+ if [ -n "${LD_PRELOAD} " ]; then
105+ LD_PRELOAD=${orig_preload}
106+ fi
107+ }
0 commit comments