After building TensorFlow from source, seeing libcudart.so and libcudnn errors - tensorflow

I'm building TensorFlow from source code. The build appears to succeed; however, when my TensorFlow program invokes import tensorflow, one or both of the following errors appear:
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
ImportError: libcudnn.5: cannot open shared object file: No such file or directory

First, for the following error:
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
make sure your LD_LIBRARY_PATH includes your lib64 directory in whichever path you installed your cuda package in. You can do this by adding an export line in your .bashrc. For Omar, it looked like the following:
I fixed this just adding the cuda path to my .bashrc
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/
For me, I had to do Omar's line and also:
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64/
because I have two directories involving cuda (probably not the best).
Second, are you sure you installed cuDNN? Note that this is different from the regular cuda package. You will need to register, then download and install the package from the following page:
https://developer.nvidia.com/cudnn
Third, I had this same problem:
ImportError: libcudnn.5: cannot open shared object file: No such file or directory
It turns out there is no libcudnn.5 in my /usr/local/cuda/lib64 or /usr/local/cuda-8.0/lib64 directories. However, I do have a libcudnn.so.6.* file. To solve the problem, I created a soft link:
ln -s libcudnn.so.6.* libcudnn.so.5
in my /usr/local/cuda/lib64 directory. Now everything works for me. Your directory might be different if you already had cuDNN, and your libcudnn.so.6.* might be a different version, so check that.

I came across the same issue
In [1]: import tensorflow
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/usr/local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
40 sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 41 from tensorflow.python.pywrap_tensorflow_internal import *
42 from tensorflow.python.pywrap_tensorflow_internal import __version__
/usr/local/lib/python3.5/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
/usr/local/lib/python3.5/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/local/lib/python3.5/imp.py in load_module(name, file, filename, details)
241 else:
--> 242 return load_dynamic(name, filename, file)
243 elif type_ == PKG_DIRECTORY:
/usr/local/lib/python3.5/imp.py in load_dynamic(name, path, file)
341 name=name, loader=loader, origin=path)
--> 342 return _load(spec)
343
ImportError: libcudnn.so.5: 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-1-a649b509054f> in <module>()
----> 1 import tensorflow
/usr/local/lib/python3.5/site-packages/tensorflow/__init__.py in <module>()
22
23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
25 # pylint: enable=wildcard-import
26
/usr/local/lib/python3.5/site-packages/tensorflow/python/__init__.py in <module>()
49 import numpy as np
50
---> 51 from tensorflow.python import pywrap_tensorflow
52
53 # Protocol buffers
/usr/local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
50 for some common reasons and solutions. Include the entire stack trace
51 above this error message when asking for help.""" % traceback.format_exc()
---> 52 raise ImportError(msg)
53
54 # 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.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/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/local/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/local/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcudnn.so.5: 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.
I have installed cudnn 6.0 while it needs libcudnn.so.5, apparently it couldn't find libcudnn.so.5. It seems that your tensorflow needs cudnn 5.x, so install cudnn 5.x
Make sure you have already installed cuda 8.0 and exported the PATH and LD_LIBRARY_PATH
To install cudnn 5.x, try the following commands
Extract tgz files
$ tar -zxvf cudnn-8.0-linux-x64-v5.1.tgz
Check the files
$ cd cuda/lib64/
$ ls -l
total 150908
lrwxrwxrwx 1 doom doom 13 Nov 7 2016 libcudnn.so -> libcudnn.so.5
lrwxrwxrwx 1 doom doom 18 Nov 7 2016 libcudnn.so.5 -> libcudnn.so.5.1.10
-rwxr-xr-x 1 doom doom 84163560 Nov 7 2016 libcudnn.so.5.1.10
-rw-r--r-- 1 doom doom 70364814 Nov 7 2016 libcudnn_static.a
Here you will see 2 symbolic link files, and just copy libcudnn.so.5.1.10 and libcudnn_static.a to /usr/local/cuda/lib64
Make symbolic link files
$ cd /usr/local/cuda/lib64/
$ sudo ln -s libcudnn.so.5.1.10 libcudnn.so.5
$ sudo ln -s libcudnn.so.5 libcudnn.so
$ ls -l libcudnn*
lrwxrwxrwx 1 root root 13 May 24 09:24 libcudnn.so -> libcudnn.so.5
lrwxrwxrwx 1 root root 18 May 24 09:24 libcudnn.so.5 -> libcudnn.so.5.1.10
-rwxr-xr-x 1 root root 84163560 May 24 09:23 libcudnn.so.5.1.10
-rw-r--r-- 1 root root 70364814 May 24 09:23 libcudnn_static.a
Copy cudnn.h in include directory to /usr/local/cuda/include
$ sudo cp cudnn.h /usr/local/cuda/include/
Hope it will help you!

I fixed this just adding the cuda path to my .bashrc
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/
Just have in mind that first you need to go to nvidia Deep Learning page, register and download cuDNN, extract and copy the files from include and lib64 folders into your cuda installation.

I have seen a similar error (bottom of this post), but complaining about libcudnn.so.6 instead of libcudart.so.8.0 (see a note below).
Solution:
Download 'cuDNN v6.0 Library for Linux':
Go to https://developer.nvidia.com/rdp/cudnn-download
Click on 'Download cuDNN v6.0 (April 27, 2017), for CUDA 8.0'
Then click on 'cuDNN v6.0 Library for Linux'. A file (named 'cudnn-8.0-linux-x64-v6.0.tgz') will be downloaded.
Follow the instructions of Alexander Yau above to install the cuDNN v6.0 library.
Note:
the Tensorflow installation instructions (as of 20/Aug/2017) require installing cuDNN v5.1, but my Tensorflow installation (following the instructions for installing in a virtualenv) required cuDNN v6.x (as indicated by the error). I don't know if it is a mistake on my side or a Tensorflow documentation one. Nevertheless, above solution worked for me.
Encountered error:
In [1]: import tensorflow as tf
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-41389fad42b5> in <module>()
----> 1 import tensorflow as tf
/home/haseeb/.virtualenvs/attention_transformer/local/lib/python2.7/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/haseeb/.virtualenvs/attention_transformer/local/lib/python2.7/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/haseeb/.virtualenvs/attention_transformer/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
50 for some common reasons and solutions. Include the entire stack trace
51 above this error message when asking for help.""" % traceback.format_exc()
---> 52 raise ImportError(msg)
53
54 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "/home/haseeb/.virtualenvs/attention_transformer/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/haseeb/.virtualenvs/attention_transformer/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/haseeb/.virtualenvs/attention_transformer/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcudnn.so.6: 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.

