Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 8a80728

Browse files
committed
Remove aten submodule, add pytorch submodule and get aten from there. Also make TC work with the latest aten AP and switch python API to use pytorch-nightly. CI is switched from gcc 4.8.* to gcc 4.9 to maintain compatibility with the pytorch binary which is using gcc 4.9
1 parent 7d79f6e commit 8a80728

21 files changed

+81
-130
lines changed

.circleci/config.yml

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
working_directory: ~/TensorComprehensions
55
resource_class: xlarge
66
docker:
7-
- image: tensorcomprehensions/linux-trusty-gcc4.8-cuda8-cudnn6-py3-conda:x86
7+
- image: tensorcomprehensions/linux-trusty-gcc4.9-cuda8-cudnn7-py3-conda:1
88

99
steps:
1010
- checkout
@@ -26,7 +26,7 @@ jobs:
2626

2727
- restore_cache:
2828
keys:
29-
- v1-aten-{{ checksum ".git/modules/third-party/ATen/HEAD" }}-{{ checksum "build.sh" }}-{{ checksum ".circleci/config.yml" }}-{{ arch }}-1404
29+
- v1-pytorch-{{ checksum ".git/modules/third-party/pytorch/HEAD" }}-{{ checksum "build.sh" }}-{{ checksum ".circleci/config.yml" }}-{{ arch }}-1404
3030

3131
- restore_cache:
3232
keys:
@@ -68,7 +68,7 @@ jobs:
6868
- third-party/caffe2/build_host_protoc
6969

7070
- save_cache:
71-
key: v1-aten-{{ checksum ".git/modules/third-party/ATen/HEAD" }}-{{ checksum "build.sh" }}-{{ checksum ".circleci/config.yml" }}-{{ arch }}-1404
71+
key: v1-aten-{{ checksum ".git/modules/third-party/pytorch/HEAD" }}-{{ checksum "build.sh" }}-{{ checksum ".circleci/config.yml" }}-{{ arch }}-1404
7272
paths:
7373
- third-party-install/share/ATen
7474
- third-party-install/include/ATen
@@ -78,19 +78,9 @@ jobs:
7878
- third-party-install/include/THCUNN
7979
- third-party-install/include/THNN
8080
- third-party-install/include/THS
81+
- third-party-install/include/cpuinfo.h
8182
- third-party-install/lib/libATen.so
82-
- third-party-install/lib/libATen.so.1
83-
- third-party-install/lib/libTH.so
84-
- third-party-install/lib/libTH.so.0
85-
- third-party-install/lib/libTHC.so
86-
- third-party-install/lib/libTHC.so.0
87-
- third-party-install/lib/libTHCS.so
88-
- third-party-install/lib/libTHCS.so.1
89-
- third-party-install/lib/libTHCUNN.so
90-
- third-party-install/lib/libTHNN.so
91-
- third-party-install/lib/libTHS.so
92-
- third-party-install/lib/libTHS.so.1
93-
- third-party/ATen/build/src/ATen/test
83+
- third-party/pytorch/aten/build/src/ATen/test/
9484

9585
- save_cache:
9686
key: v1-isl-{{ checksum ".git/modules/third-party/islpp/HEAD" }}-{{ checksum "build.sh" }}-{{ checksum ".circleci/config.yml" }}-{{ arch }}-1404
@@ -125,7 +115,7 @@ jobs:
125115
working_directory: ~/TensorComprehensions
126116
resource_class: xlarge
127117
docker:
128-
- image: tensorcomprehensions/linux-xenial-gcc5-cuda9-cudnn7-py3:x86
118+
- image: tensorcomprehensions/linux-xenial-gcc5-cuda9-cudnn7-py3:1
129119

130120
steps:
131121
- checkout
@@ -188,7 +178,7 @@ jobs:
188178
- third-party-install/lib/libcaffe2_gpu.so
189179

