Skip to content

Commit 3ba8d21

Browse files
authored
Merge branch 'master' into updt_utls
2 parents 341478a + 7cc941f commit 3ba8d21

File tree

15 files changed

+1099
-129
lines changed

15 files changed

+1099
-129
lines changed

.circleci/config.yml

Lines changed: 303 additions & 1 deletion
Large diffs are not rendered by default.

.circleci/config.yml.in

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,67 @@ commands:
4545
our_upload_channel=test
4646
fi
4747
echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}
48+
install_cuda_compatible_cmath:
49+
description: "Install CUDA compatible cmath"
50+
steps:
51+
- run:
52+
name: _HACK_ Install CUDA compatible cmath
53+
no_output_timeout: 1m
54+
command: |
55+
powershell .circleci/scripts/vs_install_cmath.ps1
56+
57+
brew_update:
58+
description: "Update Homebrew and install base formulae"
59+
steps:
60+
- run:
61+
name: Update Homebrew
62+
no_output_timeout: "10m"
63+
command: |
64+
set -ex
65+
66+
# Update repositories manually.
67+
# Running `brew update` produces a comparison between the
68+
# current checkout and the updated checkout, which takes a
69+
# very long time because the existing checkout is 2y old.
70+
for path in $(find /usr/local/Homebrew -type d -name .git)
71+
do
72+
cd $path/..
73+
git fetch --depth=1 origin
74+
git reset --hard origin/master
75+
done
76+
77+
export HOMEBREW_NO_AUTO_UPDATE=1
78+
79+
# Install expect and moreutils so that we can call `unbuffer` and `ts`.
80+
# moreutils installs a `parallel` executable by default, which conflicts
81+
# with the executable from the GNU `parallel`, so we must unlink GNU
82+
# `parallel` first, and relink it afterwards.
83+
brew install coreutils
84+
brew unlink parallel
85+
brew install moreutils
86+
brew link parallel --overwrite
87+
brew install expect
88+
89+
brew_install:
90+
description: "Install Homebrew formulae"
91+
parameters:
92+
formulae:
93+
type: string
94+
default: ""
95+
steps:
96+
- run:
97+
name: Install << parameters.formulae >>
98+
no_output_timeout: "10m"
99+
command: |
100+
set -ex
101+
export HOMEBREW_NO_AUTO_UPDATE=1
102+
brew install << parameters.formulae >>
103+
104+
run_brew_for_ios_build:
105+
steps:
106+
- brew_update
107+
- brew_install:
108+
formulae: libtool
48109

49110
binary_common: &binary_common
50111
parameters:
@@ -83,6 +144,22 @@ binary_common: &binary_common
83144
UNICODE_ABI: << parameters.unicode_abi >>
84145
CU_VERSION: << parameters.cu_version >>
85146

147+
torchvision_ios_params: &torchvision_ios_params
148+
parameters:
149+
build_environment:
150+
type: string
151+
default: ""
152+
ios_arch:
153+
type: string
154+
default: ""
155+
ios_platform:
156+
type: string
157+
default: ""
158+
environment:
159+
BUILD_ENVIRONMENT: << parameters.build_environment >>
160+
IOS_ARCH: << parameters.ios_arch >>
161+
IOS_PLATFORM: << parameters.ios_platform >>
162+
86163
smoke_test_common: &smoke_test_common
87164
<<: *binary_common
88165
docker:
@@ -212,6 +289,7 @@ jobs:
212289
steps:
213290
- checkout_merge
214291
- designate_upload_channel
292+
- install_cuda_compatible_cmath
215293
- run:
216294
name: Build conda packages
217295
no_output_timeout: 20m
@@ -239,6 +317,7 @@ jobs:
239317
steps:
240318
- checkout_merge
241319
- designate_upload_channel
320+
- install_cuda_compatible_cmath
242321
- run:
243322
name: Build wheel packages
244323
command: |
@@ -278,6 +357,43 @@ jobs:
278357
paths:
279358
- "*"
280359

