Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Adding CMake to the CI #1310

Merged
merged 8 commits into from
Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 154 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,81 @@ commands:
sudo wget -q https://github.com/bazelbuild/bazel/releases/download/<< parameters.version >>/bazel-<< parameters.version >>-linux-<< parameters.platform >> -O /usr/bin/bazel
sudo chmod a+x /usr/bin/bazel

install-cmake:
description: Install CMake.
parameters:
cache:
default: true
description: Whether or not to cache the installation.
type: boolean
cache-key:
default: v1
description: String to use in cache key. Typically overridden when needed to bust cache.
type: string
install-dir:
default: $HOME/cmake
description: The path to install CMake to.
type: string
version:
default: 3.18.2
description: The version of CMake to install.
type: string
steps:
- when:
condition:
equal:
- << parameters.cache >>
- true
steps:
- run:
command: mkdir -pv << parameters.install-dir >>
name: Prep cache restore
- restore_cache:
keys:
- cmake-<< parameters.cache-key >>-<< parameters.version >>
- run:
command: |
echo 'export PATH="<< parameters.install-dir >>/bin:$PATH"' >> $BASH_ENV
name: Add CMake to PATH
- run:
command: |
if which cmake; then
if cmake --version | grep "<< parameters.version >>"; then
echo "CMake is already installed."
exit 0
else
echo "CMake is already installed but it is the wrong version."
fi
fi

rm -rf << parameters.install-dir >>/*
echo "Installing the requested version of CMake."
baseUrl="https://github.com/Kitware/CMake/releases/download/"
url="${baseUrl}/v<< parameters.version >>/cmake-<< parameters.version >>-Linux-x86_64.tar.gz"
curl -sSL -o /tmp/cmake.tar.gz $url
tar -C << parameters.install-dir >> --strip-components 1 -zxf /tmp/cmake.tar.gz
name: Install CMake
- run:
command: rm -rf << parameters.install-dir >>/{doc,man}
name: Remove unnecessary files
- run:
command: |
ls -l << parameters.install-dir >>/bin
echo $PATH
cmake --version
name: Verify CMake installation
- when:
condition:
equal:
- << parameters.cache >>
- true
steps:
- save_cache:
key: cmake-<< parameters.cache-key >>-<< parameters.version >>
paths:
- << parameters.install-dir >>


install-cuda:
description: "Install CUDA"
parameters:
Expand Down Expand Up @@ -207,6 +282,30 @@ commands:
mkdir -p /tmp/dist/builds
cp dist/* /tmp/dist/builds

build-cmake:
description: "Build the torch-tensorrt using CMake"
parameters:
platform:
type: string
default: "x86_64"
steps:
- run:
name: Build torch-tensorrt library with CMake
command: |
mkdir build
export PATH=$PATH:/usr/local/cuda/bin
~/cmake/bin/cmake -S. -Bbuild \
-DCMAKE_MODULE_PATH=cmake/Module \
-DTorch_DIR=/opt/circleci/.pyenv/versions/3.9.4/lib/python3.9/site-packages/torch/share/cmake/Torch \
-DTensorRT_ROOT=/usr \
-DCMAKE_BUILD_TYPE=Debug
cmake --build build -j4
mkdir -p /tmp/dist/builds
cp -r build/bin /tmp/dist/builds
cp -r build/lib /tmp/dist/builds
cp -r cpp/include /tmp/dist/builds


dump-test-env:
description: "Dump the test env to console"
steps:
Expand Down Expand Up @@ -632,7 +731,7 @@ jobs:
platform: "x86_64"
cudnn-version: << pipeline.parameters.cudnn-release-version >>
trt-version-short: << pipeline.parameters.trt-release-version-short >>
bazel-version: "5.1.1"
bazel-version: << pipeline.parameters.bazel-version >>
bazel-platform: "x86_64"
- run:
name: Build cxx11-abi tarball
Expand Down Expand Up @@ -703,7 +802,7 @@ jobs:
platform: "sbsa"
cudnn-version: << pipeline.parameters.cudnn-jetson-version >>
trt-version-short: << pipeline.parameters.trt-jetson-version-short >>
bazel-version: "5.1.1"
bazel-version: << pipeline.parameters.bazel-version >>
bazel-platform: "arm64"
- run:
name: Set python version
Expand Down Expand Up @@ -742,6 +841,45 @@ jobs:
path: /tmp/dist/jetson
destination: aarch64-release-pkgs

build-x86_64-cmake:
parameters:
cudnn-version:
type: string
trt-version-short:
type: string
torch-build:
type: string
torch-build-index:
type: string
machine:
image: ubuntu-2004-cuda-11.4:202110-01
resource_class: gpu.nvidia.small
steps:
- checkout
- create-env:
os: "ubuntu2004"
platform: "x86_64"
cudnn-version: << parameters.cudnn-version >>
trt-version-short: << parameters.trt-version-short >>
bazel-platform: "x86_64"
- install-cmake:
version: 3.24.1
- install-torch-from-index:
torch-build: << parameters.torch-build >>
torch-build-index: << parameters.torch-build-index >>
- build-cmake
- run:
name: Move to cmake build dir
command: |
mkdir -p /tmp/dist/cmake
cp -r /tmp/dist/builds/* /tmp/dist/cmake
- persist_to_workspace:
root: /tmp/dist
paths:
- cmake
- store_artifacts:
path: /tmp/dist/cmake
destination: x86_64-cmake

parameters:
bazel-version:
Expand Down Expand Up @@ -821,7 +959,6 @@ workflows:
jetpack-version: << pipeline.parameters.jetpack-version >>
python-version: 3.8.10


- build-x86_64-pyt-release:
torch-build: << pipeline.parameters.torch-release-build >>
torch-build-index: << pipeline.parameters.torch-release-build-index >>
Expand Down Expand Up @@ -855,7 +992,6 @@ workflows:
requires:
- build-x86_64-pyt-release


- build-x86_64-pyt-nightly:
torch-build: << pipeline.parameters.torch-nightly-build >>
torch-build-index: << pipeline.parameters.torch-nightly-build-index >>
Expand Down Expand Up @@ -901,7 +1037,6 @@ workflows:
torch-build: << pipeline.parameters.torch-release-build >>
torch-build-index: << pipeline.parameters.torch-release-build-index >>


- test-core-cpp-x86_64:
name: test-core-cpp-x86_64-pyt-release
channel: "release"
Expand Down Expand Up @@ -958,7 +1093,6 @@ workflows:
jetpack-version: << pipeline.parameters.jetpack-version >>
python-version: 3.8.10


- build-x86_64-pyt-release:
torch-build: << pipeline.parameters.torch-release-build >>
torch-build-index: << pipeline.parameters.torch-release-build-index >>
Expand Down Expand Up @@ -1025,3 +1159,17 @@ workflows:
trt-version-long: << pipeline.parameters.trt-nightly-version-long >>
requires:
- build-x86_64-pyt-nightly

- build-x86_64-cmake:
name: build-x86_64-cmake-pyt-nightly
torch-build: << pipeline.parameters.torch-nightly-build >>
torch-build-index: << pipeline.parameters.torch-nightly-build-index >>
trt-version-short: << pipeline.parameters.trt-nightly-version-short >>
cudnn-version: << pipeline.parameters.cudnn-nightly-version >>

- build-x86_64-cmake:
name: build-x86_64-cmake-pyt-release
torch-build: << pipeline.parameters.torch-release-build >>
torch-build-index: << pipeline.parameters.torch-release-build-index >>
trt-version-short: << pipeline.parameters.trt-release-version-short >>
cudnn-version: << pipeline.parameters.cudnn-release-version >>