.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "python/rmm-examples/rmm_singlegpu.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_python_rmm-examples_rmm_singlegpu.py: Using rmm on a single node device ================================= .. GENERATED FROM PYTHON SOURCE LINES 5-29 .. code-block:: Python import rmm from sklearn.datasets import make_classification import xgboost as xgb # Initialize RMM pool allocator rmm.reinitialize(pool_allocator=True) # Optionally force XGBoost to use RMM for all GPU memory allocation, see ./README.md # xgb.set_config(use_rmm=True) X, y = make_classification(n_samples=10000, n_informative=5, n_classes=3) dtrain = xgb.DMatrix(X, label=y) params = { "max_depth": 8, "eta": 0.01, "objective": "multi:softprob", "num_class": 3, "tree_method": "hist", "device": "cuda", } # XGBoost will automatically use the RMM pool allocator bst = xgb.train(params, dtrain, num_boost_round=100, evals=[(dtrain, "train")]) .. _sphx_glr_download_python_rmm-examples_rmm_singlegpu.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: rmm_singlegpu.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: rmm_singlegpu.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: rmm_singlegpu.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_