190180
- save_cache:
191-
key: v1-aten-{{ checksum ".git/modules/third-party/ATen/HEAD" }}-{{ checksum "build.sh" }}-{{ checksum ".circleci/config.yml" }}-{{ arch }}-1604
181+
key: v1-aten-{{ checksum ".git/modules/third-party/pytorch/HEAD" }}-{{ checksum "build.sh" }}-{{ checksum ".circleci/config.yml" }}-{{ arch }}-1604
192182
paths:
193183
- third-party-install/share/ATen
194184
- third-party-install/include/ATen
@@ -198,19 +188,9 @@ jobs:
198188
- third-party-install/include/THCUNN
199189
- third-party-install/include/THNN
200190
- third-party-install/include/THS
191+
- third-party-install/include/cpuinfo.h
201192
- third-party-install/lib/libATen.so
202-
- third-party-install/lib/libATen.so.1
203-
- third-party-install/lib/libTH.so
204-
- third-party-install/lib/libTH.so.0
205-
- third-party-install/lib/libTHC.so
206-
- third-party-install/lib/libTHC.so.0
207-
- third-party-install/lib/libTHCS.so
208-
- third-party-install/lib/libTHCS.so.1
209-
- third-party-install/lib/libTHCUNN.so
210-
- third-party-install/lib/libTHNN.so
211-
- third-party-install/lib/libTHS.so
212-
- third-party-install/lib/libTHS.so.1
213-
- third-party/ATen/build/src/ATen/test
193+
- third-party/pytorch/aten/build/src/ATen/test/
214194

215195
- save_cache:
216196
key: v1-isl-{{ checksum ".git/modules/third-party/islpp/HEAD" }}-{{ checksum "build.sh" }}-{{ checksum ".circleci/config.yml" }}-{{ arch }}-1604

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
[submodule "third-party/glog"]
2424
path = third-party/glog
2525
url = https://github.com/google/glog.git
26-
[submodule "third-party/ATen"]
27-
path = third-party/ATen
28-
url = https://github.com/zdevito/aten.git
2926
[submodule "third-party/dlpack"]
3027
path = third-party/dlpack
3128
url = https://github.com/dmlc/dlpack.git
@@ -35,3 +32,6 @@
3532
[submodule "third-party/pybind11"]
3633
path = third-party/pybind11
3734
url = https://github.com/pybind/pybind11.git
35+
[submodule "third-party/pytorch"]
36+
path = third-party/pytorch
37+
url = https://github.com/pytorch/pytorch.git

.jenkins/build.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ if [[ "$DISTRIB_RELEASE" == 14.04 ]]; then
7070
echo "Building TC in conda env"
7171
conda create -y --name tc-env python=3.6
7272
source activate tc-env
73-
conda install -y -c pytorch pytorch
74-
conda install -y pyyaml
73+
conda install -y pyyaml mkl-include
7574
conda install -yc conda-forge pytest
75+
conda install -y pytorch-nightly=2018.04.17 -c pytorch
7676
WITH_PYTHON_C2=OFF CORES=$(nproc) CLANG_PREFIX=/usr/local/clang+llvm-tapir5.0 BUILD_TYPE=Release ./build.sh --all
7777
else
7878
echo "Building TC in non-conda env"
@@ -85,9 +85,9 @@ if [[ "$DISTRIB_RELEASE" == 16.04 ]]; then
8585
echo "Building TC in conda env"
8686
conda create -y --name tc-env python=3.6
8787
source activate tc-env
88-
conda install -y pytorch cuda90 -c pytorch
89-
conda install -y pyyaml
88+
conda install -y pyyaml mkl-include
9089
conda install -yc conda-forge pytest
90+
conda install -y pytorch-nightly=2018.04.17 cuda90 -c pytorch
9191
WITH_PYTHON_C2=OFF CORES=$(nproc) CLANG_PREFIX=/usr/local/clang+llvm-tapir5.0 BUILD_TYPE=Release ./build.sh --all
9292
else
9393
echo "Building TC in non-conda env"

.jenkins/run_test.sh

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,12 @@ source /etc/lsb-release
88
# condition: if 16.04 and conda, run only python tests
99
# condition: if any and non-conda, run test.sh only
1010

