DLL load failed: The specified procedure could not be found. And not showing any missing DLL file name - tensorflow

I'm on windows 10, I'm getting this error but cant see any helpful clue to fix this. I'm trying to install tensorflow and my python version is 3.6. Can any one help me to fix this.
(venv) D:\Work\IIT\Fourth Year\Submission\FYP\FYP Project\FYPProject>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-02-03 08:25:40.694788: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened
dynamic library cudart64_101.dll
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
from tensorflow_core import *
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP Project\FYPProject\venv\lib\site-packages\tensorflow_core\python\__init__.py", line 64, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP Project\FYPProject\venv\lib\site-packages\tensorflow_core\core\framework\graph_pb2.py", line 7, in <module>
from google.protobuf import descriptor as _descriptor
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
>>>

So far I have found this. First uninstall the existing tensorflow using
pip uninstall tensorflow
And install again using this,
pip install tensorflow==1.5
pip install protobuf==3.6.0
if the 'tf_utils' error come you can try this,
pip install keras==2.1.5

Related

Tensorflow cannot be imported on ubuntu

System information
Linux Ubuntu 16.04
TensorFlow version: tensorflow-gpu 1.5
Python version: 2.7
Installed using virtualenv: pip
CUDA/cuDNN version: CUDA9.0 & CUDNN7.0
Enviroment
Using anaconda to create a virtual environment named tf.
Error Msg
(tf) ➜ ~ python
Python 2.7.18 |Anaconda, Inc.| (default, Jun 4 2021, 14:47:46)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/google/protobuf/descriptor.py", line 113
class DescriptorBase(metaclass=DescriptorMetaclass):
^
SyntaxError: invalid syntax
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
As mentioned in this link, You're running the script in the same directory as TensorFlow. Try to move it out and you should be fine.
For example, Open the Linux command line and execute the script that you've just copied to desktop
Restarting the conda (using miniconda + conda-forge channel) works for me. But I don't know why, though...

Getting Error while running python3 main.py file

I am getting this error,
/tmp/Python-3.7.5$ python3 main.py
Traceback (most recent call last):
File "main.py", line 3, in <module>
import pandas as pd
File "/home/abc/.local/lib/python3.7/site-packages/pandas/__init__.py", line 51, in <module>
from pandas.core.api import (
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/api.py", line 31, in <module>
from pandas.core.groupby import Grouper, NamedAgg
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 65, in <module>
from pandas.core.frame import DataFrame
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/frame.py", line 119, in <module>
from pandas.core import algorithms, common as com, generic, nanops, ops
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/generic.py", line 112, in <module>
from pandas.io.formats import format as fmt
File "/home/abc/.local/lib/python3.7/site-packages/pandas/io/formats/format.py", line 77, in <module>
from pandas.io.common import stringify_path
File "/home/abc/.local/lib/python3.7/site-packages/pandas/io/common.py", line 3, in <module>
import bz2
File "/usr/local/lib/python3.7/bz2.py", line 19, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
what is the solution?
How did you install your Python? If you've manually built it or used the make command, you might be missing the bz2 library headers.
Try the following...
Centos/Fedora/RHEL:
sudo yum install bzip2-devel
Debian and Ubuntu:
sudo apt-get install libbz2-dev
You'll then either need to rebuild your Python installation or to copy the header in your Python folder, with:
sudo cp /usr/lib/python3.7/lib-dynload/_bz2.cpython-38-x86_64-linux-gnu.so /usr/local/lib/python3.7/

After installing Tensorflow-gpu i got error Failed to load the native TensorFlow runtime

I have installed redhat 6.6, cuda 9.0, cudnn 7.3.1 and tesnorflow-gpu. but after installation getting following error. My graphics card is nvidia titan v
Traceback (most recent call last):
File "<ipython-input-1-88d96843a926>", line 1, in <module>
import keras
File "/root/anaconda3/lib/python3.7/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/root/anaconda3/lib/python3.7/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/root/anaconda3/lib/python3.7/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/root/anaconda3/lib/python3.7/site-packages/keras/backend/__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "/root/anaconda3/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/root/anaconda3/lib/python3.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)
File "/root/anaconda3/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/root/anaconda3/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcuda.so.1: cannot open shared object file: No such file or directory
Did you tested your installations of cuda and cudnn:
Nvidia drivers:
$ nvidia-smi
This should display you an overview of the metrics of your GPU
Test cuda:
Check first if:
$ nvcc -V
display the right version of your cuda toolkit
Then you can test it with the following process:
First:
$ cd ~/NVIDIA_CUDA-9.0_Samples
$ make
And then:
$ cd ~/NVIDIA_CUDA-10.0_Samples/bin/x86_64/linux/release
$./deviceQuery
if you have a 'Result: pass' at the end, you're all good!
To test cudnn:
$ cp -r /usr/src/cudnn_samples_v7/ $HOME
$ cd $HOME/cudnn_samples_v7/mnistCUDNN
$ make clean && make
$ ./mnistCUDNN
You should have as result: 'Test passed!'
Tensorflow:
If cuda and cudnn are working, i advice you to install tensorflow in a conda environment using:
conda create --name tf_gpu tensorflow-gpu
For me (and after a lot of problems) it was working very well.
To test it:
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
main sources:
install tensorflow GPU
tensorflow for GPU made easy

