An unofficial Julia wrapper for the RAPIDS.ai ecosystem using PythonCall.jl
MIT License
⚠️ RAPIDS.jl is only supported on Julia 1.8.5+. For previous Julia versions, you have to manually upgrade to libraries from GCC 12.
Unofficial Julia wrapper for the RAPIDS.ai ecosystem.
The goal of this library is to provide a simple method for accessing the GPU accelerated models withing RAPIDS from Julia, and integrating the models into MLJ. This library relies on PythonCall.jl and CondaPkg.jl for efficient installations of the Python dependencies.
This wrapper could be broken up into several libraries (cuDF
, cuML
, cuGraph
, cuSpatial
), but there would be significant overlap between these libraries. Large dependencies such as cudatoolkit
would be repeated.
Long term, directly wrapping libcudf
, libcuml
... would greatly improve this library, but I don't have time to tackle that at this moment.
More information is available here.
From the Julia General Registry:
julia> ] # enters the pkg interface
pkg> add RAPIDS
julia> using Pkg; Pkg.add("RAPIDS")
From source:
julia> ]add https://github.com/tylerjthomas9/RAPIDS.jl
julia> using Pkg; Pkg.add(url="https://github.com/tylerjthomas9/RAPIDS.jl")
You can access the following python libraries with their standard syntax:
cupy
cudf
cuml
cugraph
cuspatial
cuxfilter
dask
dask_cuda
dask_cudf
numpy
pickle
Here is an example of using LogisticRegression
, make_classification
via the Python API.
using RAPIDS
const make_classification = cuml.datasets.classification.make_classification
X_py, y_py = make_classification(n_samples=200, n_features=4,
n_informative=2, n_classes=2)
lr = cuml.LogisticRegression(max_iter=100)
lr.fit(X_py, y_py)
preds = lr.predict(X_py)
print(lr.coef_)
A MLJ interface is also available for supported models. The model hyperparameters are the same as described in the cuML docs. The only difference is that the models will always input/output numpy arrays, which will be converted back to Julia arrays (output_type="input"
).
using MLJBase
using RAPIDS.CuML
const make_classification = cuml.datasets.classification.make_classification
X_py, y_py = make_classification(n_samples=200, n_features=4,
n_informative=2, n_classes=2)
X = RAPIDS.pyconvert(Matrix{Float32}, X_py.get())
y = RAPIDS.pyconvert(Vector{Float32}, y_py.get().flatten())
lr = LogisticRegression(max_iter=100)
mach = machine(lr, X, y)
fit!(mach)
preds = predict(mach, X)
print(mach.fitresult.coef_)
MLJ Support:
KMeans
DBSCAN
AgglomerativeClustering
HDBSCAN
LogisticRegression
MBSGDClassifier
RandomForestClassifier
SVC
LinearSVC
KNeighborsClassifier
LinearRegression
Ridge
Lasso
ElasticNet
MBSGDRegressor
RandomForestRegressor
CD
SVR
LinearSVR
KNeighborsRegressor
PCA
IncrementalPCA
TruncatedSVD
UMAP
TSNE
GaussianRandomProjection
ExponentialSmoothing
ARIMA