Tensorflow won't import in Colab - tensorflow

I'm new to ML and Colab. Trying to play around with the project at https://github.com/tkarras/progressive_growing_of_gans but having a hard time getting it running in Colab.
When I run the import_example.py script from the project, I get immediate errors relating to Tensorflow not loading. So I tried stepping back and simply doing import tensorflow as tf. When I run this, I get the below errors. I've got the runtime set to GPU. I was getting the same issue yesterday with the Colab demo GPU code, but that's working today.
Can anyone give me any pointers? It seems like basic stuff that should just work in the environment.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py in <module>()
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
/usr/lib/python3.6/imp.py in load_module(name, file, filename, details)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
/usr/lib/python3.6/imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
--> 343 return _load(spec)
344
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-8-64156d691fe5> in <module>()
----> 1 import tensorflow as tf
/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py in <module>()
22
23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
25
26 try:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 from tensorflow.python.tools import component_api_helper
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

Even I was facing the same issue. Later I realized I forgot to enable GPU in notebook settings.
I enabled it and installed TensorFlow-GPU (GPU version).
You can find notebook settings in Edit > Notebook Settings.
Here's the screenshot

Check if you have installed the version of tensorflow that you need in Colab or not?! (Maybe you have installed a different version of tensorflow-gpu and you have not installed the corresponding tensorflow version. I got the same error in this case)
!pip list
If you do not have tensorflow in the list, you should install both tensorflow and tensorflow-gpu as follow:
!pip install tensorflow=='enter version here'
!pip install tensorflow-gpu=='enter same version as the previous one here'

You just have to read the error carefully:
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
Try running:
!pip install tensorflow
inside notebook, and then rerun the cell with the import.

TensorFlow is included by default in Colab. So, I suspect you've somehow broken the existing install.
You can request a new backend by selecting the Runtime -> Reset all runtimes... menu. Then, try import tensorflow as tf again.

Related

ImportError: DLL load failed with error code 3221225501 tensorflow

I get the above mentioned error code when importing tensorflow the used version is 1.14 in a separate environment the installation is succesful, through pip install in anaconda, windows 7, installing cudam toolkit, but yet unable to import tensorflow successfully
i get this error
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
~\Anaconda3\lib\imp.py in load_module(name, file, filename, details)
241 else:
--> 242 return load_dynamic(name, filename, file)
243 elif type_ == PKG_DIRECTORY:
~\Anaconda3\lib\imp.py in load_dynamic(name, path, file)
341 name=name, loader=loader, origin=path)
--> 342 return _load(spec)
343
ImportError: DLL load failed with error code 3221225501
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-64156d691fe5> in <module>
----> 1 import tensorflow as tf
~\Anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
26
27 # pylint: disable=g-bad-import-order
---> 28 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
29 from tensorflow.python.tools import module_util as _module_util
30
~\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\Neuralserver\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Neuralserver\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Neuralserver\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\Neuralserver\Anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Neuralserver\Anaconda3\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed with error code 3221225501
Try to access after installing proper CUDA Reference 1, Reference 2
I encountered this error while installing Tensorflow 2.x in a conda environment without CUDA on windows 7.
Ultimately, I managed to install Tensorflow as part of setting up a new conda environment. This was my environment file which managed the install:
# This file defines a conda environment.
# Run as: conda env create -f dev_environment.yml
# Remove old environment using: conda env remove --name dev
name: dev
channels:
- conda-forge
dependencies:
- python=3.7
- notebook
- numpy
- pandas
- tensorflow-mkl=2.1 # <-
- tensorflow-estimator==2.1 # <- (Needed to avoid AttributeError)
I also installed the Microsoft Visual C++ Redistributable, as mentioned in the installation docs as part of my search to get things workings, but I am unsure whether this is vital or not.
Some further remarks:
At the time of writing, tensorflow 2.2 was already available on conda, but gave a AttributeError when importing
Using pip always gave the error described by OP (pip install tensorflow or pip install tensorflow-cpu). I am unsure what the difference is between the pip and conda versions.
Tensorflow hardware requirements mention TF uses AVX cpu instructions starting from version 1.6. However, I was able to install TF using the above method on a machine with an intel i9 cpu, which does not support AVX instructions.

Not able to import tensorflow_datasets module in jupyter notebook

