Hello @Mauro Andretta
Thanks for reaching out to us, it will be good to share the book you are referring to so that we can know the whole story.
Personally, I prefer to create a conda env all the time so that I can have the right dependencies and packages.
To answer your question generally, when you use a compute instance, you can create and activate a conda environment directly in the Jupyter notebook. However, when you use a compute cluster, you need to create and activate a conda environment before submitting your job to the cluster. This is because the job will be executed on a remote compute target, and the environment needs to be set up on that target before the job can run.
To activate an AML environment, you need to first create the environment using a conda specification file or a Dockerfile. Once the environment is created, you can activate it using the following command -
conda activate <environment_name>
This command activates the specified environment, allowing you to use the packages and dependencies installed in that environment. You can then run your code or submit your job to the compute cluster using the activated environment.
It's important to activate the correct environment before running your code or submitting your job, as different environments may have different package versions or dependencies that could affect the behavior of your code.
The reason why the book defines a conda environment for the example using a compute cluster is because the job will be executed on a remote compute target, and the environment needs to be set up on that target before the job can run.
When you use a compute instance, you can create and activate a conda environment directly in the Jupyter notebook, because the notebook is running on the compute instance itself. However, when you use a compute cluster, the job will be executed on a remote compute target, and the environment needs to be set up on that target before the job can run.
Defining a conda environment for the compute cluster example ensures that the necessary packages and dependencies are installed on the remote compute target before the job is executed, and that the job runs consistently and reproducibly across different machines and environments.
I hope this helps.
Regards,
Yutong