Skip to content

Commit 0cd83dd

Browse files
committed
Describe user managed dependencies
1 parent 51bec91 commit 0cd83dd

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

articles/machine-learning/how-to-use-environments.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,29 @@ myenv.docker.base_image = None
260260
myenv.docker.base_dockerfile = dockerfile
261261
```
262262

263-
> [!NOTE]
264-
> If you specify `environment.python.user_managed_dependencies=False` while you're using a custom Docker image, then the service will build a Conda environment within the image. It will execute the run in that environment instead of using any Python libraries that you installed on the base image. Set the parameter to `True` to use your own installed packages.
263+
### Use user-managed dependencies
264+
265+
In some situations, your custom base image may already contain an Python environment with packages that you want to use.
266+
267+
By default, Azure Machine Learning service will build a Conda environment with the dependecies you specified, and will execute the run in that environment instead of using any Python libraries that you installed on the base image.
268+
269+
To use your own installed packages, set the parameter `Environment.python.user_managed_dependencies = True`. You must ensure that the base image contains a Python interpreter, and has the packages your training script needs.
270+
271+
For example, to run in a base Miniconda environment that has NumPy package installed, first specify a Dockerfile with a step to install the package. Then set the user-managed dependencies to `True`.
272+
273+
You can also specify a path to a specific Python interpreter within the image, by setting the `Environment.python.interpreter_path` variable.
274+
275+
```python
276+
dockerfile = """
277+
FROM mcr.microsoft.com/azureml/base:intelmpi2018.3-ubuntu16.04
278+
RUN conda install numpy
279+
"""
280+
281+
myenv.docker.base_image = None
282+
myenv.docker.base_dockerfile = dockerfile
283+
myenv.python.user_managed_dependencies=True
284+
myenv.python.interpreter_path = "/opt/miniconda/bin/python"
285+
```
265286

266287
## Use environments for training
267288

0 commit comments

Comments
 (0)