Skip to content

Commit 8f3dee5

Browse files
rongouhcho3
andauthored
Speed up tests with federated learning enabled (dmlc#8350)
* Speed up tests with federated learning enabled * Re-enable timeouts Co-authored-by: Hyunsu Philip Cho <[email protected]>
1 parent 031d66e commit 8f3dee5

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

plugin/federated/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ target_link_libraries(federated_client INTERFACE federated_proto)
2929

3030
# Rabit engine for Federated Learning.
3131
target_sources(objxgboost PRIVATE federated_server.cc)
32-
target_link_libraries(objxgboost PRIVATE federated_client)
32+
target_link_libraries(objxgboost PRIVATE federated_client "-Wl,--exclude-libs,ALL")
3333
target_compile_definitions(objxgboost PUBLIC -DXGBOOST_USE_FEDERATED=1)

python-package/xgboost/testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def skip_ipv6() -> PytestSkip:
4141
return {"condition": not has_ipv6(), "reason": "IPv6 is required to be enabled."}
4242

4343

44-
def timeout(sec: int, *args: Any, enable: bool = False, **kwargs: Any) -> Any:
44+
def timeout(sec: int, *args: Any, enable: bool = True, **kwargs: Any) -> Any:
4545
"""Make a pytest mark for the `pytest-timeout` package.
4646
4747
Parameters

src/c_api/c_api.cu

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,15 @@ void XGBBuildInfoDevice(Json *p_info) {
4242
}
4343

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

5250
void XGBoostAPIGuard::RestoreGPUAttribute() {
53-
try {
54-
dh::safe_cuda(cudaSetDevice(device_id_));
55-
} catch (dmlc::Error const&) {
56-
// do nothing, running on CPU only machine
57-
}
51+
// Not calling `safe_cuda` to avoid unnecessary exception handling overhead.
52+
// If errors, do nothing, assuming running on CPU only machine.
53+
cudaSetDevice(device_id_);
5854
}
5955
} // namespace xgboost
6056

tests/ci_build/Dockerfile.cpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
3030
RUN git clone -b v1.49.1 https://github.com/grpc/grpc.git \
3131
--recurse-submodules --depth 1 --shallow-submodules && \
3232
pushd grpc && \
33-
cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=/opt/grpc && \
33+
cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=/opt/grpc -DCMAKE_CXX_VISIBILITY_PRESET=hidden && \
3434
cmake --build build --target install && \
3535
popd && \
3636
rm -rf grpc

tests/ci_build/Dockerfile.gpu_build_centos7

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ENV GOSU_VERSION 1.10
3939
RUN git clone -b v1.49.1 https://github.com/grpc/grpc.git \
4040
--recurse-submodules --depth 1 && \
4141
pushd grpc && \
42-
cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=/opt/grpc && \
42+
cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=/opt/grpc -DCMAKE_CXX_VISIBILITY_PRESET=hidden && \
4343
cmake --build build --target install && \
4444
popd && \
4545
rm -rf grpc

0 commit comments

Comments
 (0)