I am trying tensorflow course from Udacity which uses google colab to write/run the code. But I want to run the code on my local machine and hence have created a new environment to run the code , but am unable to import tensorflow_dataset into the tensorflow environment .
I have tried searching for the module from the anaconda navigator to install it in tensorflow environment but anaconda navigator does not provide the tensorflow datasets module.
From cmd (command prompt) I tried to execute the below commands
1.activate tensorflow
2. pip install tensorflow_datasets
It says the module is installed but when I tried to import it from jupyter notebook I get error that there is no module with name tensorflow_datasets
1.activate tensorflow
2. pip install tensorflow_datasets
import tensorflow_datasets as tfds
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-46a8a2031c9c> in <module>()
----> 1 import tensorflow_datasets as tfds
ImportError: No module named 'tensorflow_datasets'
And if I am trying to import from tensorflow env
1.jupyter notebook
2.import tensorflow_datasets as tdfs
ImportError Traceback (most recent call last)
~\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
~\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>()
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
~\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
~\Miniconda2\envs\tensorflow\lib\imp.py in load_module(name, file, filename, details)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
~\Miniconda2\envs\tensorflow\lib\imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
--> 343 return _load(spec)
344
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-46a8a2031c9c> in <module>()
----> 1 import tensorflow_datasets as tfds
~\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow_datasets\__init__.py in <module>()
44 # needs to happen before anything else, since the imports below will try to
45 # import tensorflow, too.
---> 46 from tensorflow_datasets.core import tf_compat
47 tf_compat.ensure_tf_install()
48
~\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow_datasets\core\__init__.py in <module>()
16 """API to define datasets."""
17
---> 18 from tensorflow_datasets.core.dataset_builder import BeamBasedBuilder
19 from tensorflow_datasets.core.dataset_builder import BuilderConfig
20 from tensorflow_datasets.core.dataset_builder import DatasetBuilder
~\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow_datasets\core\dataset_builder.py in <module>()
27 from absl import logging
28 import six
---> 29 import tensorflow as tf
30
31 from tensorflow_datasets.core import api_utils
~\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow\__init__.py in <module>()
26
27 # pylint: disable=g-bad-import-order
---> 28 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
29 from tensorflow.python.tools import module_util as _module_util
30
~\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
~\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\HOME\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\HOME\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\HOME\Miniconda2\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\HOME\Miniconda2\envs\tensorflow\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\HOME\Miniconda2\envs\tensorflow\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.```
tensorflow_datasets is a separate module. You can install it using pip :
pip install tensorflow_datasets
Then you can import it as:
import tensorflow_datasets as tfds
to use tensorflow-datasets in anaconda you have to use the below command
conda install -c anaconda tensorflow-datasets
i tried using pip install and all but it was not working fine.but the above command worked like a charm.
using pip install will only install tensorflow-datasets in system python installation, which cant be used inside anaconda environment
To use tensorflow datasets, open the terminal/command prompt and enter :
pip install tensorflow_datasets
And if you are using Anaconda, you need to open up your environment and then manually import it as it doesn't gets installed.
If you are having anaconda prompt, then as the answers already suggest installing tensorflow-datasets should work without issues. You can find the related Pypi package here. This installation should work in command prompt (with pip /python installed) as well.
pip install tensorflow-datasets
If you are directly installing via conda, it is best to set up conda-forge as all the packages are shared in a single channel.Importantly the corresponding builds for AMD,Linux and MacOS are also up-to-date. For installing , here are the steps:
Making sure conda version is >=4.9:
conda --version
conda update conda
Adding conda-forge as the highest priority channel:
conda config --add channels conda-forge
Activate Strict priority (optional for Conda>=5.0):
conda config --set channel_priority strict
Install the tensorflow-datasets package from conda-forge:
conda install tensorflow-datasets==4.3.0
4.3.0 is the latest version as per Pypi.
If you are using Anaconda, go to Anaconda Navigator -> Environments -> Choose your environment. After that simply find which package would you like to install and click it. After you accept it, it uploads automatically. It is really easy. (It took half an hour to find a correct answer for me, but after finding in Anaconda it is way easier than using Terminal) Do not forget to restart Anaconda after installing new packages.

Unable to import tensorflow in jupyter notebook (Linux Mint 19)

I am a beginer in jupyter and tensorflow. I tried to install tensorflow but it doesn't work. I did try several of your advice that has been posted before but nothing seems to work.
virtualenv --version
15.1.0
python3 --version
Python 3.6.7
pip3 --version
pip 19.1.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
I tried to pip install tensorflow but it keeps giving me this error:
import tensorflow as tf
ImportError Traceback (most recent call last)
/home/tzions/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
/home/tzions/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in <module>()
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
/home/tzions/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
/usr/lib/python3.6/imp.py in load_module(name, file, filename, details)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
/usr/lib/python3.6/imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
--> 343 return _load(spec)
344
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-3-64156d691fe5> in <module>()
----> 1 import tensorflow as tf
/home/tzions/.local/lib/python3.6/site-packages/tensorflow/__init__.py in <module>()
22
23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
25 # pylint: enable=wildcard-import
26
/home/tzions/.local/lib/python3.6/site-packages/tensorflow/python/__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
/home/tzions/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "/home/tzions/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/tzions/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/tzions/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
It would be great if someone can tell me how to make it work. I have installed several other things that have been pointed out as necessary and if anything else needs to be installed please let me know.
On import, the code is looking for a libcublas.so.9.0 folder you would have if your CUDA version were 9.0, but if it is an other version, 9.1 for instance, then this folder is not found because the final number is different.
When you install tensorflow-gpu-1.5, it requires CUDA 9.0, so you can fix that installing tensorflow-gpu-1.4 if your CUDA version is 8.0, because it will be the one required, with:
pip install --upgrade tensorflow-gpu==1.4
If your CUDA version is a later one like CUDA 9.1, you can downgrade CUDA version to 9.0 if you do not need later functionalities, with:
sudo apt-get install cuda-9.0
and stay with tensorflow-gpu-1.5.

Google Colab: ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

I have been trying to run some tensorflow projects on Google Colab, but everytime I get the error below. I have checked that GPU is enabled, and I tried to use instead tensorflow-gpu 1.4.0 with similar results. Any ideas?
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py in <module>()
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
/usr/lib/python3.6/imp.py in load_module(name, file, filename, details)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
/usr/lib/python3.6/imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
--> 343 return _load(spec)
344
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-6-df440c95c76a> in <module>()
9
10 import numpy as np
---> 11 import tensorflow as tf
12
13 import tflib as lib
/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py in <module>()
22
23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
25
26 try:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 from tensorflow.python.tools import component_api_helper
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
I struggled with this issue for some hours, here is what works for me.
As #Bob Smith mentioned the issue if with the version of CUDA on colab, you can check it using this command :
cat /usr/local/cuda/version.txt
Then you run the following command line by line to install a lower version of CUDA
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
apt-get update
apt-get install cuda=9.0.176-1
And yupi everything works now, at least at my side :)

Installing Tensorflow for Python 3.6.0

can somebody explain to me what to do step by step for installation of Tensorflow for Python 3.7.0! (I'm using ipython)!
My system is windows 10 64 bit system.
I do not understand what to do even with all the explanation I find so far.
So can somebody pointed me to the exact link I have to click on to install tensor flow? Tnx
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>()
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
~\Anaconda3\lib\imp.py in load_module(name, file, filename, details)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
~\Anaconda3\lib\imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
--> 343 return _load(spec)
344
ImportError: DLL load failed: Een initialisatieroutine van de dynamic link library (DLL-bestand) is mislukt.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-2-fae406f752e9> in <module>()
6 from PIL import Image
7 from scipy import ndimage
----> 8 import tensorflow as tf
9 from tensorflow.python.framework import ops
10 from cnn_utils import *
~\Anaconda3\lib\site-packages\tensorflow\__init__.py in <module>()
20
21 # pylint: disable=g-bad-import-order
---> 22 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
23
24 try:
~\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\gstevens\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\gstevens\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\gstevens\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\gstevens\Anaconda3\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\gstevens\Anaconda3\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Een initialisatieroutine van de dynamic link library (DLL-bestand) is mislukt.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Summarizing installation steps from the official tensorflow installation guide specifically for your case.
Since you already have Python 3.6 and Conda installed on your machine (which is good!) we can move on to confirming the other stuffs.
1. Microsoft Visual C++ 2015 Redistributable Update 3
Install the Microsoft Visual C++ 2015 Redistributable Update 3. This comes with Visual Studio 2015 but can be installed separately:
Go to the Visual Studio downloads,
Select Redistributables and Build Tools, (it is well hidden, use search to look for it)
Download and install the Microsoft Visual C++ 2015 Redistributable Update 3.
2. Install Tensorflow in your Conda virtual environment
Open your Command Prompt. Since you already have the environment created with the name tensorflow you just need to:
In case you wish to create a new environment, run conda create -n venv pip python=3.6. Replace venv with a name of your choice for the environment.
source activate tensorflow. tensorflow in this line is the name of the Conda environment you named when you ran conda create -n tensorflow python=3.6. Unless you've followed step 1 and made a new environment, replace tensorflow with the name you used in step 1.
Now you have activated your virtual environment. Within the virtual environment, install the Tensorflow pip package using its complete URL, so for your case, just run:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.11.0-cp36-cp36m-win_amd64.whl
Please update the URL in the command above according to the URL list if you're installing this again in the future. The command above will become outdated eventually.
3. Verifying the install
Restart your Command Prompt, and again activate your conda environment, then run python -c "import tensorflow as tf; print(tf.__version__)", and it should print the version of Tensorflow you have installed, in this case 1.11.0. If it does, then you have successfully installed Tensorflow in your Conda virtual environment. Congratulations!
If it doesn't work, comment here so I can modify my answer to further assist you.
Tensorflow does not support Python 3.7 yet (https://github.com/tensorflow/tensorflow/issues/17022).
Use Python 3.6.