Sagemaker Studio notebook - no module named 'tensorflow' when chosen image type "Tensorflow 2.6 Python 3.8 GPU optimized"

Viewed 517

I have created a simple notebook on SageMaker Studio using the Image "Tensorflow 2.6 Python 3.8 GPU optimized". But when I try to run simple statement viz. "import tensorflow", I am getting the error "no module named 'tensorflow'".

I tried to install 'tensorflow' package using pip from the terminal attached to the image. But it shows the message "requirement already satisfied".

Am I missing anything here? Please help.

Thanks in advance, Surya Praveen

1 Answers

I posted the same question in AWS forum "re:Post" and I got following answer.

The service team are aware of this issue and are actively working on a fix. Meanwhile, you can try the following as workaround

  1. Open a notebook using a Tensorflow 2.6 Python 3.8 kernel

  2. Execute the following line in a notebook cell:

    !sed -i 's|^ *"python",| "/usr/local/bin/python",|g' /usr/local/share/jupyter/kernels/python3/kernel.json

  3. Stop the kernel

  4. Re-attach the kernel to your notebook.

This actually worked for me.

Related