As of now tensor-flow supports cuda-9.0
Do following things. Hope it helps :
$ sudo apt-get install cuda-9.0
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64
Download cuDNN for 9.0 (You need to register before downloading)
https://developer.nvidia.com/rdp/form/cudnn-download-survey
$ sudo dpkg -i libcudnn7_7.1.2.21-1+cuda9.0_amd64.deb
Close all terminal and open new
$ source activate tensorflow
$ python
>> import tensorflow as tf
You should not get any error after this.

Mysteriously, my libcudnn.so.5 was installed at ~/cuda/lib64. For people like me, you need to change
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:~/cuda/lib64"
to
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/yourusername/cuda/lib64"

The preceding errors are typically caused by not specifying a version number for the Cuda SDK or cuDNN when you run the configure script. In other words, when running the configure script, always specify a version number in response to the following two questions:
Please specify the Cuda SDK version you want to use, e.g. 7.0.
Please specify the cuDNN version you want to use.
Don't accept the system defaults.

On MacOS, this issue is often caused by bazel running in a sandbox environment, thus not respecting the LD_LIBRARY_PATH set in your local shell. I wouldn't bother going into the merit of deep integration of sandboxing in a build tool.
The simple workaround is to symlink the libraries into /usr/local/lib.
cd /usr/local/lib && ln -s ../cuda/lib/libcudart.8.0.dylib

First, Install CUDA library (version 7.5) from here
Installation Instructions:
1- sudo dpkg -i cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb
2- sudo apt-get update
3- sudo apt-get install cuda
Second, install the cuDNN from here
Third, export cuDNN path:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/
In case you have an error like "The package libcudnnX needs to be reinstalled", follow those steps here

