This section covers how to setup modeltime.gluonts
to
use GPUs.
GPU Requirements
You must have:
- One or more Nvidia GPUs
- CUDA software properly installed
Refer to MXNet’s Official GPU Documentation on using GPUs.
Step 1: Create a Custom GluonTS Python Environment
Create a Custom GluonTS Python Environment. You will need to install
a version of mxnet
that is compatible with your CUDA
software.
reticulate::py_install(
envname = "my_gluonts_env",
python_version = "3.7.1",
packages = c(
# IMPORTANT
"mxnet-cu92", # replace `cu92` according to your CUDA version.
"gluonts==0.8.0",
"pandas",
"numpy",
"pathlib"
),
method = "conda",
pip = TRUE
)
Step 2: Connect to the GluonTS GPU Environment
Follow instructions to set the path and check your custom gluonts environment. You will need to:
- Locate the Python Path to your new Custom GPU-enabled Python Environment
- Set the System Environment Variable
- Load Modeltime GluonTS
- Check Your Environment to make sure
modeltime.gluonts
is connecting to your GPU-enabled GluonTS Python Environment
Step 4 (Optional): Configure your GPUs using the MXNet Context (CTX)
One final point is that if you have multiple GPUs, you can configure
how to distribute the work using the MXNet Context (ctx
).
For example, if you have two GPUs, you can specify to use both of them
by adding to the set_engine()
.
mxnet <- reticulate::import("mxnet")
# Modify your set_engine()
... %>%
set_engine("gluonts_deepar", ctx = list(mxnet$gpu(0), mxnet$gpu(1)))