error message of No module named 'tensorflow' in GCP AI Platform Notebook - tensorflow

I launched a notebook with GCP AI Platform. Then, I tried to install tensorflow by:
import tensorflow as tf
There is an error message of
No module named 'tensorflow'
I tried to install it by:
!pip install -U --user tensorflow==1.14.0
But the same error message appeared. As it is a GCP platform, I wonder why I need to install tensorflow. During Coursera training, I can import tensorflow directly without installation. I wonder if I missed anything.
Grateful if you can help.
Thank you

You have probably selected an instance type that doesn't have tensorflow pre-installed.
After you install a Python dependency you will have to restart the Python Kernel for updates to take effect by clicking on Kernel->Restart Kernel....

Related

Running Train a GPT-2 (or GPT Neo) Text-Generating Model w/ GPU on Colab

When I start "Running Train a GPT-2 (or GPT Neo) Text-Generating Model w/ GPU on Colab" in my Colab, following error comes up:
ERROR: tensorflow 2.5.0 has requirement tensorboard~=2.5, but you'll
have tensorboard 2.4.1 which is incompatible. ERROR: pytorch-lightning
1.3.8 has requirement PyYAML<=5.4.1,>=5.1, but you'll have pyyaml 3.13 which is incompatible.
What to do? Is it because of my Mac, or do I need to upgrade my Colab account would that help?
The problem comes from the default packages installed in the Colab environment. I does not depend on the platform you are using to access Colab or on the type of your subscription.
You have to upgrade the Python packages using pip.
In general you can run shell commands like pip in Colab prepending a ! character,
so in your case the following lines should be sufficient to fix the problem
!pip install tensorboard==2.5
!pip install pyyaml==5.4.1
If you need to run more shell commands, you can use more user-friedly methods (see the answers to this question).

AttributeError: module 'tensorflow._api.v2.config.experimental' has no attribute 'set_lms_enabled'

I wanted to use LMS for my deep learning project, and I used the code for this:
import tensorflow as tf
tf.config.experimental.set_lms_enabled(True)
from this IBM GitHub link. But I get the mentioned error.
AttributeError: module 'tensorflow._api.v2.config.experimental' has no attribute 'set_lms_enabled'
I tried it in colab notebook, which uses tensorflow 2.2. Should I downgrade it? How else do I solve this issue?
according to TensorFlow Large Model Support github page:
TFLMS is built into the tensorflow-gpu conda package so it is installed by default when you install the GPU enabled TensorFlow from WML CE.
so you need to install anaconda and install TensorFlow from WML CE by conda package manager.
to install anaconda follow anaconda official document page by this link:
https://docs.anaconda.com/anaconda/install/

Jupyter Notebook kernel dies when importing tensorflow 1.5.0

Jupyter Notebook kernel dies when importing tensorflow 1.5.0
I have read a lot of posts relating to this but they have all had higher version numbers of tensorflow and have solved it by downgrading to 1.5.0. I also had higher version number and followed the advice to downgrade but I still have the problem.
Does anyone know what to try next?
pip install h5py==2.8.0
worked for me
When trying using the command prompt I got an error message not related to the tensorflow issue (I think);
"Warning! HDF5 library version mismatched error"
The key information from that message body was "Headers are 1.10.1, library is 1.10.2" so I downgraded hdf5 library by "conda install -c anaconda hdf5=1.10.1" and now the error message is gone and the kernel does not die when importing tensorflow.
I got similar problems, any tensorflow or tensorflow related packages (e.g. keras) made my kernel to die when loading, from any interface (jupyter, spyder, console....)
For those having this kind of problems, try running python from the console with verbose mode (python -v) then import tensorflow and look for errors.
I spot errors related to h5py, similar to the reply of #DBSE. I just upgraded the h5py package then everything was solved !
If you are using a conda environment, then the easiest method for fixing this issue is to just create a new environment and install tensorflow with just a single command. I had the same issue, I have tried a lot on most of the version of python and tensorflow. But at the last I have successfully configured it with just a single steps.
Run this command for installing GPU version
conda create --name tf_gpu tensorflow-gpu
The above line of code will automatically install that version of python and tf which is comaptible with your GPU or CPU.
For CPU, Run this command
conda create --name tf_env tensorflow
Both of these command work 100 % with my system for GPU and CPU access and will download the latest version which are compatible with system. It will resolved/fixed "Illegal Instruction (code dumps)" error.
pip install h5py==3.1.0
This is the most updated version which worked for me.
Try using import numpy before Keras and Tensorflow.

problems when importing tensorflow in Jupiter Notebook

I am using Jupiter Notebook installed with Anaconda distribution and I want to install Tensorflow.
I wrote
!pip install tensorflow
it installed it, but now when I want to import tensorflow, when I type
import tensorflow as tf
it gives me an error:
ImportError: DLL load failed with error code -1073741795
I searched for answers and questions related to this issue but nothing helped me. The most weird is that I managed to install and import tensorflow on another computer like this. I can`t find out what I am missing.

Tensorflow installation issue on Win 10

I am new to tensorflow and tried to install into Anaconda. I followed the instruction to the dot from tensorflow.org. I encountered no problem encountered but in python shell when i perform import tensorflow as tf, I got this error message, "ModuleNotFoundError: No module named 'tensorflow'".
Please advise what to do to install tensorflow.
I already followed the previous post on conda create -n tensorflow python=3.6 but to no avail.