Check the NVIDIA requirements to run TensorFlow with GPU support (link):
CUDA® Toolkit 8.0
The NVIDIA drivers associated with CUDA Toolkit 8.0
cuDNN v6.0
GPU card with CUDA Compute Capability 3.0 or higher
The libcupti-dev library, which is the NVIDIA CUDA Profile Tools Interface
I installed the cuda v5.1 and the message below still remains:
ImportError: libcudart.so.8.0: cannot open shared object file:
No such file or directory
I so I got pissed off because everything looks fine, so I decide to check my GPU with the command (on Linux):
glxinfo | grep GeForce
And I noticed that my NVIDIA GPU is not supported:
OpenGL renderer string: **GeForce GTX 560M**/PCIe/SSE2
In this link you can find a list, like that:
So my solution was use tensor flow without GPU support. So I do:
pip uninstall tensorflow-gpu
I install whithout support:
pip install tensorflow

TensorFlow 1.2.1 is compatible with cuDNN 5.1, but not yet with 6.0. So just install cuDNN 5.1. Besides that you seem to be missing CUDA 8.0.

Common workaround general problem related to GPU, CUDA, and Docker:
A. If you are dealing with machine learning/ deep learning related deployment, use nvidia-docker and not native-docker. To install nvidia-docker follow these simple steps.
Docker containers are platform-agnostic, but also hardware-agnostic. This presents a problem when using specialized hardware such as NVIDIA GPUs which require kernel modules and user-level libraries to operate. As a result, Docker does not natively support NVIDIA GPUs within containers.
B. If you want to access GPU with docker, never build a container from scratch, you will be fried with a number of errors. Instead just use any container from Nvidia-Docker hub. Choose any specific image, copy its Dockerfile and run sudo nvidia-docker build -t happyapp .. [happyapp is your new app name]. In 5 min you will get your container ready (depends on network speed :p).
C. Never download a nvidia-docker having any cuda/cudnn version If you want to install and run Tensorflow on it. If you do so you will get libcudnn.so.6 or libcudnn.so.9 or libcusolver.so.8.0 related errors and you will hardly get around this errors.
Instead just use pre-built Tensorflow Docker image: sudo nvidia-docker run -it tensorflow/tensorflow:latest-gpu /bin/bash

Related

CuPy on AMD GPU causing an ImportError

