Skip to content

Commit

Permalink
Fix caffe2 windows CI for new Windows AMI (#21452)
Browse files Browse the repository at this point in the history
Summary:
The alternative of #21410.
Pull Request resolved: pytorch/pytorch#21452

Differential Revision: D15701767

Pulled By: ezyang

fbshipit-source-id: e65c1d6bfcc98e88460f4a57e5b99c2f395c0ceb
  • Loading branch information
peterjc123 authored and facebook-github-bot committed Jun 6, 2019
1 parent 3feb40d commit bb78863
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .jenkins/pytorch/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ test_libtorch() {
python test/cpp/jit/tests_setup.py setup
CPP_BUILD="$PWD/../cpp-build"
if [[ "$BUILD_ENVIRONMENT" == *cuda* ]]; then
"$CPP_BUILD"/caffe2/bin/test_jit
"$CPP_BUILD"/caffe2/build/bin/test_jit
else
"$CPP_BUILD"/caffe2/bin/test_jit "[cpu]"
"$CPP_BUILD"/caffe2/build/bin/test_jit "[cpu]"
fi
python test/cpp/jit/tests_setup.py shutdown
python tools/download_mnist.py --quiet -d test/cpp/api/mnist
OMP_NUM_THREADS=2 TORCH_CPP_TEST_MNIST_PATH="test/cpp/api/mnist" "$CPP_BUILD"/caffe2/bin/test_api
OMP_NUM_THREADS=2 TORCH_CPP_TEST_MNIST_PATH="test/cpp/api/mnist" "$CPP_BUILD"/caffe2/build/bin/test_api
assert_git_not_dirty
fi
}
Expand Down
1 change: 0 additions & 1 deletion .jenkins/pytorch/win-test-helpers/build_pytorch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ if not "%USE_CUDA%"=="0" (
if "%BUILD_ENVIRONMENT%"=="" (
echo NOTE: To run `import torch`, please make sure to activate the conda environment by running `call %CONDA_PARENT_DIR%\Miniconda3\Scripts\activate.bat %CONDA_PARENT_DIR%\Miniconda3` in Command Prompt before running Git Bash.
) else (
mv %CD%\build\bin\test_api.exe %CONDA_PARENT_DIR%\Miniconda3\Lib\site-packages\torch\lib
7z a %TMP_DIR_WIN%\%IMAGE_COMMIT_TAG%.7z %CONDA_PARENT_DIR%\Miniconda3\Lib\site-packages\torch %CONDA_PARENT_DIR%\Miniconda3\Lib\site-packages\caffe2 && python %SCRIPT_HELPERS_DIR%\upload_image.py %TMP_DIR_WIN%\%IMAGE_COMMIT_TAG%.7z
)
)
Expand Down
8 changes: 3 additions & 5 deletions .jenkins/pytorch/win-test-helpers/test_libtorch.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
call %SCRIPT_HELPERS_DIR%\setup_pytorch_env.bat

dir
dir %TMP_DIR_WIN%\build
dir %TMP_DIR_WIN%\build\torch
dir %TMP_DIR_WIN%\build\torch\lib
cd %TMP_DIR_WIN%\build\torch\lib
cd %TMP_DIR_WIN%\build\torch\bin
set PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt\bin\x64;%TMP_DIR_WIN%\build\torch\lib;%PATH%
test_api.exe --gtest_filter="-IntegrationTest.MNIST*"

if errorlevel 1 exit /b 1
8 changes: 4 additions & 4 deletions caffe2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1095,10 +1095,10 @@ if (BUILD_TEST)
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
if (INSTALL_TEST)
install(TARGETS ${test_name} DESTINATION test)
# Install PDB files for MSVC builds
if (MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:${test_name}> DESTINATION test OPTIONAL)
endif()
# Install PDB files for MSVC builds
if (MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:${test_name}> DESTINATION test OPTIONAL)
endif()
endif()
endforeach()

Expand Down
10 changes: 9 additions & 1 deletion cmake/public/cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ if(CUDA_FOUND)
# compiling with, e.g., if a ccache nvcc is fed to us by CUDA_NVCC_EXECUTABLE
# but the PATH is not consistent with CUDA_HOME. It's better safe
# than sorry: make sure everything is consistent.
if(MSVC AND CMAKE_GENERATOR MATCHES "Visual Studio")
# When using Visual Studio, it attempts to lock the whole binary dir when
# `try_run` is called, which will cause the build to fail.
string(RANDOM BUILD_SUFFIX)
set(PROJECT_RANDOM_BINARY_DIR "${PROJECT_BINARY_DIR}/${BUILD_SUFFIX}")
else()
set(PROJECT_RANDOM_BINARY_DIR "${PROJECT_BINARY_DIR}")
endif()
set(file "${PROJECT_BINARY_DIR}/detect_cuda_version.cc")
file(WRITE ${file} ""
"#include <cuda.h>\n"
Expand All @@ -56,7 +64,7 @@ if(CUDA_FOUND)
" return 0;\n"
"}\n"
)
try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file}
try_run(run_result compile_result ${PROJECT_RANDOM_BINARY_DIR} ${file}
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS}"
LINK_LIBRARIES ${CUDA_LIBRARIES}
RUN_OUTPUT_VARIABLE cuda_version_from_header
Expand Down
8 changes: 8 additions & 0 deletions test/cpp/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ if (NOT MSVC)
-Wno-unused-but-set-parameter)
endif()
endif()

if (INSTALL_TEST)
install(TARGETS test_api DESTINATION bin)
# Install PDB files for MSVC builds
if (MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:test_api> DESTINATION bin OPTIONAL)
endif()
endif()
8 changes: 8 additions & 0 deletions test/cpp/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ if (USE_CUDA)

target_compile_definitions(test_jit PRIVATE USE_CUDA)
endif()

if (INSTALL_TEST)
install(TARGETS test_jit DESTINATION bin)
# Install PDB files for MSVC builds
if (MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:test_jit> DESTINATION bin OPTIONAL)
endif()
endif()
2 changes: 1 addition & 1 deletion tools/build_libtorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
options = parser.parse_args()

build_caffe2(version=None, cmake_python_library=None, build_python=False,
rerun_cmake=True, cmake_only=False, build_dir='.')
rerun_cmake=True, cmake_only=False, build_dir='build')

0 comments on commit bb78863

Please sign in to comment.