360+
binary_ios_build:
361+
<<: *torchvision_ios_params
362+
macos:
363+
xcode: "12.0"
364+
steps:
365+
- attach_workspace:
366+
at: ~/workspace
367+
- checkout
368+
- run_brew_for_ios_build
369+
- run:
370+
name: Build
371+
no_output_timeout: "1h"
372+
command: |
373+
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_build.sh"
374+
cat "$script"
375+
source "$script"
376+
- persist_to_workspace:
377+
root: /Users/distiller/workspace/
378+
paths: ios
379+
380+
binary_ios_upload:
381+
<<: *torchvision_ios_params
382+
macos:
383+
xcode: "12.0"
384+
steps:
385+
- attach_workspace:
386+
at: ~/workspace
387+
- checkout
388+
- run_brew_for_ios_build
389+
- run:
390+
name: Upload
391+
no_output_timeout: "1h"
392+
command: |
393+
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_upload.sh"
394+
cat "$script"
395+
source "$script"
396+
281397
binary_macos_conda:
282398
<<: *binary_common
283399
macos:
@@ -546,6 +662,7 @@ jobs:
546662
steps:
547663
- checkout
548664
- designate_upload_channel
665+
- install_cuda_compatible_cmath
549666
- run:
550667
name: Generate cache key
551668
# This will refresh cache on Sundays, nightly build should generate new cache.
@@ -587,6 +704,7 @@ jobs:
587704
steps:
588705
- checkout
589706
- designate_upload_channel
707+
- install_cuda_compatible_cmath
590708
- run:
591709
name: Generate cache key
592710
# This will refresh cache on Sundays, nightly build should generate new cache.
@@ -595,7 +713,7 @@ jobs:
595713
{% raw %}
596714
keys:
597715
- env-v1-windows-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/windows/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
598-
{% endraw %}
716+
{% endraw %}
599717
- run:
600718
name: Setup
601719
command: .circleci/unittest/windows/scripts/setup_env.sh
@@ -716,6 +834,7 @@ jobs:
716834
steps:
717835
- checkout_merge
718836
- designate_upload_channel
837+
- install_cuda_compatible_cmath
719838
- run:
720839
command: |
721840
set -ex
@@ -729,6 +848,7 @@ jobs:
729848
steps:
730849
- checkout_merge
731850
- designate_upload_channel
851+
- install_cuda_compatible_cmath
732852
- run:
733853
command: |
734854
set -ex
@@ -813,6 +933,7 @@ workflows:
813933
- clang_format
814934
- torchhub_test
815935
- torch_onnx_test
936+
{{ ios_workflows() }}
816937

817938
unittest:
818939
jobs:
@@ -832,6 +953,7 @@ workflows:
832953
- clang_format
833954
- torchhub_test
834955
- torch_onnx_test
956+
{{ ios_workflows(nightly=True) }}
835957
{{ build_workflows(prefix="nightly_", filter_branch="nightly", upload=True) }}
836958
docker_build:
837959
triggers:

