Skip to content

Jupyter notebook kernel dies during execution and ModuleNotFound errors

0

I have been working on building a QML model for the classification of an image dataset, which is approximately 194 MB in size. While executing the code on the AWS Braket Jupyter instance, I encountered an issue where a pop-up appears stating, "The kernel died.". Also I've been facing issues in installation and importing of packages like scikit-learn , tensorflow etc, I tried creating a new environment for the same but still ModuleNotFound error persists.

Since this is my first time using this platform, I am unsure how to resolve these problems and proceed further.

3 Answers
1

For the 1st question on the kernel, it is possible that you run out of memory of the instance of the notebook instance, which is default to be 4G (although it is larger than 194MB, other preinstalled materials may have also occupied some space). One possible solution is to launch a notebook with larger memory, but please be aware of the higher cost of that. For more information on pricing of notebooks, please refer to this page https://aws.amazon.com/sagemaker/pricing/, See the Section "On-Demand Pricing", and select the Tab "Notebook Instances", and select the region you used.

For the 2nd question on ModuleNotFound Errors, suppose you used "pip install <package_name>" in the terminal, the package won't be installed in the default kernel "conda_braket" used for the notebooks. There are two possible solutions

2.1. You could install the package in the notebook as "%pip install <package_name>" (note the % symbol). 2.2. You could run

python3 -m pip install ipykernel
python3 -m ipykernel install --user

in the terminal, then you could use "python3" as the kernel for the notebook, which then allows you "pip install <package_name>" in the terminal and use the package in the notebook.

AWS
answered 2 years ago
0

There are a few potential reasons for the issues you're experiencing with your Jupyter notebook on AWS Braket. Let's address them one by one:

  1. Kernel dying: This is likely due to memory constraints. When working with large datasets or complex models, it's common to run out of memory, causing the kernel to crash. To resolve this:
  • Restart the kernel: Navigate to the "Kernel" menu in your Jupyter Notebook and select "Restart Kernel".
  • Check resource utilization: Monitor your instance's memory usage using system commands or CloudWatch metrics.
  • Increase instance size: If you're consistently running out of memory, consider using a larger instance type with more RAM.
  1. ModuleNotFound errors: These errors occur when Python can't find the required packages. To address this:
  • Ensure proper installation: Make sure you've correctly installed the required packages (scikit-learn, tensorflow, etc.) in your environment.
  • Verify environment activation: Double-check that you're using the correct environment where these packages are installed.
  • Install missing packages: If packages are missing, install them using pip or conda within your Jupyter notebook or terminal.
  1. Environment issues: Creating a new environment is a good approach, but ensure you're activating it correctly:
  • Create a new conda environment with necessary packages.
  • Register this environment with Jupyter:
    python -m ipykernel install --user --name=my_notebook_env
    
  • Select the new kernel in Jupyter: Click "Kernel" > "Change kernel" and choose your new environment.
  1. AWS Braket specific considerations:
  • Check AWS Braket documentation for any specific package versions or compatibility issues.
  • Ensure you have the necessary permissions to install packages and modify environments on your instance.

If problems persist after trying these solutions, consider reaching out to AWS support for platform-specific troubleshooting. Remember to save your work frequently and consider using smaller subsets of your data for initial development to avoid memory issues.

Sources
Running Jupyter Notebook Tutorials - AWS Deep Learning AMIs
Jupyter Notebook QuickStart — AWS Neuron Documentation
Building multi-tenant JupyterHub Platforms on Amazon EKS | Containers

answered 2 years ago
  • already tried all the suggestions, didn't work. Modules specifically tensorflow ad scikit-learn are not getting imported.

0

I think if all things are the same to just upgrade the notebook to a higher tier unless your constrained on the ability to relinquish funds for such a thing then I would say you may need to rethink your project and what all you must have and what you can get rid of.

answered 8 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.