aleju / imgaug

Image augmentation for machine learning experiments.
http://imgaug.readthedocs.io
MIT License
14.35k stars 2.43k forks source link

Import error caused by some conflict with tensorflow #611

Open CMCDragonkai opened 4 years ago

CMCDragonkai commented 4 years ago

I found this weird error with imgaug 0.4.0 and tf 1.15.0.

import tensorflow as tf
import imgaug

Gives me:

Python 3.7.6 (default, Dec 18 2019, 19:23:55) 
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-02-14 16:56:44.373921: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.2
>>> import imgaug
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/gsfhp99q0i2wdv0rq451nx7ygq0v9nwj-python3.7-imgaug-0.4.0/lib/python3.7/site-packages/imgaug/__init__.py", line 7, in <module>
    from imgaug.imgaug import *  # pylint: disable=redefined-builtin
  File "/nix/store/gsfhp99q0i2wdv0rq451nx7ygq0v9nwj-python3.7-imgaug-0.4.0/lib/python3.7/site-packages/imgaug/imgaug.py", line 18, in <module>
    import cv2
ImportError: /nix/store/c801vyj23lyq3m0ppnmgjhq09grk3l6q-gcc-7.5.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /nix/store/lx96qc10194p859q3040b0j1bqgkb00l-opencv-3.4.8/lib/libopencv_dnn.so.3.4)

But if I do the other way around:

import imgaug 
import tensorflow as tf

It works as advertised!

Is there some conflict between tensorflow and imgaug in how they use opencv? This conflict leaks through the imports... really annoying.

aleju commented 4 years ago

Hm, weird error. I'm not aware of any incompatibilities with respect to OpenCV. There are similar errors here: https://github.com/lhelontra/tensorflow-on-arm/issues/13 and here: https://github.com/ContinuumIO/anaconda-issues/issues/483 . Maybe one of the suggestions helps?

Which package manager did you use for the installations? Does /nix mean that you use NixOS?

CMCDragonkai commented 4 years ago

Yes I'm using NixOS. But I'm just changing the import order to avoid this problem.

On 17 February 2020 00:35:43 GMT+11:00, Alexander Jung notifications@github.com wrote:

Hm, weird error. I'm not aware of any incompatibilities with respect to OpenCV. There are similar errors here: https://github.com/lhelontra/tensorflow-on-arm/issues/13 and here: https://github.com/ContinuumIO/anaconda-issues/issues/483 . Maybe one of the suggestions helps?

Which package manager did you use for the installations? Does /nix mean that you use NixOS?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/aleju/imgaug/issues/611#issuecomment-586706940

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

CMCDragonkai commented 3 years ago

This seems to apply where you need to import cv2 ahead of tensorflow as well.

import cv2
import tensorflow as tf

Because of:

Python 3.7.8 (default, Jun 27 2020, 09:38:56) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.>>> import tensorflow as tf
>>> import cv2Traceback (most recent call last):
  File "<stdin>", line 1, in <module>ImportError: /nix/store/xdpy9i6y2xk3jqc8nib7i5lyrwz25q2v-gcc-7.5.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /nix/store/3c9g460yf3i16ism88zz58zpbs0m5sg7-opencv-3.4.8/lib/libopencv_dnn.so.3.4)>>>