undefined symbol: cuDevicePrimaryCtxGetState when importing tensorflow - python-2.7

everyone!
I'm trying to install and run tensorflow (GPU-support). I followed the guide and installed cudnn 7 and cuda 9.0.
However, when trying to import tensorflow, I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/boudi/anaconda2/lib/python2.7/site-
packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint:
disable=unused-import
File "/home/boudi/anaconda2/lib/python2.7/site-
packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/boudi/anaconda2/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/boudi/anaconda2/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/boudi/anaconda2/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
<module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/boudi/anaconda2/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: /home/boudi/anaconda2/lib/python2.7/site-
packages/tensorflow/python/../libtensorflow_framework.so: undefined
symbol: cuDevicePrimaryCtxGetState
How can I fix it?

I had the same problem - I had already installed the required NVIDIA drivers on my Ubuntu machine, but when I tried to import Tensorflow I got the same error.
So for me the problem was that I was using the Nouveau driver instead of the NVIDIA driver. In order to fix the issue you need to go to System Settings->Software & Updates->Additional Drivers and select the option Using NVIDIA binary driver ... and then click at the Apply Changes button. Then just reboot and you're done.

Related

ImportError: libblas.so.3

After installation of turicreate, when I am importing it
import turicreate
I am getting the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/papun/anaconda2/lib/python2.7/site-packages/turicreate/__init__.py", line 19, in <module>
from turicreate.data_structures.sgraph import Vertex, Edge
File "/home/papun/anaconda2/lib/python2.7/site-packages/turicreate/data_structures/__init__.py", line 18, in <module>
from . import sframe
File "/home/papun/anaconda2/lib/python2.7/site-packages/turicreate/data_structures/sframe.py", line 16, in <module>
from ..connect import main as glconnect
File "/home/papun/anaconda2/lib/python2.7/site-packages/turicreate/connect/main.py", line 13, in <module>
from ..cython.cy_unity import UnityGlobalProxy
ImportError: libblas.so.3: cannot open shared object file: No such file or directory
It will helpful, if I can get a suggestion on this. I have also tried
re installing scipy.
You need to install Blas.
Follow instruction details in this blog: libblas and liblapack issues and speed, with SciPy and Ubuntu

libcublas issue - tensorflow

I am very new to tensorflow, struggling on its installation. I use ubuntu 16.04. I obviously installed the Nvidia dependencies.
Whenever I type in:
import tensorflow as tf
I get:
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
builtins.execfile(filename, *where)
File "/media/as/KINGSTON/SIEC NEURONOWA/NETWORK.py", line 3, in <module>
from keras.models import Sequential
File "/usr/local/lib/python2.7/dist-packages/keras/__init__.py", line 3, in <module>
from . import activations
File "/usr/local/lib/python2.7/dist-packages/keras/activations.py", line 4, in <module>
from . import backend as K
File "/usr/local/lib/python2.7/dist-packages/keras/backend/__init__.py", line 73, in <module>
from .tensorflow_backend import *
File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 1, in <module>
import tensorflow as tf
File "/home/as/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/as/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/as/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/as/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/as/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/as/.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: libcublas.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I tried many solutions, but the effect remains the same. Many thanks for help!
I had this same problem when installing gputools in R. After hundreds of tries, the command which worked for me is:
sudo ln -s /usr/local/cuda/lib64/libcublas.so.8.0 /usr/lib/libcublas.so.8.0
OR
sudo ln -s /usr/local/cuda-8.0/lib64/libcublas.so.8.0 /usr/lib/libcublas.so.8.0

Error on QSTK.qstkstudy on Python 2.7.3

