bazel.rc seems take no effect when build tensorflow-serving r1.10 or r1.11 - tensorflow-serving

I am building tensorflow-serving r1.10; since my centos7 default python version is 2.7.13 and I want to build with python3.6, so I changed the PYTHON_BIN_PATH in tools/bazel.rc like this.[The python3.6 env is installed with pyenv]
build --action_env PYTHON_BIN_PATH="/home/pyenv/.pyenv/versions/tensorflow-serving/bin/python"
build --define PYTHON_BIN_PATH=/home/pyenv/.pyenv/versions/tensorflow-serving/bin/python
It had been worked when I build tensorflow-serving r 1.9 before. but now, It does not work, so it is the problem with tensorflow-serving r1.11
ERROR: /home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/external/org_tensorflow/tensorflow/BUILD:581:1: Executing genrule #org_tensorflow//tensorflow:tensorflow_python_api_gen failed (Exit 1): bash failed: error executing command
(cd /home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving && \
exec env - \
PATH=/home/pyenv/.pyenv/plugins/pyenv-virtualenv/shims:/home/pyenv/.pyenv/shims:/home/pyenv/.pyenv/bin:/usr/local/ffmpeg/bin/:/opt/jdk1.8.0_112/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/pyenv/.local/bin:/home/pyenv/bin \
/bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api --root_init_template=external/org_tensorflow/tensorflow/api_template.__init__.py --apidir=bazel-out/host/genfiles/external/org_tensorflow/tensorflow --apiname=tensorflow --apiversion=2 --package=tensorflow.python --output_package=tensorflow bazel-out/host/genfiles/external/org_tensorflow/tensorflow/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/app/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/bitwise/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/compat/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/data/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/debugging/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/distributions/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/distributions/bijectors/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/dtypes/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/errors/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/feature_column/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/gfile/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/graph_util/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/image/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/io/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/initializers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/activations/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/densenet/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/inception_resnet_v2/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/inception_v3/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/mobilenet/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/nasnet/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/resnet50/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/vgg16/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/vgg19/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/xception/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/backend/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/callbacks/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/constraints/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/boston_housing/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/cifar10/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/cifar100/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/fashion_mnist/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/imdb/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/mnist/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/reuters/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/estimator/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/initializers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/layers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/losses/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/metrics/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/models/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/optimizers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/preprocessing/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/preprocessing/image/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/preprocessing/sequence/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/preprocessing/text/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/regularizers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/utils/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/wrappers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/wrappers/scikit_learn/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/layers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/linalg/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/logging/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/losses/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/manip/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/math/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/metrics/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/nn/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/nn/rnn_cell/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/profiler/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/python_io/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/quantization/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/resource_loader/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/strings/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/builder/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/constants/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/loader/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/main_op/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/signature_constants/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/signature_def_utils/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/tag_constants/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/utils/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/sets/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/sparse/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/spectral/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/summary/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/sysconfig/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/test/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/train/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/train/queue_runner/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/user_ops/__init__.py')
Traceback (most recent call last):
File "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 27, in <module>
from tensorflow.python.tools.api.generator import doc_srcs
File "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: /home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _Py_FalseStruct
There even no PYTHON_BIN_PATH in the exec command.
I know tensorflow-serving r1.10 should build with bazel0.15 +, So what happend here? how do I change bazel.rc to specify my python path ?

It's hard to tell without a minimal, complete, and veriafiable example. Perhaps bazel isn't picking up on your workspace for some reason?
One thing you can try is using a .bazelrc file instead:
https://docs.bazel.build/versions/master/best-practices.html#bazelrc

Related

Missing dll tensorflow-gpu

I have anaconda and python installed and I am trying to use tensorflow through command prompt. Can someone help?
(venv)
C:\Users\NeravDOSHI>.\venv\Scripts\activate
(venv)
C:\Users\NeravDOSHI>python --version
Python 3.7.6
(venv)
C:\Users\NeravDOSHI>pip3 --version
pip 20.1 from C:\Users\NeravDOSHI\venv\lib\site-packages\pip (python 3.7)
(venv)
C:\Users\NeravDOSHI>virtualenv --version
virtualenv 20.0.20 from c:\programdata\anaconda3\lib\site-packages\virtualenv\__init__.py
(venv)
C:\Users\NeravDOSHI>pip install --ignore-installed --upgrade
https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.13.1-cp36-cp36m-win_amd64.whl
ERROR: tensorflow-1.13.1-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.
(venv)
C:\Users\NeravDOSHI>python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "c:\programdata\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:\programdata\anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "c:\programdata\anaconda3\lib\imp.py", line 342, 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 "<string>", line 1, in <module>
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 50, in <module>
from tensorflow.python import pywrap_tensorflow
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 69, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "c:\programdata\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:\programdata\anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "c:\programdata\anaconda3\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.
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.
Please follow the instructions from TensorFlow website. I recommend please install Tensorflow 2, if you are using lower versions.
You need to download and install/update the Microsoft Visual C++ 2015-2019 Redistributable (x64) from here.
If you are facing any other issues possible reasons are
Your CPU does not support AVX2 instructions
Your CPU/Python is on 32 bits
There is a library that is in a different location/not installed on your system that cannot be loaded.
Please refer tested build configurations for windows CPU and GPU.

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

VirtualEnv tensorflow with Nvidia GPU : cuda-9.0-vs-cuda-8.0, cuDNN-7.0-vs-cuDNN-6.0

Today I installed tensorflow using the RTFM tensorflow dot org install linux,
I installed the VirtualEnv + Python3 + CPU and tested tensorflow Hello World, which worked fine.
Then I went on the nvidia path (GPU GTX 970) to install VirtualEnv + Python + GPU. RTFM (docs dot nvidia dot com cuda cuda-installation-guide-linux index dot html) , cuda-9.0, cuDDN 7, all PATH's are okay, .bashrc up-to-date, printenv LD_LIBRARY_PATH ok.
My GPU has been ok with the cuda scripts deviceQuery and bandwitdhTest. All post-installation-actions from the Nvidia checklist passed.
When I run Hello World in VirtualEnv+Python3+GPU, code below is what I get (cliffnote : tensorflow wants to use some cudalibrary-8.0 from the /usr/local/cuda-9.0/lib64 which is a 9.0 directory. I tried to add a symlink so cudalibrary-8.0 points to 9.0, but then I get the same message with another cudalibrary... doing this trick for all the cuda libraries is not what I call a fix ;-) )
alexandre#Martin-2:~/Documents/Ordinateur/VirtualEnv$ source tensorflow_py3_gpu/bin/activate
(tensorflow_py3_gpu) alexandre#Martin-2:~/Documents/Ordinateur/VirtualEnv$ python
Python 3.5.2 (default, Sep 14 2017, 22:51:06) [GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> # Python
... import tensorflow as tf
Traceback (most recent call last):
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/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 "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory
Last line above is about the cudalibrary-8.0 that obviously is NOT in the list of the cudalibrary-9.0. Below is the rest of it.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/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 "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https tensorflow dot org slash install slash install_sources hashtag common_installation_problems for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.
>>> hello = tf.constant('Hello, TensorFlow!')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'tf' is not defined
>>> sess = tf.Session()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'tf' is not defined
>>> print(sess.run(hello))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sess' is not defined
>>> quit()
(tensorflow_py3_gpu) alexandre#Martin-2:~/Documents/Ordinateur/VirtualEnv$ deactivate`
--
Next day update
Not so clean fix : Create a link in /usr/local/cuda/lib64/ for every library with the wrong number version, linked to the right number version.
alexandre#Martin-2:/usr/local/cuda/lib64$ sudo ln -s libcurand.so.9.0 libcurand.so.8.0
I did this with five cuda libraries (libcusolver, libcublas, libcudart, libcurand, libcufft) and with the cuDNN library libcudnn (version 6 --> version 7).
Hello world! tensorflow worked... but if someone can tell me why tensorflow calls cuda-8.0 and cuDDN-6.0 libraries when I only installed cuda-9.0 and cuDDN-7.0, you're very welcome.
[SOLVED... OR NEARLY] UPDATE
I found https://github.com/tensorflow/tensorflow/issues/12052 that explains almost it all.
Cliffnote :
tensorflow-1.3 uses cuda-8.0 and cuDNN-6.0 (this is why these libraries are linked explicitly when I run tensorflow). I got tricked on the nvidia site that made me download the cuda-9.0 and cuDNN-7.0 versions, which will not be implemented in tensorflow-1.3.
tensorflow-1.4 will work with the cuda-9.0 and cuDNN-7.0 versions. tensorflow-1-4 may be available sometime in October 2017 (or anytime soon, check the link above).
Have you tried
sudo apt install cuda-8-0
?
It should download packages from http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604
Along with installing cudnn6 (the same way I installed cudnn7), it worked for me.

ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory

I am trying to use tensorflow-gpu on my system. I have re-installed it many times, it gives the error give below. But when I use tensorflow-cpu it works fine. I have cuda 8.0 toolkit installed and cudnn 5.1.
Traceback (most recent call last):
File "finetune.py", line 17, in <module>
import tensorflow as tf
File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
If changing your path variable does not work, running the following in your terminal is what usually solves this for me:
sudo ldconfig /usr/local/cuda/lib64
(sometimes cuda may need to be something like cuda-8.0, depending on your installation)
The problem is that you don't have environment variable CUDA_HOME set. If you think you have CUDA installed, then you need to make sure that the above environment variable is set prob=perly and contains address of the CUDA installation directory where all share libraries are located.
export CUDA_HOME=/CUDA/installation/path
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64"
sudo ldconfig /usr/local/cuda/lib64
Works for me.
Please refer this link for more information.
https://github.com/tensorflow/tensorflow/issues/5343

Error with swig_import_helper and PyModule_Create2 when building tensorflow-serving with bazel

I'm trying to install tensorflow-serving using bazel, and when I run
bazel build tensorflow_serving/...
to build the source tree, I get this error:
ERROR: /home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/external/org_tensorflow/tensorflow/contrib/session_bundle/example/BUILD:38:1: Executing genrule #org_tensorflow//tensorflow/contrib/session_bundle/example:half_plus_two failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Traceback (most recent call last):
File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/tf_serving/../org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.py", line 32, in <module>
import tensorflow as tf
File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 48, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: /home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow.so: undefined symbol: PyModule_Create2
What do I do?
I'm running python 3.5, gcc/g++ 4.9, CUDA 8.0, have swig installed, and am trying to build on Ubuntu Mate 16.04 with a GTX 1080.
Thanks!