---
title: "Known issues and troubleshooting"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Known issues and troubleshooting}
  %\VignetteEngine{knitr::rmarkdown}
  \use_package{UTF-8}
---

This guide covers known issues and troubleshooting for using R in Azure Machine Learning.

The list will continue to evolve as new issues are discovered and old ones are resolved.

## Installation
For issues with installing the **azuremlsdk** package, please refer to the [troubleshooting](https://azure.github.io/azureml-sdk-for-r/articles/installation.html#troubleshooting) section of the installation guide.

## Compute instance
The following address issues when developing in R on a [Compute instance](https://docs.microsoft.com/azure/machine-learning/concept-compute-instance) using RStudio or Jupyter.

### Older version of azuremlsdk
There will sometimes be a lag in between the latest release of the **azuremlsdk** package to CRAN and when the package version is updated on the compute instance. You can determine what version of the SDK you have by running `packageVersion("azuremlsdk")`.

To update to the latest version on CRAN:
``` {r eval=FALSE}
install.packages("azuremlsdk")
azuremlsdk::install_azureml()
```

To install the latest development version from GitHub:
``` {r eval=FALSE}
remotes::install_github('https://github.com/Azure/azureml-sdk-for-r')
azuremlsdk::install_azureml()
```

### Error: "Unable to install packages"
You may run into an error installing R packages from Jupyter using the R kernel, even though the same installation works from RStudio. The error will look as follows: 
```
Installing package into '/usr/local/lib/R/site-library' (as 'lib' is unspecified)

Warning message in install.packages(<package name>):
"'lib = "/usr/local/lib/R/site-library"' is not writable"
```

The discrepancy is due to RStudio assuming a different default library location than the R kernel in Jupyter. 

You can work around this by specifying a library location you have permission to such as the home directory "/home/azureuser/R". 

1. From your Jupyter notebook run:  
`install.packages("<package name>", lib="/home/azureuser")`
2. Then add a call to `.libPaths()` at the beginning of your notebook to tell Jupyter where your packages are:  
`.libPaths("/home/azureuser/R")`

An alternative is to give yourself access to the default folder by running a `chmod` or `chown` command from the terminal.

## Training

### "ModuleNotFoundError": "No module named 'ruamel'"
If the following error occurs for your training run (or deployment):
```
"ModuleNotFoundError": "No module named 'ruamel'"
```
This is due to an issue with the installation `ruamel.yaml` package required by `azureml-defaults` that happens with `pip > 20.1.1`.

To work around this issue, you can pin `pip` to version 20.1.1. Two options for doing so:

1. If you are using the default environment, you can modify your environment as follows:
```{r eval=FALSE}
nv <- r_environment(name = "my-env")
env$python$conda_dependencies$add_conda_package('pip==20.1.1')
```
2. If you are using a custom Docker image, pin `pip=20.1.1`. You can refer to the ["Building custom Docker images](https://azure.github.io/azureml-sdk-for-r/articles/building-custom-docker-images.html) vignette for an example and more information.

### "PermissionError" when submitting an experiment in RStudio
If the following error occurs when submitting an experiment using RStudio: 
```
Error in py_call_impl(callable, dots$args, dots$keywords) : 
 PermissionError: [Errno 13] Permission denied
```
Move the files for your project into a subdirectory and reset the working directory to that directory before re-submitting.
  
In order to submit an experiment, the Azure ML SDK must create a .zip file of the project directory to send to the service. However, the SDK does not have permission to write into the .Rproj.user subdirectory that is automatically created during an RStudio session. For this reason, the recommended best practice is to isolate project files into their own directory.

### "Error": "C stack usage ______________ is too close to the limit"
This is due to an unchecked recursion loop in interacting with reticulate.

Update to the latest `reticulate` version from GitHub to resolve it.
```r
remotes::install_github('https://github.com/rstudio/reticulate')
```

## Deployment
For information on troubleshooting web service deployment issues, see the "Troubleshooting section" of the [Deploying models](https://azure.github.io/azureml-sdk-for-r/articles/deploying-models.html#troubleshooting-deployment) guide.

## Resource quotas
You may hit resource quota issues, such as the error below:
```
Operation could not be completed as it results in exceeding approved Total Regional Cores quota.
```

For information on quotas, see [Manage and request quotas for Azure resources](https://docs.microsoft.com/azure/machine-learning/how-to-manage-quotas).
