File tree Expand file tree Collapse file tree 8 files changed +136
-13
lines changed Expand file tree Collapse file tree 8 files changed +136
-13
lines changed Original file line number Diff line number Diff line change 74
74
WERROR=1 python setup.py install
75
75
76
76
# Add the test binaries so that they won't be git clean'ed away
77
- git add -f build/bin build/lib
77
+ git add -f build/bin
78
78
79
79
# Testing ATen install
80
80
if [[ " $BUILD_ENVIRONMENT " != * cuda* ]]; then
@@ -101,3 +101,11 @@ if [[ "$BUILD_ENVIRONMENT" == *xenial-cuda8-cudnn6-py3* ]]; then
101
101
make html
102
102
popd
103
103
fi
104
+
105
+ # Test no-Python build
106
+ if [[ " $BUILD_TEST_LIBTORCH " == " 1" ]]; then
107
+ echo " Building libtorch"
108
+ # NB: Install outside of source directory (at the same level as the root
109
+ # pytorch folder) so that it doesn't get cleaned away prior to docker push.
110
+ WERROR=1 VERBOSE=1 tools/cpp_build/build_caffe2.sh " $PWD /../cpp-build"
111
+ fi
Original file line number Diff line number Diff line change @@ -61,12 +61,6 @@ export IMAGE_COMMIT_TAG=${BUILD_ENVIRONMENT}-${IMAGE_COMMIT_ID}
61
61
62
62
python setup.py install
63
63
64
- # this is a bit hacky, but not too bad. Bundle the test binaries into
65
- # the installation directory, so they can catch a free ride on the 7z
66
- # train.
67
- mkdir -p ${PYTORCH_ENV_DIR} /miniconda3/lib/python3.6/site-packages/torch/test_binaries/build
68
- mv build/{bin,lib} ${PYTORCH_ENV_DIR} /miniconda3/lib/python3.6/site-packages/torch/test_binaries/build/
69
-
70
64
# Upload torch binaries when the build job is finished
71
65
7z a ${IMAGE_COMMIT_TAG} .7z ${PYTORCH_ENV_DIR} /miniconda3/lib/python3.6/site-packages/torch*
72
66
aws s3 cp ${IMAGE_COMMIT_TAG} .7z s3://ossci-macos-build/pytorch/${IMAGE_COMMIT_TAG} .7z --acl public-read
Original file line number Diff line number Diff line change @@ -50,13 +50,22 @@ test_python_all() {
50
50
test_cpp_api () {
51
51
# C++ API
52
52
53
+ # NB: Install outside of source directory (at the same level as the root
54
+ # pytorch folder) so that it doesn't get cleaned away prior to docker push.
55
+ # But still clean it before we perform our own build.
56
+ #
57
+ CPP_BUILD=" $PWD /../cpp-build"
58
+ rm -rf $CPP_BUILD
59
+ mkdir -p $CPP_BUILD
60
+ WERROR=1 VERBOSE=1 tools/cpp_build/build_caffe2.sh " $CPP_BUILD "
61
+
53
62
python tools/download_mnist.py --quiet -d test/cpp/api/mnist
54
63
55
64
# Unfortunately it seems like the test can't load from miniconda3
56
65
# without these paths being set
57
66
export DYLD_LIBRARY_PATH=" $DYLD_LIBRARY_PATH :$PWD /miniconda3/lib"
58
67
export LD_LIBRARY_PATH=" $LD_LIBRARY_PATH :$PWD /miniconda3/lib"
59
- ${PYTORCH_ENV_DIR} /miniconda3/lib/python3.6/site-packages/torch/test_binaries/build /bin/test_api
68
+ " $CPP_BUILD " /caffe2 /bin/test_api
60
69
}
61
70
62
71
if [ -z " ${JOB_BASE_NAME} " ] || [[ " ${JOB_BASE_NAME} " == * -test ]]; then
Original file line number Diff line number Diff line change @@ -108,13 +108,14 @@ test_torchvision() {
108
108
test_libtorch () {
109
109
if [[ " $BUILD_TEST_LIBTORCH " == " 1" ]]; then
110
110
echo " Testing libtorch"
111
+ CPP_BUILD=" $PWD /../cpp-build"
111
112
if [[ " $BUILD_ENVIRONMENT " == * cuda* ]]; then
112
- ./build /bin/test_jit
113
+ " $CPP_BUILD " /caffe2 /bin/test_jit
113
114
else
114
- ./build /bin/test_jit " [cpu]"
115
+ " $CPP_BUILD " /caffe2 /bin/test_jit " [cpu]"
115
116
fi
116
117
python tools/download_mnist.py --quiet -d test/cpp/api/mnist
117
- OMP_NUM_THREADS=2 ./build /bin/test_api
118
+ OMP_NUM_THREADS=2 " $CPP_BUILD " /caffe2 /bin/test_api
118
119
fi
119
120
}
120
121
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -ex
4
+
5
+ SCRIPTPATH=" $( cd " $( dirname " $0 " ) " ; pwd -P ) "
6
+
7
+ pushd $SCRIPTPATH
8
+ source ./build_common.sh
9
+
10
+ echo " Building Caffe2"
11
+
12
+ mkdir -p $CAFFE2_BUILDPATH
13
+ pushd $CAFFE2_BUILDPATH
14
+
15
+ cmake -DUSE_CUDA:BOOL=$USE_CUDA \
16
+ -DBUILD_TORCH=ON \
17
+ -DUSE_OPENMP:BOOL=${USE_OPENMP: ON} \
18
+ -DBUILD_CAFFE2=OFF \
19
+ -DBUILD_ATEN=ON \
20
+ -DBUILD_PYTHON=OFF \
21
+ -DBUILD_BINARY=OFF \
22
+ -DBUILD_SHARED_LIBS=ON \
23
+ -DONNX_NAMESPACE=$ONNX_NAMESPACE \
24
+ -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE \
25
+ -DCMAKE_INSTALL_PREFIX:STRING=$INSTALL_PREFIX \
26
+ -DCMAKE_INSTALL_MESSAGE=NEVER \
27
+ -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
28
+ -G " $GENERATE " \
29
+ $PYTORCHPATH /
30
+ $MAKE -j " $JOBS " install
31
+
32
+ popd
33
+ popd
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ BUILD_PATH=" ${1:- $SCRIPTPATH / build} "
4
+ INSTALL_PREFIX=" $BUILD_PATH /install"
5
+ PYTORCHPATH=" $SCRIPTPATH /../.."
6
+
7
+ USE_CUDA=0
8
+ if [ -x " $( command -v nvcc) " ]; then
9
+ USE_CUDA=1
10
+ fi
11
+
12
+ CAFFE2_BUILDPATH=" $BUILD_PATH /caffe2"
13
+ NANOPB_BUILDPATH=" $BUILD_PATH /nanopb"
14
+
15
+ # Build with Ninja if available. It has much cleaner output.
16
+ GENERATE=" Unix Makefiles"
17
+ MAKE=make
18
+ if [ -x " $( command -v ninja) " ]; then
19
+ GENERATE=Ninja
20
+ MAKE=ninja
21
+ fi
22
+
23
+ # Code is developed a lot more than released, so default to Debug.
24
+ BUILD_TYPE=${BUILD_TYPE:- Debug}
25
+
26
+ # Try to build with as many threads as we have cores, default to 4 if the
27
+ # command fails.
28
+ set +e
29
+ if [ -n " $MAX_JOBS " ]; then # Use MAX_JOBS if it is set
30
+ JOBS=$MAX_JOBS
31
+ elif [[ " $( uname) " == " Linux" ]]; then
32
+ # https://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line
33
+ JOBS=" $( grep -c ' ^processor' /proc/cpuinfo) "
34
+ else # if [[ "$(uname)" == "Darwin"]]
35
+ # https://stackoverflow.com/questions/1715580/how-to-discover-number-of-logical-cores-on-mac-os-x
36
+ JOBS=" $( sysctl -n hw.ncpu) "
37
+ fi
38
+ set -e
39
+ if [[ $? -ne 0 ]]; then
40
+ JOBS=4
41
+ fi
42
+
43
+ # Make sure an ONNX namespace is set
44
+ if [ -z " $ONNX_NAMESPACE " ]; then
45
+ ONNX_NAMESPACE=" onnx_torch"
46
+ fi
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -ex
4
+
5
+ SCRIPTPATH=" $( cd " $( dirname " $0 " ) " ; pwd -P ) "
6
+
7
+ pushd $SCRIPTPATH
8
+ source ./build_common.sh
9
+
10
+ echo " Building Torch"
11
+
12
+ mkdir -p $LIBTORCH_BUILDPATH
13
+ pushd $LIBTORCH_BUILDPATH
14
+
15
+ cmake -DUSE_CUDA:BOOL=$USE_CUDA \
16
+ -DNO_API:BOOL=${NO_API:- 0} \
17
+ -DCAFFE2_PATH=$PYTORCHPATH / \
18
+ -DCAFFE2_BUILD_PATH=$CAFFE2_BUILDPATH \
19
+ -DONNX_NAMESPACE=$ONNX_NAMESPACE \
20
+ -DNANOPB_BUILD_PATH=$NANOPB_BUILDPATH \
21
+ -DINSTALL_PREFIX=$INSTALL_PREFIX \
22
+ -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE \
23
+ -DCMAKE_INSTALL_PREFIX:STRING=$INSTALL_PREFIX \
24
+ -DCMAKE_INSTALL_MESSAGE=NEVER \
25
+ -Dnanopb_BUILD_GENERATOR:BOOL=OFF \
26
+ -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
27
+ -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
28
+ -DVERBOSE:BOOL=${VERBOSE:- 0} \
29
+ -G " $GENERATE " \
30
+ $PYTORCHPATH /torch
31
+ $MAKE -j " $JOBS "
32
+
33
+ popd
34
+ popd
Original file line number Diff line number Diff line change @@ -389,7 +389,6 @@ if (BUILD_TORCH_TEST AND NOT MSVC AND NOT APPLE AND NOT USE_ROCM)
389
389
if (USE_CUDA)
390
390
target_link_libraries (test_jit ${CUDA_LIBRARIES} )
391
391
endif ()
392
-
393
392
endif ()
394
393
395
394
if (BUILD_TORCH_TEST AND NOT NO_API AND NOT USE_ROCM)
@@ -438,5 +437,4 @@ if (BUILD_TORCH_TEST AND NOT NO_API AND NOT USE_ROCM)
438
437
-Wno-unused-but-set-parameter)
439
438
endif ()
440
439
endif ()
441
-
442
440
endif ()
You can’t perform that action at this time.
0 commit comments