[CI] Test C API demo (#6159)
* Fix CMake install config to use dependencies * [CI] Test C API demo * Explicitly cast num_feature, to avoid warning in Linux
This commit is contained in:
parent
bd2b1eabd0
commit
2c4dedb7a0
41
.github/workflows/main.yml
vendored
41
.github/workflows/main.yml
vendored
@ -35,6 +35,47 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd build
|
cd build
|
||||||
ctest --extra-verbose
|
ctest --extra-verbose
|
||||||
|
c-api-demo:
|
||||||
|
name: Test installing XGBoost lib + building the C API demo
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: ["ubuntu-latest"]
|
||||||
|
python-version: ["3.8"]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
- name: Install system packages
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y --no-install-recommends ninja-build
|
||||||
|
- uses: conda-incubator/setup-miniconda@v1
|
||||||
|
with:
|
||||||
|
auto-update-conda: true
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Display Conda env
|
||||||
|
shell: bash -l {0}
|
||||||
|
run: |
|
||||||
|
conda info
|
||||||
|
conda list
|
||||||
|
- name: Build and install XGBoost
|
||||||
|
shell: bash -l {0}
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. -DBUILD_STATIC_LIB=ON -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -GNinja
|
||||||
|
ninja -v install
|
||||||
|
- name: Build and run C API demo
|
||||||
|
shell: bash -l {0}
|
||||||
|
run: |
|
||||||
|
cd demo/c-api/
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. -GNinja -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
|
||||||
|
ninja -v
|
||||||
|
cd ..
|
||||||
|
./build/api-demo
|
||||||
test-with-jvm:
|
test-with-jvm:
|
||||||
name: Test JVM on OS ${{ matrix.os }}
|
name: Test JVM on OS ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|||||||
@ -290,7 +290,7 @@ install(DIRECTORY ${xgboost_SOURCE_DIR}/include/xgboost
|
|||||||
#
|
#
|
||||||
# https://github.com/dmlc/xgboost/issues/6085
|
# https://github.com/dmlc/xgboost/issues/6085
|
||||||
if (BUILD_STATIC_LIB)
|
if (BUILD_STATIC_LIB)
|
||||||
set(INSTALL_TARGETS xgboost runxgboost objxgboost rabit)
|
set(INSTALL_TARGETS xgboost runxgboost objxgboost rabit dmlc)
|
||||||
else (BUILD_STATIC_LIB)
|
else (BUILD_STATIC_LIB)
|
||||||
set(INSTALL_TARGETS xgboost runxgboost)
|
set(INSTALL_TARGETS xgboost runxgboost)
|
||||||
endif (BUILD_STATIC_LIB)
|
endif (BUILD_STATIC_LIB)
|
||||||
|
|||||||
@ -1,5 +1,24 @@
|
|||||||
@PACKAGE_INIT@
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
|
||||||
|
set(USE_OPENMP @USE_OPENMP@)
|
||||||
|
set(USE_CUDA @USE_CUDA@)
|
||||||
|
set(USE_NCCL @USE_NCCL@)
|
||||||
|
|
||||||
|
find_dependency(Threads)
|
||||||
|
if(USE_OPENMP)
|
||||||
|
find_dependency(OpenMP)
|
||||||
|
endif()
|
||||||
|
if(USE_CUDA)
|
||||||
|
find_dependency(CUDA)
|
||||||
|
endif()
|
||||||
|
if(USE_NCCL)
|
||||||
|
find_dependency(Nccl)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT TARGET xgboost::xgboost)
|
if(NOT TARGET xgboost::xgboost)
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/XGBoostTargets.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/XGBoostTargets.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Found XGBoost (found version \"${xgboost_VERSION}\")")
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
project(api-demo LANGUAGES C CXX VERSION 0.0.1)
|
||||||
find_package(xgboost REQUIRED)
|
find_package(xgboost REQUIRED)
|
||||||
add_executable(api-demo c-api-demo.c)
|
add_executable(api-demo c-api-demo.c)
|
||||||
target_link_libraries(api-demo xgboost::xgboost)
|
target_link_libraries(api-demo PRIVATE xgboost::xgboost)
|
||||||
|
|||||||
@ -62,7 +62,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
bst_ulong num_feature = 0;
|
bst_ulong num_feature = 0;
|
||||||
safe_xgboost(XGBoosterGetNumFeature(booster, &num_feature));
|
safe_xgboost(XGBoosterGetNumFeature(booster, &num_feature));
|
||||||
printf("num_feature: %llu\n", num_feature);
|
printf("num_feature: %lu\n", (unsigned long)(num_feature));
|
||||||
|
|
||||||
// predict
|
// predict
|
||||||
bst_ulong out_len = 0;
|
bst_ulong out_len = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user