Tensorflow 2.0.: ImportError: DLL load failed: The specified module could not be found

I just installed tensorflow 2.0 using the pip command:
pip install tensorflow-gpu==2.0.0-alpha0
The import error is shown as follows:
import tensorflow as tf
Traceback (most recent call last):
File "<ipython-input-1-64156d691fe5>", line 1, in <module>
import tensorflow as tf
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\__init__.py", line 27, in <module>
from tensorflow._api.v2 import audio
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\_api\v2\audio\__init__.py", line 8, in <module>
from tensorflow.python.ops.gen_audio_ops import decode_wav
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Anaconda\Anaconda3.7\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:\Anaconda\Anaconda3.7\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Anaconda\Anaconda3.7\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
The installation was done on the Windows 10 with python 3.7.1, and cuda 9.0.
I have successfully installed tensorflow-gpu 1.13 on my pc in the python 3.5 environment. It seems tensorflow 2.0 is compatible with python 3.7 Ultimate Guide to TensorFlow 2.0 in Python?
TF2.0 was built with CUDA 10 in mind. source
You either can install CUDA 10.0 with cuDNN SDK (>= 7.4.1) or build Tensorflow from sourse.

rpy2.ipython errors with pandas / numpy

Trying to use the rpy2.ipython (formerly 'rmagic') extension of IPython, to get interactive R (%R line magic and %%R cell magic functions), I get the following errors...
louis ~ $ python
Python 3.5.1 |Anaconda 2.4.0 (64-bit)| (default, Dec 7 2015, 11:16:01)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2.ipython
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 7, in <module>
from pandas import hashtable, tslib, lib
File "pandas/src/numpy.pxd", line 157, in init pandas.hashtable (pandas/hashtable.c:38262)
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/polynomial.py", line 20, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/__init__.py", line 51, in <module>
from .linalg import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: /home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so: undefined symbol: zgelsd_
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/rmagic.py", line 59, in <module>
from rpy2.robjects import pandas2ri as baseconversion
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/robjects/pandas2ri.py", line 6, in <module>
from pandas.core.frame import DataFrame as PandasDataFrame
File "/home/louis/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 13, in <module>
"extensions first.".format(module))
ImportError: C extension: /home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so: undefined symbol: zgelsd_ not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/__init__.py", line 1, in <module>
from .rmagic import load_ipython_extension
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/rmagic.py", line 63, in <module>
from rpy2.robjects import numpy2ri as baseconversion
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/robjects/numpy2ri.py", line 6, in <module>
import numpy
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/polynomial.py", line 13, in <module>
import numpy.core.numeric as NX
AttributeError: module 'numpy' has no attribute 'core'
I've always ignored the fact that Anaconda3 seems to have been built on RHEL (I'm on Linux Mint, which is based on Ubuntu), but I'm wondering now if this might be the cause of the problem here - "C extensions not built" for my machine?
Since it's in the conda virtual environment, I'm not sure how I can fix this.
Should I attempt to python setup.py build_ext --inplace within ~/anaconda3/lib/python3.5/site-packages/pandas ?
When I step through the above imports, of e.g. :
from numpy.linalg import lapack_lite, _umath_linalg
there's no error, so I'm not certain there are actually unbuilt files, perhaps it's just some masking of one variable by another (as in this question with similar error message but different traceback, i.e. an error in rpy2).
import numpy.core (etc.) without first trying to load rpy2.ipython works fine
Summary of pip show :
---
Metadata-Version: 2.0
Name: rpy2
Version: 2.7.5
---
Metadata-Version: 1.1
Name: numpy
Version: 1.10.1
---
Metadata-Version: 1.1
Name: pandas
Version: 0.17.0
---
Metadata-Version: 2.0
Name: ipython
Version: 4.0.1
(all locations /home/louis/anaconda3/lib/python3.5/site-packages)
System info from cat /proc/version and lsb_release -a :
Linux version 3.13.0-35-generic (buildd#panlong) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014
LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch
Description: Linux Mint 17 Qiana
I am suspecting an incompatibility between versions of the LAPACK library: the one picked at runtime on your system, the one numpy was built with, and the one R was built with.
Installing numpy, R, and rpy2 from source in your virtual environment should solve the issue. An alternative would be to notify the maintainers of the anaconda packages involved and see it they confirm that numpy and R packaged by anaconda use the same LAPACK.