Creating and using a custom Anaconda environment on Azure DSVM

1.4k Views Asked by At

I want to use a specific Python environment with specific libraries (Keras, TensorFlow) on an Azure Linux data science virtual machine (DSVM) to move some of my local work to the cloud.

I created the environment in the terminal using Keras v2.1.6. Also, I can see the environment in the Jupyter environment. However, when I switch my kernel to my new environment and run:

import keras
keras.__version__
# output: 2.1.2.

This should be 2.1.6.

Any help would be appreciated!

1

There are 1 best solutions below

0
On

I resolved this issue. Here are the proper steps to use a custom environment or use a specific version of a library in a DSVM:

1. Create a new environment

From the DSVM, click 'New->Terminal'. Run the following command:

conda create -n myenv python=3.5 keras=2.1.6 

Note: You can substitute any languages or add other libraries. Instructions are in the Anaconda docs - Creating Environments.

2. Activate Env, install necessary library.

From the terminal:

source activate myenv
pip install ipykernel

The IPython Kernel is necessary to allow Jupyter to execute code in your new environment. Without this step, you will see your environment listed in the Jupyter UI but it won't connect and use your environment.

Expose the env to Jupyter

Run the following command to expose your new environment (myenv) to Jupyter and use the display name, Python (myenv):

python -m ipykernel install --user --name=myenv --display-name "Python (myenv)"

That's it!

Verifying your environment

In Jupyter refresh your browser, click 'New -> Python (myenv)'. You can verify that you're using the correct version of your libraries by simply:

import keras
keras.__version__