Skip to content

Commit

Permalink
Speed up tests with federated learning enabled (#8350)
Browse files Browse the repository at this point in the history
* Speed up tests with federated learning enabled

* Re-enable timeouts

Co-authored-by: Hyunsu Philip Cho <chohyu01@cs.washington.edu>
  • Loading branch information
rongou and hcho3 committed Oct 17, 2022
1 parent 031d66e commit 8f3dee5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion plugin/federated/CMakeLists.txt
Expand Up @@ -29,5 +29,5 @@ target_link_libraries(federated_client INTERFACE federated_proto)

# Rabit engine for Federated Learning.
target_sources(objxgboost PRIVATE federated_server.cc)
target_link_libraries(objxgboost PRIVATE federated_client)
target_link_libraries(objxgboost PRIVATE federated_client "-Wl,--exclude-libs,ALL")
target_compile_definitions(objxgboost PUBLIC -DXGBOOST_USE_FEDERATED=1)
2 changes: 1 addition & 1 deletion python-package/xgboost/testing.py
Expand Up @@ -41,7 +41,7 @@ def skip_ipv6() -> PytestSkip:
return {"condition": not has_ipv6(), "reason": "IPv6 is required to be enabled."}


def timeout(sec: int, *args: Any, enable: bool = False, **kwargs: Any) -> Any:
def timeout(sec: int, *args: Any, enable: bool = True, **kwargs: Any) -> Any:
"""Make a pytest mark for the `pytest-timeout` package.
Parameters
Expand Down
16 changes: 6 additions & 10 deletions src/c_api/c_api.cu
Expand Up @@ -42,19 +42,15 @@ void XGBBuildInfoDevice(Json *p_info) {
}

void XGBoostAPIGuard::SetGPUAttribute() {
try {
device_id_ = dh::CurrentDevice();
} catch (dmlc::Error const&) {
// do nothing, running on CPU only machine
}
// Not calling `safe_cuda` to avoid unnecessary exception handling overhead.
// If errors, do nothing, assuming running on CPU only machine.
cudaGetDevice(&device_id_);
}

void XGBoostAPIGuard::RestoreGPUAttribute() {
try {
dh::safe_cuda(cudaSetDevice(device_id_));
} catch (dmlc::Error const&) {
// do nothing, running on CPU only machine
}
// Not calling `safe_cuda` to avoid unnecessary exception handling overhead.
// If errors, do nothing, assuming running on CPU only machine.
cudaSetDevice(device_id_);
}
} // namespace xgboost

Expand Down
2 changes: 1 addition & 1 deletion tests/ci_build/Dockerfile.cpu
Expand Up @@ -30,7 +30,7 @@ ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN git clone -b v1.49.1 https://github.com/grpc/grpc.git \
--recurse-submodules --depth 1 --shallow-submodules && \
pushd grpc && \
cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=/opt/grpc && \
cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=/opt/grpc -DCMAKE_CXX_VISIBILITY_PRESET=hidden && \
cmake --build build --target install && \
popd && \
rm -rf grpc
Expand Down
2 changes: 1 addition & 1 deletion tests/ci_build/Dockerfile.gpu_build_centos7
Expand Up @@ -39,7 +39,7 @@ ENV GOSU_VERSION 1.10
RUN git clone -b v1.49.1 https://github.com/grpc/grpc.git \
--recurse-submodules --depth 1 && \
pushd grpc && \
cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=/opt/grpc && \
cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=/opt/grpc -DCMAKE_CXX_VISIBILITY_PRESET=hidden && \
cmake --build build --target install && \
popd && \
rm -rf grpc
Expand Down

0 comments on commit 8f3dee5

Please sign in to comment.