Dear Roofit experts,
I am trying to apply the new CUDA acceleration in my Roofit code, but it is somehow printing errors. The ROOT version is ‘6.32.02’ and here’s my small reproducer code:
import ROOT
from ROOT import RooFit, RooRealVar, RooGaussian, RooDataSet, RooFitResult, RooAbsReal
def fit_with_cuda():
# Define observable
x = RooRealVar("x", "x", -10, 10)
# Define parameters
mean = RooRealVar("mean", "mean", 0, -10, 10)
sigma = RooRealVar("sigma", "sigma", 1, 0.1, 10)
# Define Gaussian PDF
gauss = RooGaussian("gauss", "gaussian PDF", x, mean, sigma)
# Generate a toy dataset
data = gauss.generate(ROOT.RooArgSet(x), 100)
data.Print("v")
# Perform the fit
result = gauss.fitTo(data, RooFit.Save(), EvalBackend="cuda")
# Print results
result.Print()
# Run the fit function
fit_with_cuda()
This code returns with:
[#1] INFO:Fitting -- RooAbsPdf::fitTo(gauss_over_gauss_Int[x]) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- using CPU computation library compiled with -mavx2
[#1] INFO:Fitting -- using CUDA computation library
Traceback (most recent call last):
File "/work/users/yun79/valerie/fork/copperheadV2/quick_tests/quic_cuda_test.py", line 35, in <module>
fit_with_cuda()
File "/work/users/yun79/valerie/fork/copperheadV2/quick_tests/quic_cuda_test.py", line 29, in fit_with_cuda
result = gauss.fitTo(data, RooFit.Save(), EvalBackend="cuda")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/depot/cms/kernels/root632/lib/python3.12/site-packages/ROOT/_pythonization/_roofit/_rooabspdf.py", line 62, in fitTo
return self._fitTo["RooLinkedList const&"](args[0], _pack_cmd_args(*args[1:], **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cppyy.gbl.std.runtime_error: Could not find "fitTo<RooLinkedList const&>" (set cppyy.set_debug() for C++ errors):
RooFitResult* RooAbsPdf::fitTo(RooAbsData& data, const RooLinkedList& cmdArgs) =>
runtime_error: copyHostToDeviceImpl(), /depot/cms/purdue-af/roofit-batchcompute/src/CudaInterface.cu:160 : invalid argument
I took a quick look at line 160 of CudaInterface.cu, which is ERRCHECK(cudaMemcpy(dest, src, nBytes, cudaMemcpyHostToDevice));
, implying that moving the data on system memory to GPU memory is failing. I would appreciate any help on this matter.
Thank you in advance!
Hyeon-Seo