Using CUDA in pyROOT

Dear Experts

I have installed ROOT with CUDA support. The following output proves it i guess:

╭─ WSL at    ~/root/root_build                                                                                                                                        14:00:33  ─╮
╰─ root-config --features | grep -i cuda
cxx17 asimage builtin_afterimage builtin_clang builtin_cling builtin_llvm builtin_openui5 cuda cudnn dataframe fitsio gdml http imt mysql opengl pyroot roofit webgui root7 rpath runtime_cxxmodules shared ssl tmva tmva-gpu tmva-pymva spectrum vdt x11 xml

How do I use CUDA for training ? The following is my code in python.:slight_smile:

tmvaFactory = ROOT.TMVA.Factory("TMVAClassification", file_output, "V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification")
tmvaDataLoader = ROOT.TMVA.DataLoader("dataset")

tmvaDataLoader.AddVariable("fPosX","F")
tmvaDataLoader.AddVariable("fPosY","F")
tmvaDataLoader.AddVariable("fPosZ","F")       

# tmvaDataLoader.AddVariable("fFv0signal","F")
# tmvaDataLoader.AddVariable("fFt0asignal","F") 
# tmvaDataLoader.AddVariable("fFt0csignal","F") 
tmvaDataLoader.AddVariable("fFddasignal","F")
tmvaDataLoader.AddVariable("fFddcsignal","F")

tmvaDataLoader.AddVariable("fTimeFt0a","F")   
# tmvaDataLoader.AddVariable("fTimeFt0c","F")   
tmvaDataLoader.AddVariable("fTimeFdda","F")
tmvaDataLoader.AddVariable("fTimeFddc","F")

tmvaDataLoader.AddVariable("fFourPionPt","F")
tmvaDataLoader.AddVariable("fFourPionEta","F")
# tmvaDataLoader.AddVariable("fFourPionRapidity","F") 
tmvaDataLoader.AddVariable("fFourPionPhi","F")

tmvaDataLoader.AddSignalTree(tree_mc, 1.0)
tmvaDataLoader.AddBackgroundTree(tree_data, 1.0)
SignalCuts = ROOT.TCut("fFourPionPt < 0.15 && abs(fFourPionRapidity) < 0.5")
BackgroundCuts = ROOT.TCut("fFourPionPt < 0.15 && abs(fFourPionRapidity) < 0.5")
tmvaDataLoader.PrepareTrainingAndTestTree(SignalCuts, BackgroundCuts, "SplitMode=Random:V")
tmvaFactory.BookMethod(tmvaDataLoader, 
                       ROOT.TMVA.Types.kBDT, 
                       f"BDT",
                       f"NTrees={NTrees}:MaxDepth={MaxDepth}:BoostType=Grad:Shrinkage={Shrinkage}:"
                       f"UseBaggedBoost=True:BaggedSampleFraction={BaggedSampleFraction}:"
                       f"nCuts={nCuts}:MinNodeSize={minNodeSize}"
                       f"CreateMVAGPU=True"
                       )
tmvaFactory.TrainAllMethods()
tmvaFactory.TestAllMethods()
tmvaFactory.EvaluateAllMethods()

How should I change my code so that the training uses CUDA? Or is it that it automatically uses CUDA?

Thanks in Advance

Adding @moneta in the loop