I am trying to install QSTK on my python 2.7.3. (on windows 10). During the installation, it seemed there was no problem and I did not face any errors. However, when I run the validation.py (here) to check it seems that QSTK.qstkstudu cannot be imported. Here is the error that I get while running validation.py:
QSTK is installed and can be imported
[...]
QSTK.qstkutil is installed and can be imported
File "C:\Python27\lib\site.py", line 372, in __call__
raise SystemExit(code)
SystemExit: Error : QSTK.qstkstudy can not be imported.
Does anyone have a clue what should I do?
The line in Validation.py which produces the error is:
import QSTK.qstkstudy.EventProfiler
If you try it directly in python, you can see what is missing. In my case it was tkinter.
>>> import QSTK.qstkstudy.EventProfiler
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkstudy/EventProfiler.py", line 16, in <module>
import matplotlib.pyplot as plt
File "/usr/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 114, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from matplotlib.externals.six.moves import tkinter as Tk
File "/usr/lib/python2.7/dist-packages/matplotlib/externals/six.py", line 199, in load_module
mod = mod._resolve()
File "/usr/lib/python2.7/dist-packages/matplotlib/externals/six.py", line 113, in _resolve
return _import_module(self.mod)
File "/usr/lib/python2.7/dist-packages/matplotlib/externals/six.py", line 80, in _import_module
__import__(name)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package
I am on Linux so I did
sudo apt-get python-tk
Google how to install python tkinter in Windows.
Good luck

Successfully installed georasters but unable to import

Not able to solve.Kindly clarify.
I had installed georasters then it gave error with numpy ,now numpy is solved it is giving error with fiona.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import georasters
File "D:\Python\lib\site-packages\georasters\__init__.py", line 3, in <module>
from .georasters import get_geo_info, map_pixel, map_pixel_inv, aggregate, create_geotiff, align_rasters, \
File "D:\Python\lib\site-packages\georasters\georasters.py", line 38, in <module>
from fiona.crs import from_string
File "D:\Python\lib\site-packages\fiona\__init__.py", line 77, in <module>
from fiona.collection import Collection, BytesCollection, vsi_path
File "D:\Python\lib\site-packages\fiona\collection.py", line 7, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: DLL load failed: The specified module could not be found.
Having same issue.
Just install fiona and geopandas.
pip install fiona geopandas

How can I resolve the "import multiarray" error in parallel python?

I am trying to run a python 2.7 script which uses parallel python (version 1.6.1) to excute a function which uses numpy arrays (numpy version 1.6.1) on a Ubuntu Voyager (Ubuntu 12.04 derivative) system. It gives me the following error message (actually, it's still longer, repeated 12 times I guess):
Starting pp with 12 workers
* An error has occured during the module import
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/ppworker.py", line 49, in preprocess
exec module
File "<string>", line 1, in <module>
File "/usr/share/pyshared/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/usr/share/pyshared/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/usr/share/pyshared/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/usr/share/pyshared/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/usr/share/pyshared/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: No module named multiarray
A fatal error has occured during the function execution
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/ppworker.py", line 86, in run
__args = pickle.loads(__sargs)
File "/usr/share/pyshared/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/usr/share/pyshared/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/usr/share/pyshared/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/usr/share/pyshared/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/usr/share/pyshared/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: No module named multiarray
Exception in thread run_local:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 504, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/pymodules/python2.7/pp.py", line 719, in _run_local
job.finalize(sresult)
UnboundLocalError: local variable 'sresult' referenced before assignment
Exception in thread run_local:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 504, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/pymodules/python2.7/pp.py", line 719, in _run_local
job.finalize(sresult)
UnboundLocalError: local variable 'sresult' referenced before assignment
From other threads (e.g. importing NumPy in Parallel Python) I have seen that it's probably an issue with the communication of pp and numpy, so I have tried these:
updating pp and numpy
reinstalling numpy (I'm using the anaconda package)
running the code directly from the shell (not from spyder)
submitting multiarray (which otherwise imports just fine) directly to the workers with the job (and I'm sure I have the correct syntax ...)
but to no avail. Do you have any other suggestions? Is there a simple workaround other than, erm, "de-numpying" my function (which would be sad, it's a matrix multiplication)? My colleague who uses a more recent version of the same operating system, but otherwise the same python setup, does not seem to have this problem, but since time is an issue updating my system or hijacking his slower computer are both not the best options.
If necessary, feel free to ask for more details & thank you in advance.