on restarting the instance in sagemaker and selecting kernel, not able to import modules

0

Hello I created, activated, installed modules and saved a new environment as a kernel in sagemaker studio using below commands, !conda create -n myenv -y !source activate myenv !pip install kxyz !python -m ipykernel install --user --name myenv --display-name "Neyd"

then closed the instance and then restarted the instance and selected the Neyd kernel. But, then import kxyz shows no module found. pip list also doesnt show this module, !conda env list also doesnt show myenv .

can someone help. i dont want to install all packages everytime I start the instance.

Rajat
asked 9 months ago428 views
2 Answers
1

if you stop a notebook instance, you will lose any changes you made to the Conda environment or installed packages in that session. If you want to keep your changes, you can either create a persistent Conda environment or save your work to a persistent storage location.

Here are some additional details about the implications of stopping a notebook instance:

  • Any data that is stored in the notebook's ephemeral storage (such as the /tmp directory) will be lost.
  • Any running processes will be terminated.
  • Any changes you made to the notebook's configuration will be lost.

Solution:

AWS
Zmnako
answered 9 months ago
-1

When you stop a notebook, SageMaker terminates the notebook's Amazon Elastic Compute Cloud (Amazon EC2) instance. Non-persistent Conda environments and the packages installed don't persist between sessions. SageMaker domains and Studio use an EFS volume as a persistent storage layer. You can save your Conda environments on this EFS volume. These environments are persistent between kernel, app, or Studio restart. Studio automatically picks up all environments as KernelGateway kernels.

To Create persistent Conda environments on a Studio EFS volume, please refer the AWS article [1] and GitHub [2] which guides you through step-by-step process along with detailed instructions.

References :
[1] https://aws.amazon.com/blogs/machine-learning/four-approaches-to-manage-python-packages-in-amazon-sagemaker-studio-notebooks/#:~:text=Persist%20Conda%20environments%20to%20the%20Studio%20EFS%20volume
[2] https://github.com/durgasury/efs_backed_conda

AWS
SUPPORT ENGINEER
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions