From 52b54685e1ff63d1649ecf8942f352b9d6f3d427 Mon Sep 17 00:00:00 2001 From: tiyn Date: Thu, 11 Jun 2026 23:15:30 +0200 Subject: [PATCH] Programming Languages/Python: Added scikit-learn and cuml acceleration --- wiki/programming_language/python.md | 37 +++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/wiki/programming_language/python.md b/wiki/programming_language/python.md index e0ff720..7464bbc 100644 --- a/wiki/programming_language/python.md +++ b/wiki/programming_language/python.md @@ -149,7 +149,7 @@ Since uv is a project-based tool the following command has to be used to create `` is the path to the project directory. If it is omitted the project will be created in the current working directory. -```sh +```sh uv init ``` @@ -160,10 +160,17 @@ To use uv as a virtual environment similar to venv the following command can be project directory. It will create a `.venv` directory containing the `bin/activate` file. -```sh +```sh uv venv ``` +Packages can then be installed using the following command. +`` is the name of the package to install. + +```sh +uv add +``` + #### venv Virtual Environments [venv](https://docs.python.org/3/library/venv.html) can be used to create a virtual environment. @@ -217,6 +224,32 @@ This flag is to be used with care. This section addresses various different modules. +### scikit-learn + +[scikit-learn](https://scikit-learn.org/stable/index.html) is a free and open-source library that +provides various machine learning algorithms. +By default, [scikit-learn](https://scikit-learn.org/stable/index.html) does only utilize the CPU. +This, however, can be easily changed to also utilize the GPU and speed up calculation as explained +in the [corresponding section](#run-scikit-learn-algorithms-on-the-gpu) + +#### Run scikit-learn Algorithms on the GPU + +Using [cuml](https://docs.rapids.ai/api/cuml/latest/) the GPU can be utilized with only two lines +to add to existing code. +As explained in the +[cuml guide on zero code change acceleration](https://docs.rapids.ai/api/cuml/latest/cuml-accel/) +only the following two lines have to be added to run the scikit-learn algorithms on the GPU. +Additionally, cuml has to be installed using a [Python package manager](#using-virtual-environments) +like [uv](#uv-virtual-environments). +It is important that these lines are put before importing any scikit-learn packages. + +```py +import cuml +cuml.accel.install() +``` + +Afterwards all possible scikit-learn algorithms will run on the GPU instead of the CPU. + ### PyTorch This section addresses the [PyTorch module](https://pytorch.org/).