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

[WIP] Force VS2019 as CMake generator #7689

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .github/scripts/cmake.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake .. -DTorch_DIR="%1"^
-DWITH_CUDA=%2^
-DCMAKE_PREFIX_PATH="%CONDA_PREFIX%"^
-DCMAKE_FIND_FRAMEWORK=NEVER^
-DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%"
40 changes: 24 additions & 16 deletions .github/scripts/cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fi
TORCH_PATH=$(python -c "import pathlib, torch; print(pathlib.Path(torch.__path__[0]))")
if [[ $OS_TYPE == windows ]]; then
PACKAGING_DIR="${PWD}/packaging"
SCRIPTS_DIR=${PWD}/.github/scripts
export PATH="${TORCH_PATH}/lib:${PATH}"
fi

Expand Down Expand Up @@ -65,19 +66,22 @@ 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" "${SCRIPTS_DIR}/cmake.bat" $Torch_DIR $WITH_CUDA
"${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PACKAGING_DIR}/windows/internal/build_cmake.bat" $JOBS
else
# 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}"

make -j$JOBS
make install
fi
Expand All @@ -88,14 +92,16 @@ 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" "${SCRIPTS_DIR}/cmake.bat" $Torch_DIR $WITH_CUDA
"${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PACKAGING_DIR}/windows/internal/build_frcnn.bat" $JOBS
cd Release
cp ../fasterrcnn_resnet50_fpn.pt .
else
cmake .. -DTorch_DIR="${Torch_DIR}" -DWITH_CUDA="${WITH_CUDA}" \
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \
-DCMAKE_FIND_FRAMEWORK=NEVER

make -j$JOBS
fi

Expand All @@ -107,14 +113,16 @@ 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" "${SCRIPTS_DIR}/cmake.bat" $Torch_DIR $WITH_CUDA
"${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PACKAGING_DIR}/windows/internal/build_cpp_example.bat" $JOBS
cd Release
cp ../resnet18.pt .
else
cmake .. -DTorch_DIR="${Torch_DIR}" \
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \
-DCMAKE_FIND_FRAMEWORK=NEVER

make -j$JOBS
fi

Expand Down
Loading