-
Notifications
You must be signed in to change notification settings - Fork 7k
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
migrate cmake workflows from CircleCI to GHA #7417
Changes from all commits
502d5da
436f3ae
29373c0
f9c371c
e69c38c
3abebff
5824c74
399f545
fb4a55c
de5d298
14e2e6d
db44fef
405ea39
58c5394
6ed5400
426887f
298a236
1af9dbb
1dc42f9
16d0293
b0ca52b
40eecae
280868a
82c038a
26c6d86
7917396
e28f1cb
7cec87c
0dc5587
ca04d9c
3d01320
3a46510
2aea9bb
d88228d
33a4df1
08ae9e4
64d2b0e
f1e1201
ce90113
10a6b80
534147d
0f7f126
8048e47
c6e77d2
8a3f9d7
27725ca
9db8e0c
b056963
1d213c5
9c6f463
1938a0d
1ec0514
1db13d6
9f8f48c
c4a5802
72835b9
427c82e
862f268
9baaf70
9a86559
b43ee33
24e0b2b
d0f41ce
b98cf3e
c7a860f
0b91c3d
79ae3e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
./.github/scripts/setup-env.sh | ||
|
||
# Activate conda environment | ||
set +x && eval "$($(which conda) shell.bash hook)" && conda deactivate && conda activate ci && set -x | ||
|
||
# Setup the OS_TYPE environment variable that should be used for conditions involving the OS below. | ||
case $(uname) in | ||
Linux) | ||
OS_TYPE=linux | ||
;; | ||
Darwin) | ||
OS_TYPE=macos | ||
;; | ||
MSYS*) | ||
OS_TYPE=windows | ||
;; | ||
*) | ||
echo "Unknown OS type:" $(uname) | ||
exit 1 | ||
;; | ||
esac | ||
|
||
if [[ $OS_TYPE == macos ]]; then | ||
JOBS=$(sysctl -n hw.logicalcpu) | ||
else | ||
JOBS=$(nproc) | ||
fi | ||
|
||
TORCH_PATH=$(python -c "import pathlib, torch; print(pathlib.Path(torch.__path__[0]))") | ||
if [[ $OS_TYPE == windows ]]; then | ||
PACKAGING_DIR="${PWD}/packaging" | ||
export PATH="${TORCH_PATH}/lib:${PATH}" | ||
fi | ||
|
||
Torch_DIR="${TORCH_PATH}/share/cmake/Torch" | ||
if [[ "${GPU_ARCH_TYPE}" == "cuda" ]]; then | ||
WITH_CUDA=1 | ||
else | ||
WITH_CUDA=0 | ||
fi | ||
|
||
echo '::group::Prepare CMake builds' | ||
mkdir -p cpp_build | ||
|
||
pushd test/tracing/frcnn | ||
python trace_model.py | ||
mkdir -p build | ||
mv fasterrcnn_resnet50_fpn.pt build | ||
popd | ||
|
||
pushd examples/cpp/hello_world | ||
python trace_model.py | ||
mkdir -p build | ||
mv resnet18.pt build | ||
popd | ||
|
||
# This was only needed for the tracing above | ||
pip uninstall -y torchvision | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not needed, but we are making sure here that we don't need to have a |
||
echo '::endgroup::' | ||
|
||
echo '::group::Build and install libtorchvision' | ||
pushd cpp_build | ||
|
||
# On macOS, CMake is looking for the library (*.dylib) and the header (*.h) separately. By default, it prefers to load | ||
# the header from other packages that install the library. This easily leads to a mismatch if the library installed | ||
# from conda doesn't have the exact same version. Thus, we need to explicitly set CMAKE_FIND_FRAMEWORK=NEVER to force | ||
# it to not load anything from other installed frameworks. Resources: | ||
# https://stackoverflow.com/questions/36523911/osx-homebrew-cmake-libpng-version-mismatch-issue | ||
# https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_FRAMEWORK.html | ||
cmake .. -DTorch_DIR="${Torch_DIR}" -DWITH_CUDA="${WITH_CUDA}" \ | ||
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \ | ||
-DCMAKE_FIND_FRAMEWORK=NEVER \ | ||
-DCMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" | ||
if [[ $OS_TYPE == windows ]]; then | ||
"${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PACKAGING_DIR}/windows/internal/build_cmake.bat" $JOBS | ||
else | ||
make -j$JOBS | ||
make install | ||
fi | ||
|
||
popd | ||
echo '::endgroup::' | ||
|
||
echo '::group::Build and run project that uses Faster-RCNN' | ||
pushd test/tracing/frcnn/build | ||
|
||
cmake .. -DTorch_DIR="${Torch_DIR}" -DWITH_CUDA="${WITH_CUDA}" \ | ||
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \ | ||
-DCMAKE_FIND_FRAMEWORK=NEVER | ||
if [[ $OS_TYPE == windows ]]; then | ||
"${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PACKAGING_DIR}/windows/internal/build_frcnn.bat" $JOBS | ||
cd Release | ||
cp ../fasterrcnn_resnet50_fpn.pt . | ||
else | ||
make -j$JOBS | ||
fi | ||
|
||
./test_frcnn_tracing | ||
|
||
popd | ||
echo '::endgroup::' | ||
|
||
echo '::group::Build and run C++ example' | ||
pushd examples/cpp/hello_world/build | ||
|
||
cmake .. -DTorch_DIR="${Torch_DIR}" \ | ||
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \ | ||
-DCMAKE_FIND_FRAMEWORK=NEVER | ||
if [[ $OS_TYPE == windows ]]; then | ||
"${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PACKAGING_DIR}/windows/internal/build_cpp_example.bat" $JOBS | ||
cd Release | ||
cp ../resnet18.pt . | ||
else | ||
make -j$JOBS | ||
fi | ||
|
||
./hello-world | ||
|
||
popd | ||
echo '::endgroup::' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: CMake | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- nightly | ||
- main | ||
- release/* | ||
workflow_dispatch: | ||
|
||
jobs: | ||
linux: | ||
strategy: | ||
matrix: | ||
include: | ||
- runner: linux.12xlarge | ||
gpu-arch-type: cpu | ||
- runner: linux.g5.4xlarge.nvidia.gpu | ||
gpu-arch-type: cuda | ||
gpu-arch-version: "11.8" | ||
fail-fast: false | ||
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main | ||
with: | ||
repository: pytorch/vision | ||
runner: ${{ matrix.runner }} | ||
gpu-arch-type: ${{ matrix.gpu-arch-type }} | ||
gpu-arch-version: ${{ matrix.gpu-arch-version }} | ||
script: | | ||
set -euo pipefail | ||
|
||
export PYTHON_VERSION=3.8 | ||
export GPU_ARCH_TYPE=${{ matrix.gpu-arch-type }} | ||
export GPU_ARCH_VERSION=${{ matrix.gpu-arch-version }} | ||
|
||
./.github/scripts/cmake.sh | ||
|
||
macos: | ||
strategy: | ||
matrix: | ||
include: | ||
- runner: macos-12 | ||
- runner: macos-m1-12 | ||
fail-fast: false | ||
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main | ||
with: | ||
repository: pytorch/vision | ||
runner: ${{ matrix.runner }} | ||
script: | | ||
set -euo pipefail | ||
|
||
export PYTHON_VERSION=3.8 | ||
export GPU_ARCH_TYPE=cpu | ||
export GPU_ARCH_VERSION='' | ||
|
||
./.github/scripts/cmake.sh | ||
|
||
windows: | ||
strategy: | ||
matrix: | ||
include: | ||
- runner: windows.4xlarge | ||
gpu-arch-type: cpu | ||
- runner: windows.g5.4xlarge.nvidia.gpu | ||
gpu-arch-type: cuda | ||
gpu-arch-version: "11.8" | ||
fail-fast: false | ||
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main | ||
with: | ||
repository: pytorch/vision | ||
runner: ${{ matrix.runner }} | ||
gpu-arch-type: ${{ matrix.gpu-arch-type }} | ||
gpu-arch-version: ${{ matrix.gpu-arch-version }} | ||
script: | | ||
set -euo pipefail | ||
|
||
source packaging/windows/internal/vc_install_helper.sh | ||
|
||
# FIXME: Basically, we are reinstalling CUDA here. We only need this, because we need to copy some files that | ||
# can be extracted from the CUDA installer, but are not available on our Windows AMI. | ||
# See https://github.com/pytorch/test-infra/pull/4189 | ||
if [[ ${{ matrix.gpu-arch-type }} == cuda ]]; then | ||
export CU_VERSION=cu$(echo ${{ matrix.gpu-arch-version }} | sed 's/\.//') | ||
echo CU_VERSION="${CU_VERSION}" | ||
packaging/windows/internal/cuda_install.bat | ||
fi | ||
Comment on lines
+82
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HI @pmeir yes totally. However I think we should ship this PR for now calling |
||
|
||
export PYTHON_VERSION=3.8 | ||
export GPU_ARCH_TYPE=${{ matrix.gpu-arch-type }} | ||
export GPU_ARCH_VERSION=${{ matrix.gpu-arch-version }} | ||
|
||
./.github/scripts/cmake.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly https://github.com/pytorch/vision/blob/main/packaging/build_cmake.sh with all the slug taken out.