Skip to content

Commit

Permalink
Merge branch 'update-cuml' of https://github.com/getumen/cuml into up…
Browse files Browse the repository at this point in the history
…date-cuml
  • Loading branch information
getumen committed Jul 31, 2024
2 parents b790353 + 4f3a45c commit 06246b1
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@
]
}
},
"hostRequirements": {
"gpu": "optional"
},
"runArgs": [ "--gpus=all" ],
"remoteUser": "root"
}
11 changes: 9 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ FROM nvidia/cuda:12.2.2-devel-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN sed -i -r 's@http://(jp\.)?archive\.ubuntu\.com/ubuntu/?@http://ftp.jaist.ac.jp/pub/Linux/ubuntu/@g' /etc/apt/sources.list

ARG CUML_VERSION=v24.06.00

RUN apt-get update \
Expand Down Expand Up @@ -80,6 +78,15 @@ RUN wget https://anaconda.org/nvidia/libcumlprims/24.06.00/download/linux-64/lib
&& cmake .. \
-DDISABLE_DEPRECATION_WARNINGS=ON \
-DUSE_CCACHE=ON \
-DCMAKE_CUDA_ARCHITECTURES="native" \
&& make install \
&& cd ../../.. \
&& rm -r cuml

RUN git clone https://github.com/gabime/spdlog.git -b v1.11.0 \
&& cd spdlog \
&& mkdir build && cd build \
&& cmake .. \
&& make install -j$(nproc) \
&& cd ../.. \
&& rm -r spdlog
10 changes: 5 additions & 5 deletions rust/src/sys/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.69.2 */
/* automatically generated by rust-bindgen 0.69.4 */

#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused)]

Expand Down Expand Up @@ -1271,9 +1271,6 @@ extern "C" {
model: FILModelHandle,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn FILGetNumClasses(model: FILModelHandle, out: *mut usize) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn FILPredict(
handle: DeviceResourceHandle,
Expand Down Expand Up @@ -1378,7 +1375,10 @@ extern "C" {
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn UseArenaMemoryResource(resource: *mut DeviceMemoryResource) -> ::std::os::raw::c_int;
pub fn UseArenaMemoryResource(
resource: *mut DeviceMemoryResource,
arena_size: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ResetMemoryResource(
Expand Down
7 changes: 4 additions & 3 deletions testdata/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
100,
)

booster.save_model("xgboost.model")
booster.save_model("xgboost.json")

test_x.to_csv("feature.csv", index=False, header=False, float_format="%.8f")
test_y.to_csv("label.csv", index=False, header=False, float_format="%.8f")
Expand All @@ -63,6 +63,7 @@

tl2cgen.annotate_branch(model=model, dmat=dvalid, path="annotation.json", verbose=True)

print("Exporting model to C code")
tl2cgen.export_lib(
model=model,
toolchain="gcc",
Expand All @@ -74,12 +75,12 @@
verbose=True,
)

print("Predicting with Treelite")
predictor = tl2cgen.Predictor(
f"compiled-model.{shared_library_extension}",
nthread=os.cpu_count(),
verbose=True,
)

print("Predicting with Treelite")
# [batch_size, 1, 1]
treelite_scores = predictor.predict(dvalid, verbose=True)

Expand Down
1 change: 1 addition & 0 deletions testdata/xgboost.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ FetchContent_MakeAvailable(googletest)

add_executable(
cuml_test
memory_resource_test.cpp
clustering_test.cpp
fil_test.cpp
linear_regression_test.cpp
# fil_test.cpp
# linear_regression_test.cpp
)

target_compile_options(cuml_test PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--expt-extended-lambda --expt-relaxed-constexpr>)
Expand Down
4 changes: 2 additions & 2 deletions tests/fil_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TEST(FILTest, TestTreelite)
std::string json_config = "{\"allow_unknown_field\": True}";

TreeliteModelHandle handle;
auto res = TreeliteLoadXGBoostModel("testdata/xgboost.model", json_config.c_str(), &handle);
auto res = TreeliteLoadXGBoostModel("testdata/xgboost.json", json_config.c_str(), &handle);
EXPECT_EQ(res, 0);

res = TreeliteFreeModel(handle);
Expand All @@ -25,7 +25,7 @@ TEST(FILTest, TestFIL)
CreateDeviceResourceHandle(&device_resource_handle);

DeviceMemoryResource mr;
UseArenaMemoryResource(&mr, 1024 * 1024);
UseArenaMemoryResource(&mr, 64 * 1024);

FILModelHandle handle;
auto res = FILLoadModel(device_resource_handle, 0, "testdata/xgboost.model", 0, true, 0.5, 0, 0, 1, 0, &handle);
Expand Down
43 changes: 43 additions & 0 deletions tests/memory_resource_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <gtest/gtest.h>

#include "cuml4c/device_resource_handle.h"
#include "cuml4c/memory_resource.h"

TEST(MemoryResourceTest, TestUsePoolMemoryResource)
{
DeviceResourceHandle device_resource_handle;
CreateDeviceResourceHandle(&device_resource_handle);

DeviceMemoryResource mr;
UsePoolMemoryResource(1024 * 1024, 8 * 1024 * 1024, &mr);

ResetMemoryResource(mr, 0);

FreeDeviceResourceHandle(device_resource_handle);
}

TEST(MemoryResourceTest, TestUseBinningMemoryResource)
{
DeviceResourceHandle device_resource_handle;
CreateDeviceResourceHandle(&device_resource_handle);

DeviceMemoryResource mr;
UseBinningMemoryResource(3, 10, &mr);

ResetMemoryResource(mr, 1);

FreeDeviceResourceHandle(device_resource_handle);
}

TEST(MemoryResourceTest, TestUseArenaMemoryResource)
{
DeviceResourceHandle device_resource_handle;
CreateDeviceResourceHandle(&device_resource_handle);

DeviceMemoryResource mr;
UseArenaMemoryResource(&mr, 1024 * 1024);

ResetMemoryResource(mr, 2);

FreeDeviceResourceHandle(device_resource_handle);
}

0 comments on commit 06246b1

Please sign in to comment.