I'm trying to use/test the (experimental) AMD GPU support of CuPy (8.1.0). In short: I'm having an ImportError.
I followed the instructions for installing ROCm on a Ubuntu focal machine (with a gfx906/Radeon VII (Vega 20) card).
From the doc I set the mentioned variables (with adjusted HCC_AMDGPU_TARGET), the ROCM_HOME and export PATH=$PATH:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin.
pip3 install -v --no-cache-dir cupy succeeded without any complaints. Just a few compiler notes and warnings because of the -v option
Now when I try to import cupy it's throwing an ImportError.
In [1]: import cupy
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/cupy/__init__.py in <module>
19 message='can\'t resolve package from __spec__')
---> 20 from cupy import core # NOQA
21 except ImportError as e:
/usr/local/lib/python3.8/dist-packages/cupy/core/__init__.py in <module>
----> 1 from cupy.core import core # NOQA
2 from cupy.core import internal # NOQA
3
cupy/core/core.pyx in init cupy.core.core()
cupy/core/_routines_manipulation.pyx in init cupy.core._routines_manipulation()
cupy/core/_routines_indexing.pyx in init cupy.core._routines_indexing()
cupy/core/_routines_math.pyx in init cupy.core._routines_math()
cupy/core/_reduction.pyx in init cupy.core._reduction()
cupy/core/_cub_reduction.pyx in init cupy.core._cub_reduction()
ModuleNotFoundError: No module named 'cupy.cuda.cub'
The above exception was the direct cause of the following exception:
ImportError Traceback (most recent call last)
<ipython-input-1-329ec5cf1bc8> in <module>
----> 1 import cupy
/usr/local/lib/python3.8/dist-packages/cupy/__init__.py in <module>
39 original error: {}'''.format(_exc_info[1])) # NOQA
40
---> 41 raise ImportError(_msg) from e
42
43
ImportError: CuPy is not correctly installed.
If you are using wheel distribution (cupy-cudaXX), make sure that the version of CuPy you installed matches with the version of CUDA on your host.
Also, confirm that only one CuPy package is installed:
$ pip freeze
If you are building CuPy from source, please check your environment, uninstall CuPy and reinstall it with:
$ pip install cupy --no-cache-dir -vvvv
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
original error: No module named 'cupy.cuda.cub'
What should I do next? What should I look for in the compilation process? Thanks in advance
EDIT On request here the complete stdout and stderr of the installation process and a few io's of the console: https://seafile.cloud.uni-hannover.de/d/68862cd1057e47d180aa/
To summarize the discussion in the comments so far:
For CuPy v8.x (the latest stable releases): Up to v8.1 the offending cupy.cuda.cub module is not built in ROCm/HIP environments, which will hopefully be fixed in v8.2 (see ticket).
For CuPy v9.x (the master branch): It should just work as long as rocPRIM and hipCUB are correctly installed. It's likely that the OP's local environment is not correctly set up, leading to cupy.cuda.cub module not built and thus ImportError.

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.

Related to installing of tensorflow in python 3.7

As I am using the command prompt to run python when installing tensorflow it is saying requirment satisfied but when importing giving an error
ImportError
Traceback (most recent call last)
c:\users\chirag\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
17 try:
---> 18 fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
19 except ImportError:
c:\users\chirag\appdata\local\programs\python\python37\lib\imp.py in find_module(name, path)
295 else:
--> 296 raise ImportError(_ERR_MSG.format(name), name=name)
297
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last)
c:\users\chirag\appdata\local\programs\python\python37\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__
c:\users\chirag\appdata\local\programs\python\python37\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
c:\users\chirag\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
19 except ImportError:
---> 20 import _pywrap_tensorflow_internal
21 return _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-d6579f534729> in <module>
----> 1 import tensorflow
c:\users\chirag\appdata\local\programs\python\python37\lib\site-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:
c:\users\chirag\appdata\local\programs\python\python37\lib\site-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
c:\users\chirag\appdata\local\programs\python\python37\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\chirag\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "c:\users\chirag\appdata\local\programs\python\python37\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\chirag\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "c:\users\chirag\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "c:\users\chirag\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
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.
The TensorFlow build from source on Windows guide mentions it only supports Python 3.5 and Python 3.6.
Last time I installed tensorflow on Windows, if I recall correctly I used Python 3.6.4 64-bit. (I had some errors with Python 3.6.5 but that was last summer so there's a chance slightly newer versions of 3.6 might work).
Docs mention:
Requires Python 3.4, 3.5, or 3.6
Because I wanted to install tensorflow-gpu I also had to be mindful of the CUDA Toolkit and CuDNN versions too (some combinations didn't work).
Unfortunately I don't remember the CUDA/CuDNN versions 100% but documentation mentions CUDA 9.0 (e.g. Download cuDNN v7.0.5 (Dec 5, 2017), for CUDA 9.0
Looking at the nVidia CUDA Archive that's from Sept. 2017 so I would go with a CuDNN version compatible with CUDA 9.0 from around that time from their CuDNN Archive(e.g. 7.0.5 for Windows 10).
Not 100% guaranteed if this will work, but something like this:
Uninstall Python 3.7 (unless you can find a simple way to install multiple version of Python and switch as needed, but doing quick searches reveal it's a bit of a headache on Windows)
Install Python 3.6.4 64 bit
Install pip (if it's not already installed) (download get-pip.py and run it)
Install virtualenv(pip install virtualenv, virtualenv tf-gpu,.\tf-gpu\Scripts\activate) (the point of the virtual environment is to keep a local tensorflow setup as opposed to a global module which might cause headaches with other projects using different TensorFlow dependency versions (numpy,protobuf,six,etc.)
Install CUDA 9.0
Install CuDNN (7.0.5 or wee bit higher, but for CUDA 9.0 for sure)
Reboot, double check Windows Environment Variables for CUDA/CUDNN paths and verify the installs
Finally install TensorFlow with GPU support in the virtual environment:pip install tensorflow-gpu (will take a bit of time: might as well hydrate, etc.)
Hopefully the installation completed successfully in which case verify it: quick test: python -c 'import tensorflow;print("TensorFlow version:",tensorflow.__version__)'...if this doesn't throw errors and prints the version open run the HelloWorld example (which should also print some CUDA info) once the session runs.
If you don't want tensorflow-gpu or don't have a tensorflow compatible GPU you can skip the CUDA/CuDNN part. I still recommend making a virtual environment (e.g. tf-cpu) then use pip install tensorflow instead of pip install tensorflow-gpu within the activated virtual environment.

import tensorflow as tf gives errors even after installing without errors

I've been trying to solve this issue for long time. After many attempts in my existing python=3.5 env (in Anaconda), I deleted it and created a new env again just to properly install tensorflow with gpu support. To do that I did conda create -n FALL python=3.5 and then pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.11.0-cp35-cp35m-win_amd64.whl as suggested in tensorflow site, because I am on Windows 10 and have Anaconda. There was no error during installation. And I have been using Cuda 8.0 and cuDNN for my other deep learning practices without any hinders. So I could type python in my activated env. To check if tensorflow is installed accurately I did import tensorflow as tf and got
Traceback (most recent call last):
File "C:\Users\username\Anaconda3\envs\FALL\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\username\Anaconda3\envs\FALL\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\username\Anaconda3\envs\FALL\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\username\Anaconda3\envs\FALL\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\username\Anaconda3\envs\FALL\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\username\Anaconda3\envs\FALL\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\username\Anaconda3\envs\FALL\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\username\Anaconda3\envs\FALL\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\username\Anaconda3\envs\FALL\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\username\Anaconda3\envs\FALL\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\username\Anaconda3\envs\FALL\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\username\Anaconda3\envs\FALL\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\username\Anaconda3\envs\FALL\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
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.
I would like someone could help me as possible.
Not sure if you are still looking for this question to be answered, but seeing as I just battled this very issue for the past few days, I figured I'd leave my two cents here in case it helps anyone moving forward.
As an initial note, I was not installing tensorflow through anaconda, but rather just via a pip install in a python virtualenv. I expect the solution to this issue would be similar using either anaconda or just pip.
It really just turned out in the end that I had one or more programs installed in incompatible versions for tensorflow.
As of my writing of this, tensorflow-gpu requires CUDA 9.0, CUPTI (should be included with the CUDA install), and cuDNN version greater than 7.2 (but note that this version should be compatible with your specific install of CUDA). My problem was that I was unwittingly using CUDA 10.0, which I think is theoretically compatible with tensorflow-gpu (based on cursory searches, it seems to work for some people), but didn't work for me at all.
Long story short, here is exactly the setup/process that worked for me:
CUDA compatible GPU (https://developer.nvidia.com/cuda-gpus to check yours specifically
python 3.5.4
tensorflow-gpu version 1.12.0
CUDA 9.0
CUPTI (again, this is included with your CUDA 9.0 install)
cuDNN 9.0 version 7.4.1.5. To install this correctly, make sure the .dll in /bin gets copied into the /bin folder of Cuda 9, the .h file from /include gets copied into the Cuda 9 /include folder, and the .lib file from /lib/x64 folder gets copied into the /lib/x64 folder for Cuda 9 (this all seems self evident, but oddly some installation guides I've seen only reference copying the .dll over).
visual c++ 2017
Microsoft Visual C++ 2015 Redistributable Update 3 (this can be found under 'Redistributables and Build Tools' here: https://visualstudio.microsoft.com/vs/older-downloads/). Do note that to install this I had to go into programs and settings and manually uninstall the visual c++ 2017 redistributable that was installed when I installed visual c++ to begin with.
Include both CUDA 9 and CUPTI in your path (CUDA (and cuDNN) for me was in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin, and CUPTI was in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUPTI\libx64)
After all this importing tensorflow worked fine for me.
I honestly hope this helps someone out there, as this process was incredibly arduous for me personally and I'd love to be able to lessen that for someone else.

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.