Configure the R environment to be used for training or web service deployments. When you submit a run or deploy a model, Azure ML builds a Docker image and creates a conda environment with your specifications from your Environment object within that Docker container.

If the custom_docker_image parameter is not set, Azure ML will build a predefined base image (CPU or GPU depending on the use_gpu flag) and install any R packages specified in the cran_packages, github_packages, or custom_url_packages parameters.

r_environment(name, version = NULL, environment_variables = NULL,
  r_version = NULL, rscript_path = NULL, snapshot_date = NULL,
  cran_packages = NULL, github_packages = NULL,
  custom_url_packages = NULL, bioconductor_packages = NULL,
  custom_docker_image = NULL, image_registry_details = NULL,
  use_gpu = FALSE, shm_size = NULL)



A string of the name of the environment.


A string of the version of the environment.


A named list of environment variables names and values. These environment variables are set on the process where the user script is being executed.


The version of R to be installed.


The Rscript path to use if an environment build is not required. The path specified gets used to call the user script.


Date of MRAN snapshot to use.


A list of cran_package objects to be installed.


A list of github_package objects to be installed.


A character vector of packages to be installed from local directory or custom URL.


A character vector of packages to be installed from Bioconductor.


A string of the name of the Docker image from which the image to use for training or deployment will be built. If not set, a predefined Docker image will be used. To use an image from a private Docker repository, you will also have to specify the image_registry_details parameter.


A ContainerRegistry object of the details of the Docker image registry for the custom Docker image.


Indicates whether the environment should support GPUs. If TRUE, a predefined GPU-based Docker image will be used in the environment. If FALSE, a predefined CPU-based image will be used. Predefined Docker images (CPU or GPU) will only be used if the custom_docker_image parameter is not set.


A string for the size of the Docker container's shared memory block. For more information, see Docker run reference If not set, a default value of '2g' is used.


The Environment object.


Once built, the Docker image appears in the Azure Container Registry associated with your workspace, by default. The repository name has the form azureml/azureml_<uuid>. The unique identifier (uuid) part corresponds to a hash computed from the environment configuration. This allows the service to determine whether an image corresponding to the given environment already exists for reuse.

If you make changes to an existing environment, such as adding an R package, a new version of the environment is created when you either submit a run, deploy a model, or manually register the environment. The versioning allows you to view changes to the environment over time.

Predefined Docker images

When submitting a training job or deploying a model, Azure ML runs your training script or scoring script within a Docker container. If no custom Docker image is specified with the custom_docker_image parameter, Azure ML will build a predefined CPU or GPU Docker image. The predefine images extend the Ubuntu 16.04 Azure ML base images and include the following dependencies:

azuremlsdklatest(from GitHub)
Commonly used R packages-80+ of the most popular R packages for data science, including the IRKernel, dplyr, shiny, ggplot2, tidyr, caret, and nnet. For the full list of packages included, see here.
azureml-defaultslatestazureml-defaults contains the azureml-core and applicationinsights packages of the Python SDK that are required for tasks such as logging metrics, uploading artifacts, and deploying models. (from pip)
rpy2latest(from conda)
CUDA (GPU image only)10.0CuDNN (version 7) is also included

See also

estimator(), inference_config()


# The following example defines an environment that will build the default # base CPU image. if (FALSE) { r_env <- r_environment(name = 'myr_env', version = '1') }