11-
# TODO: modify 2LUT tests from example_MLP_model and enable on CI
12-
13-
if [[ "$DISTRIB_RELEASE" == 14.04 ]]; then
11+
if [[ $(conda --version | wc -c) -ne 0 ]]; then
12+
echo "Running TC PyTorch tests"
13+
./test_python/run_test.sh
14+
else
15+
# TODO: modify 2LUT tests from example_MLP_model and enable on CI
1416
echo "Running TC backend tests"
1517
FILTER_OUT=MLP_model ./test.sh
1618
./build/tc/benchmarks/MLP_model --gtest_filter=-*2LUT*
17-
if [[ $(conda --version | wc -c) -ne 0 ]]; then
18-
source activate tc-env
19-
echo "Running TC PyTorch tests"
20-
./test_python/run_test.sh
21-
fi
22-
fi
23-
24-
if [[ "$DISTRIB_RELEASE" == 16.04 ]]; then
25-
if [[ $(conda --version | wc -c) -ne 0 ]]; then
26-
echo "Running TC PyTorch tests"
27-
source activate tc-env
28-
./test_python/run_test.sh
29-
else
30-
echo "Running TC backend tests"
31-
FILTER_OUT=MLP_model ./test.sh
32-
./build/tc/benchmarks/MLP_model --gtest_filter=-*2LUT*
33-
fi
3419
fi

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ execute_process(COMMAND "python" "-c"
203203
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
204204
message(STATUS "PYTHON site packages: \n${PYTHON_SITE_PACKAGES}")
205205

206-
# if PyTorch is installed, we get libATen.so.1 from there, otherwise build it
206+
# if PyTorch is installed, we get libATen.so from there, otherwise build it
207207
if (__torch_install EQUAL 0)
208208
message(STATUS "TORCH INSTALLED, linking to ATen from PyTorch")
209209
set(ATEN_INCLUDE_DIR "${PYTHON_SITE_PACKAGES}/torch/lib/include")
210210
include_directories(${ATEN_INCLUDE_DIR})
211-
find_library(ATEN_LIBRARIES NAMES libATen.so.1 PATHS ${PYTHON_SITE_PACKAGES}/torch/lib)
211+
find_library(ATEN_LIBRARIES NAMES libATen.so PATHS ${PYTHON_SITE_PACKAGES}/torch/lib)
212212
link_directories("${PYTHON_SITE_PACKAGES}/../../")
213213
message(STATUS "Found ATen.so file: ${ATEN_LIBRARIES}")
214214
else()

build.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ function install_glog() {
220220
}
221221

222222
function install_aten() {
223-
mkdir -p ${TC_DIR}/third-party/ATen/build || exit 1
224-
cd ${TC_DIR}/third-party/ATen/build || exit 1
223+
mkdir -p ${TC_DIR}/third-party/pytorch/aten/build || exit 1
224+
cd ${TC_DIR}/third-party/pytorch/aten/build || exit 1
225225

226226
if ! test ${USE_CONTBUILD_CACHE} || [ ! -d "${INSTALL_PREFIX}/include/ATen" ]; then
227227

@@ -234,18 +234,18 @@ function install_aten() {
234234
fi
235235

236236
# ATen errors out when using many threads for building - use 1 core for now
237-
if should_rebuild ${TC_DIR}/third-party/ATen ${TC_DIR}/third-party/.aten_build_cache; then
237+
if should_rebuild ${TC_DIR}/third-party/pytorch/aten ${TC_DIR}/third-party/.aten_build_cache; then
238238
echo "Installing ATen"
239239

240240
if should_reconfigure .. .build_cache; then
241241
echo "Reconfiguring ATen"
242242
export PYTORCH_PYTHON=${PYTHON}
243-
${CMAKE_VERSION} ../aten -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DHAS_C11_ATOMICS=OFF -DNO_CUDA=${ATEN_NO_CUDA}
243+
${CMAKE_VERSION} .. -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DHAS_C11_ATOMICS=OFF -DNO_CUDA=${ATEN_NO_CUDA}
244244
fi
245245
make -j $CORES -s || exit 1
246246

247247
set_cache .. .build_cache
248-
set_bcache ${TC_DIR}/third-party/ATen ${TC_DIR}/third-party/.aten_build_cache
248+
set_bcache ${TC_DIR}/third-party/pytorch/aten ${TC_DIR}/third-party/.aten_build_cache
249249
fi
250250

251251
make install -j $CORES -s || exit 1
@@ -369,6 +369,7 @@ function install_tc_python() {
369369
else
370370
if [[ $(conda --version | wc -c) -ne 0 ]]; then
371371
echo "Found conda, going to install Python packages"
372+
conda install -y mkl-include
372373
cd ${TC_DIR}
373374
export CONDA_PYTHON=$(which python3)
374375
echo "CONDA_PYTHON: ${CONDA_PYTHON}"

docker/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# How to build Tensor Comprehensions docker images
22

3-
Tensor Comprehensions supports gcc4.8, gcc5, cuda8-cudnn6, cuda9-cudnn7, Xenial, Trusty
3+
Tensor Comprehensions supports gcc4.9, gcc5, cuda8-cudnn6, cuda9-cudnn7, Xenial, Trusty
44
and building in Conda/ Non-conda environment. Below are the steps you can follow
55
to build the images for various combinations. This directory contains everything needed to build the Docker images that are used in our CI as well. The `Dockerfile`s are parameterized to build the image based on the build environment. The different configurations are identified by a freeform string that we call a build environment. This string is persisted in each image as the BUILD_ENVIRONMENT environment variable.
66

77
## Supported Build environments
88

99
Non-conda env and no python installs:
1010

11-
`linux-trusty-gcc4.8-cuda8-cudnn7-py3`
11+
`linux-trusty-gcc4.9-cuda8-cudnn7-py3`
1212

1313
`linux-xenial-gcc5-cuda9-cudnn7-py3`
1414

1515
Conda env with PyTorch conda install:
1616

17-
`linux-trusty-gcc4.8-cuda8-cudnn7-py3-conda` [Run both C++ and Python tests]
17+
`linux-trusty-gcc4.9-cuda8-cudnn7-py3-conda` [Run both C++ and Python tests]
1818

1919
`linux-xenial-gcc5-cuda9-cudnn7-py3-conda` [Run only Python tests for now]
2020

@@ -56,12 +56,12 @@ cd TensorComprehensions/docker
5656
```
5757

5858
Now, we will build a docker image for TC. We will build docker image for TC on
59-
linux trusty with gcc4.8, cuda8, cudnn6 and conda environment settings. If you
59+
linux trusty with gcc4.9, cuda8, cudnn7 and conda environment settings. If you
6060
need to build images for some other combination, the steps are still valid, just
6161
make sure to change the paths below to fit your case.
6262

6363
```Shell
64-
image=linux-trusty-gcc4.8-cuda8-cudnn7-py3-conda ./docker_build.sh
64+
image=linux-trusty-gcc4.9-cuda8-cudnn7-py3-conda ./docker_build.sh
6565
```
6666

6767
This will build the image for the above permutation and then we can test this image
@@ -74,9 +74,12 @@ run `docker images` and get the `IMAGE_ID` for the image we just built.
7474
docker run --runtime=nvidia -i -t ${IMAGE_ID}
7575
# now clone the TC repo
7676
cd $HOME && git clone https://github.com/facebookresearch/TensorComprehensions.git --recursive && cd TensorComprehensions
77+
git submodule update --init --recursive
7778
# build TC
78-
conda install -y -c pytorch pytorch
79-
WITH_PYTHON_C2=OFF CLANG_PREFIX=/usr/local/clang+llvm-tapir5.0 ./build.sh --all
79+
conda install -y mkl-include pyyaml
80+
conda install -yc conda-forge pytest
81+
conda install -y pytorch-nightly=2018.04.17 -c pytorch # OR conda install -y pytorch-nightly=2018.04.17 cuda90 -c pytorch
82+
CORES=$(nproc) WITH_CAFFE2=ON CLANG_PREFIX=/usr/local/clang+llvm-tapir5.0 BUILD_TYPE=Release ./build.sh --all
8083
# Test the TC build is fine
8184
./test.sh
8285
./test_python/run_test.sh

docker/common/install_conda.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ popd
1818

1919
export PATH=/opt/conda/bin:$PATH
2020

21-
/opt/conda/bin/conda install numpy decorator six future cmake pyyaml
21+
/opt/conda/bin/conda install numpy decorator six future cmake pyyaml mkl-include typing
22+
/opt/conda/bin/conda install -yc conda-forge pytest
2223

2324
which conda
2425
conda --version

docker/common/install_pip_python.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ set -ex
44

55
# Install common dependencies
66
apt-get update
7-
apt-get install -y --no-install-recommends python3-dev python3-pip python3-setuptools
7+
apt-get install -y --no-install-recommends python3-dev python3-setuptools
88

9-
pip3 install --upgrade pip
10-
pip3 install numpy decorator six future setuptools pyyaml
9+
# Install pip from source. The python-pip package on Ubuntu Trusty is old
10+
# and upon install numpy doesn't use the binary distribution, and fails to compile it from source.
11+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
12+
python3 get-pip.py
13+
rm get-pip.py
14+
15+
pip install numpy decorator six future pyyaml
16+
# install the devel needed for aten
17+
pip install mkl mkl-devel typing
1118

1219
which python3
1320
python3 --version

docker/ubuntu-cuda-conda/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ ENV DEBIAN_FRONTEND noninteractive
1010
# PyTorch conda install
1111
ARG CUDA_VERSION
1212
ARG CUDNN_VERSION
13-
ADD ./common/install_cuda.sh install_cuda.sh
14-
RUN bash ./install_cuda.sh && rm install_cuda.sh
1513
ENV LD_LIBRARY_PATH /usr/local/cuda/lib64:/usr/local/cuda/targets/x86_64-linux/lib/stubs/:$LD_LIBRARY_PATH
1614
ENV PATH /usr/local/cuda/bin:/usr/local/bin:$PATH
1715

0 commit comments

Comments
 (0)