.circleci/regenerate.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def build_workflows(prefix='', filter_branch=None, upload=False, indentation=6,
2929
for btype in ["wheel", "conda"]:
3030
for os_type in ["linux", "macos", "win"]:
3131
python_versions = PYTHON_VERSIONS
32-
cu_versions_dict = {"linux": ["cpu", "cu101", "cu102", "cu111", "rocm4.0.1"],
32+
cu_versions_dict = {"linux": ["cpu", "cu101", "cu102", "cu111", "rocm4.0.1", "rocm4.1"],
3333
"win": ["cpu", "cu101", "cu102", "cu111"],
3434
"macos": ["cpu"]}
3535
cu_versions = cu_versions_dict[os_type]
@@ -261,6 +261,36 @@ def cmake_workflows(indentation=6):
261261
return indent(indentation, jobs)
262262

263263

264+
def ios_workflows(indentation=6, nightly=False):
265+
jobs = []
266+
build_job_names = []
267+
name_prefix = "nightly_" if nightly else ""
268+
env_prefix = "nightly-" if nightly else ""
269+
for arch, platform in [('x86_64', 'SIMULATOR'), ('arm64', 'OS')]:
270+
name = f'{name_prefix}binary_libtorchvision_ops_ios_12.0.0_{arch}'
271+
build_job_names.append(name)
272+
build_job = {
273+
'build_environment': f'{env_prefix}binary-libtorchvision_ops-ios-12.0.0-{arch}',
274+
'context': 'org-member',
275+
'ios_arch': arch,
276+
'ios_platform': platform,
277+
'name': name,
278+
}
279+
if nightly:
280+
build_job['filters'] = gen_filter_branch_tree('nightly')
281+
jobs.append({'binary_ios_build': build_job})
282+
283+
if nightly:
284+
upload_job = {
285+
'build_environment': f'{env_prefix}binary-libtorchvision_ops-ios-12.0.0-upload',
286+
'context': 'org-member',
287+
'filters': gen_filter_branch_tree('nightly'),
288+
'requires': build_job_names,
289+
}
290+
jobs.append({'binary_ios_upload': upload_job})
291+
return indent(indentation, jobs)
292+
293+
264294
if __name__ == "__main__":
265295
d = os.path.dirname(__file__)
266296
env = jinja2.Environment(
@@ -275,4 +305,5 @@ def cmake_workflows(indentation=6):
275305
build_workflows=build_workflows,
276306
unittest_workflows=unittest_workflows,
277307
cmake_workflows=cmake_workflows,
308+
ios_workflows=ios_workflows,
278309
))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$CMATH_DOWNLOAD_LINK = "https://raw.githubusercontent.com/microsoft/STL/12c684bba78f9b032050526abdebf14f58ca26a3/stl/inc/cmath"
2+
$VC14_28_INSTALL_PATH="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include"
3+
4+
curl.exe --retry 3 -kL $CMATH_DOWNLOAD_LINK --output "$home\cmath"
5+
Move-Item -Path "$home\cmath" -Destination "$VC14_28_INSTALL_PATH" -Force
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
set -ex -o pipefail
3+
4+
echo ""
5+
echo "DIR: $(pwd)"
6+
WORKSPACE=/Users/distiller/workspace
7+
PROJ_ROOT_IOS=/Users/distiller/project/ios
8+
PYTORCH_IOS_NIGHTLY_NAME=libtorch_ios_nightly_build.zip
9+
export TCLLIBPATH="/usr/local/lib"
10+
11+
# install conda
12+
curl --retry 3 -o ~/conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
13+
chmod +x ~/conda.sh
14+
/bin/bash ~/conda.sh -b -p ~/anaconda
15+
export PATH="~/anaconda/bin:${PATH}"
16+
source ~/anaconda/bin/activate
17+
18+
# install dependencies
19+
conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi requests typing_extensions wget --yes
20+
conda install -c conda-forge valgrind --yes
21+
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
22+
23+
# sync submodules
24+
cd ${PROJ_ROOT_IOS}
25+
git submodule sync
26+
git submodule update --init --recursive
27+
28+
# download pytorch-iOS nightly build and unzip it
29+
mkdir -p ${PROJ_ROOT_IOS}/lib
30+
mkdir -p ${PROJ_ROOT_IOS}/build
31+
mkdir -p ${PROJ_ROOT_IOS}/pytorch
32+
TORCH_ROOT="${PROJ_ROOT_IOS}/pytorch"
33+
34+
cd ${TORCH_ROOT}
35+
wget https://ossci-ios-build.s3.amazonaws.com/${PYTORCH_IOS_NIGHTLY_NAME}
36+
mkdir -p ./build_ios
37+
unzip -d ./build_ios ./${PYTORCH_IOS_NIGHTLY_NAME}
38+
39+
LIBTORCH_HEADER_ROOT="${TORCH_ROOT}/build_ios/install/include"
40+
cd ${PROJ_ROOT_IOS}
41+
IOS_ARCH=${IOS_ARCH} LIBTORCH_HEADER_ROOT=${LIBTORCH_HEADER_ROOT} ./build_ios.sh
42+
rm -rf ${TORCH_ROOT}
43+
44+
# store the binary
45+
DEST_DIR=${WORKSPACE}/ios/${IOS_ARCH}
46+
mkdir -p ${DEST_DIR}
47+
cp ${PROJ_ROOT_IOS}/lib/*.a ${DEST_DIR}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
set -ex -o pipefail
3+
4+
echo ""
5+
echo "DIR: $(pwd)"
6+
7+
WORKSPACE=/Users/distiller/workspace
8+
PROJ_ROOT=/Users/distiller/project
9+
ARTIFACTS_DIR=${WORKSPACE}/ios
10+
ls ${ARTIFACTS_DIR}
11+
ZIP_DIR=${WORKSPACE}/zip
12+
mkdir -p ${ZIP_DIR}/install/lib
13+
14+
# build a FAT bianry
15+
cd ${ZIP_DIR}/install/lib
16+
libs=("${ARTIFACTS_DIR}/x86_64/libtorchvision_ops.a" "${ARTIFACTS_DIR}/arm64/libtorchvision_ops.a")
17+
lipo -create "${libs[@]}" -o ${ZIP_DIR}/install/lib/libtorchvision_ops.a
18+
lipo -i ${ZIP_DIR}/install/lib/*.a
19+
20+
# copy the license
21+
cp ${PROJ_ROOT}/LICENSE ${ZIP_DIR}/
22+
# zip the library
23+
ZIPFILE=libtorchvision_ops_ios_nightly_build.zip
24+
cd ${ZIP_DIR}
25+
#for testing
26+
touch version.txt
27+
echo $(date +%s) > version.txt
28+
zip -r ${ZIPFILE} install version.txt LICENSE
29+
30+
# upload to aws
31+
# Install conda then 'conda install' awscli
32+
curl --retry 3 -o ~/conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
33+
chmod +x ~/conda.sh
34+
/bin/bash ~/conda.sh -b -p ~/anaconda
35+
export PATH="~/anaconda/bin:${PATH}"
36+
source ~/anaconda/bin/activate
37+
conda install -c conda-forge awscli --yes
38+
set +x
39+
export AWS_ACCESS_KEY_ID=${AWS_S3_ACCESS_KEY_FOR_PYTORCH_BINARY_UPLOAD}
40+
export AWS_SECRET_ACCESS_KEY=${AWS_S3_ACCESS_SECRET_FOR_PYTORCH_BINARY_UPLOAD}
41+
set -x
42+
aws s3 cp ${ZIPFILE} s3://ossci-ios-build/ --acl public-read

0 commit comments

Comments
 (0)