# Installation Guide

XGBoost provides binary packages for some language bindings.  The binary packages support
the GPU algorithm (`device=cuda:0`) on machines with NVIDIA GPUs. Please note that
**training with multiple GPUs is only supported for Linux platform**. See
[XGBoost GPU Support](gpu/index.html.md).  Also we have both stable releases and nightly builds, see below for how
to install them.  For building from source, visit [this page](build.html.md).

> ##### Contents
> 
> * [Installation Guide](#installation-guide)
>   * [Stable Release](#stable-release)
>     * [Python](#python)
>       * [CUDA toolkit variants (Linux)](#cuda-toolkit-variants-linux)
>       * [Minimal installation (CPU-only)](#minimal-installation-cpu-only)
>       * [Conda](#conda)
>     * [R](#r)
>     * [JVM](#jvm)
>   * [Nightly Build](#nightly-build)
>     * [Python](#id1)
>     * [R](#id2)
>     * [JVM](#id4)

## Stable Release

### Python

Pre-built binary wheels are uploaded to PyPI (Python Package Index) for each release. Supported platforms are Linux (x86_64, aarch64), Windows (x86_64, aarch64) and MacOS (x86_64, Apple Silicon).

```bash
pip install xgboost
```

You might need to run the command with `--user` flag or use `virtualenv` if you run into permission errors.

#### NOTE
Windows users need to install Visual C++ Redistributable

XGBoost requires DLLs from [Visual C++ Redistributable](https://www.microsoft.com/en-us/download/details.aspx?id=48145)
in order to function, so make sure to install it. Exception: If
you have Visual Studio installed, you already have access to
necessary libraries and thus don’t need to install Visual C++
Redistributable.

Capabilities of binary wheels for each platform:

| Platform            | GPU   | Multi-Node-Multi-GPU   |
|---------------------|-------|------------------------|
| Linux x86_64        | ✔     | ✔                      |
| Linux aarch64       | ✔     | ✔                      |
| MacOS x86_64        | ✘     | ✘                      |
| MacOS Apple Silicon | ✘     | ✘                      |
| Windows             | ✔     | ✘                      |
| Windows aarch64     | ✘     | ✘                      |

Linux aarch64 wheels now ship with CUDA support, so `pip install xgboost` on modern
Jetson or Graviton machines provides the same GPU functionality as the Linux x86_64
wheel.

<a id="wheel-cuda"></a>

#### CUDA toolkit variants (Linux)

The default `xgboost` wheel for Linux x86_64 and aarch64 is built with CUDA Toolkit 13.x:

```bash
pip install xgboost
```

Users with GPU whose NVIDIA driver supports CUDA 12 but not CUDA 13 can instead install the CUDA 12 package:

```bash
pip uninstall xgboost xgboost-cu12
pip install xgboost-cu12
```

The CUDA 12 package is a driver-compatibility option.

#### Minimal installation (CPU-only)

The default installation with `pip` will install the full XGBoost package, including support for GPU algorithms.

You may choose to reduce the size of the installed package and save the disk space, by opting to install `xgboost-cpu` instead:

```bash
pip install xgboost-cpu
```

The `xgboost-cpu` variant has a drastically smaller disk footprint, but does not provide GPU algorithms.

#### Conda

You may use the Conda packaging manager to install XGBoost:

```bash
conda install -c conda-forge py-xgboost
```

Conda should be able to detect the existence of a GPU on your machine and install the correct variant of XGBoost. If you run into issues, try indicating the variant explicitly:

```bash
# CPU variant
conda install -c conda-forge py-xgboost=*=cpu*
# GPU variant
conda install -c conda-forge py-xgboost=*=cuda*
```

To force the installation of the GPU variant on a machine that does not have an NVIDIA GPU, use environment variable `CONDA_OVERRIDE_CUDA`,
as described in [“Managing Virtual Packages” in the conda docs](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-virtual.html).

```bash
export CONDA_OVERRIDE_CUDA="12.8"
conda install -c conda-forge py-xgboost=*=cuda*
```

You can install Conda from the following link: [Download the conda-forge Installer](https://conda-forge.org/download/).

### R

* From R Universe

```R
install.packages('xgboost', repos = c('https://dmlc.r-universe.dev', 'https://cloud.r-project.org'))
```

#### NOTE
Using all CPU cores (threads) on Mac OSX

If you are using Mac OSX, you should first install OpenMP library (`libomp`) by running

```bash
brew install libomp
```

and then run `install.packages("xgboost")`. Without OpenMP, XGBoost will only use a
single CPU core, leading to suboptimal training speed.

* We also provide **experimental** pre-built binary with GPU support. With this binary,
  you will be able to use the GPU algorithm without building XGBoost from the source.
  Download the binary package from the Releases page. The file name will be of the form
  `xgboost_r_gpu_[os]_[version].tar.gz`, where `[os]` is either `linux` or `win64`.
  (We build the binaries for 64-bit Linux and Windows.)
  Then install XGBoost by running:
  ```bash
  # Install dependencies
  R -q -e "install.packages(c('data.table', 'jsonlite'))"
  # Install XGBoost
  R CMD INSTALL ./xgboost_r_gpu_linux.tar.gz
  ```
* From CRAN (outdated):

#### WARNING
We are working on bringing the CRAN version of XGBoost up-to-date, in the meantime,
please use packages from the R-universe.

```R
install.packages("xgboost")
```

#### NOTE
Using all CPU cores (threads) on Mac OSX

If you are using Mac OSX, you should first install OpenMP library (`libomp`) by running

```bash
brew install libomp
```

and then run `install.packages("xgboost")`. Without OpenMP, XGBoost will only use a
single CPU core, leading to suboptimal training speed.

### JVM

* XGBoost4j-Spark

```xml
<properties>
  ...
  <!-- Specify Scala version in package name -->
  <scala.binary.version>2.12</scala.binary.version>
</properties>

<dependencies>
  ...
  <dependency>
      <groupId>ml.dmlc</groupId>
      <artifactId>xgboost4j-spark_${scala.binary.version}</artifactId>
      <version>latest_version_num</version>
  </dependency>
</dependencies>
```

```scala
libraryDependencies ++= Seq(
  "ml.dmlc" %% "xgboost4j-spark" % "latest_version_num"
)
```

* XGBoost4j-Spark-GPU

```xml
<properties>
  ...
  <!-- Specify Scala version in package name -->
  <scala.binary.version>2.12</scala.binary.version>
</properties>

<dependencies>
  ...
  <dependency>
      <groupId>ml.dmlc</groupId>
      <artifactId>xgboost4j-spark-gpu_${scala.binary.version}</artifactId>
      <version>latest_version_num</version>
  </dependency>
</dependencies>
```

```scala
libraryDependencies ++= Seq(
  "ml.dmlc" %% "xgboost4j-spark-gpu" % "latest_version_num"
)
```

This will check out the latest stable version from the Maven Central.

For the latest release version number, please check [release page](https://github.com/dmlc/xgboost/releases).

To enable the GPU algorithm (`device='cuda'`), use artifacts `xgboost4j-spark-gpu_2.12` instead (note the `gpu` suffix).

#### NOTE
Windows not supported in the JVM package

Currently, XGBoost4J-Spark does not support Windows platform, as the distributed training algorithm is inoperational for Windows. Please use Linux or MacOS.

## Nightly Build

### Python

Nightly builds are available. You can go to [this page](https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds/list.html),
find the wheel with the commit ID you want and install it with pip:

```bash
pip install <url to the wheel>
```

The capability of Python pre-built wheel is the same as stable release.

### R

Other than standard CRAN installation, we also provide *experimental* pre-built binary on
with GPU support.  You can go to [this page](https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds/list.html), Find the commit
ID you want to install and then locate the file `xgboost_r_gpu_[os]_[commit].tar.gz`,
where `[os]` is either `linux` or `win64`. (We build the binaries for 64-bit Linux
and Windows.) Download it and run the following commands:

```bash
# Install dependencies
R -q -e "install.packages(c('data.table', 'jsonlite', 'remotes'))"
# Install XGBoost
R CMD INSTALL ./xgboost_r_gpu_linux.tar.gz
```

### JVM

* XGBoost4j/XGBoost4j-Spark

```xml
<repository>
  <id>XGBoost4J Snapshot Repo</id>
  <name>XGBoost4J Snapshot Repo</name>
  <url>https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/snapshot/</url>
</repository>
```

```scala
resolvers += "XGBoost4J Snapshot Repo" at "https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/snapshot/"
```

Then add XGBoost4J-Spark as a dependency:

```xml
<properties>
  ...
  <!-- Specify Scala version in package name -->
  <scala.binary.version>2.12</scala.binary.version>
</properties>

<dependencies>
  <dependency>
      <groupId>ml.dmlc</groupId>
      <artifactId>xgboost4j-spark_${scala.binary.version}</artifactId>
      <version>latest_version_num-SNAPSHOT</version>
  </dependency>
</dependencies>
```

```scala
libraryDependencies ++= Seq(
  "ml.dmlc" %% "xgboost4j-spark" % "latest_version_num-SNAPSHOT"
)
```

* XGBoost4j-Spark-GPU

```xml
<properties>
  ...
  <!-- Specify Scala version in package name -->
  <scala.binary.version>2.12</scala.binary.version>
</properties>

<dependencies>
  <dependency>
      <groupId>ml.dmlc</groupId>
      <artifactId>xgboost4j-spark-gpu_${scala.binary.version}</artifactId>
      <version>latest_version_num-SNAPSHOT</version>
  </dependency>
</dependencies>
```

```scala
libraryDependencies ++= Seq(
  "ml.dmlc" %% "xgboost4j-spark-gpu" % "latest_version_num-SNAPSHOT"
)
```

Look up the `version` field in [pom.xml](https://github.com/dmlc/xgboost/blob/master/jvm-packages/pom.xml) to get the correct version number.

The SNAPSHOT JARs are hosted by the XGBoost project. Every commit in the `master` branch will automatically trigger generation of a new SNAPSHOT JAR. You can control how often Maven should upgrade your SNAPSHOT installation by specifying `updatePolicy`. See [here](https://maven.apache.org/pom.html#Repositories) for details.

You can browse the file listing of the Maven repository at [https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/list.html](https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/list.html).

To enable the GPU algorithm (`device='cuda'`), use artifacts `xgboost4j-gpu_2.12` and `xgboost4j-spark-gpu_2.12` instead (note the `gpu` suffix).
