8

I'm getting an ImportError if OpenCV (cv2) is imported after the tensorflow exporter.

ubuntu@ip-172-31-2-144:~/Downloads/opencv-2.4.13/release$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tensorflow.contrib.session_bundle import exporter
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcurand.so locally
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen: cannot load any more object with static TLS
>>> 

However, it works just fine the other way around:

ubuntu@ip-172-31-2-144:~/Downloads/opencv-2.4.13/release$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> from tensorflow.contrib.session_bundle import exporter
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcurand.so locally
>>> 

Any idea what's going on?

Vikesh
  • 2,018
  • 6
  • 23
  • 33
  • http://stackoverflow.com/questions/14892101/cannot-load-any-more-object-with-static-tls tells me that this means that one of the two is not linked the right way (with -fPIC). It might be a problem with either OpenCV or Tensorflow. You might follow the instructions in http://stackoverflow.com/questions/1340402/how-can-i-tell-with-something- like-objdump-if-an-object-file-has-been-built-wi to work out which it is and report back. – Peter Hawkins Oct 27 '16 at 19:02

2 Answers2

0

I had the same error as you and I've just fixed it executing import opencv2 a second time. It's a workaround.. but I can continue working, so..

richar8086
  • 177
  • 4
  • 13
0

I had same issue but solved. When I import cv2 on jupyter notebook, same error was displayed, but after that, I imported cv2 on terminal (python) then it worked. And finally, cv2 can be imported on jupyter notebook. Please try that.