agentmorris / MegaDetector

MegaDetector is an AI model that helps conservation folks spend less time doing boring things with camera trap images.
MIT License
117 stars 26 forks source link

Error installing tensorflow 1.13.1 #41

Closed agentmorris closed 1 year ago

agentmorris commented 1 year ago

I couldn't install tensorflow using the readme instructions:

$ pip install tensorflow==1.13.1
ERROR: Could not find a version that satisfies the requirement tensorflow==1.13.1 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.2.2, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1, 2.3.2, 2.4.0rc0, 2.4.0rc1, 2.4.0rc2, 2.4.0rc3, 2.4.0rc4, 2.4.0)
ERROR: No matching distribution found for tensorflow==1.13.1

But after some googling this method worked for me:

python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.13.1-py3-none-any.whl

Issue cloned from Microsoft/CameraTraps, original issue posted by maxogden on Jan 15, 2021.

agentmorris commented 1 year ago

Oh wait maybe that didn't work... I get ELF errors when trying to use it:

$ python run_tf_detector.py md_v4.1.0.pb --image_file ~/Desktop/100MEDIA/DSCF0004.JPG 
Fontconfig error: Cannot load default config file
Traceback (most recent call last):
  File "/home/max/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/max/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/max/.local/lib/python3.8/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 "/opt/anaconda/lib/python3.8/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/opt/anaconda/lib/python3.8/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /home/max/.local/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: invalid ELF header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run_tf_detector.py", line 70, in <module>
    import tensorflow as tf
  File "/home/max/.local/lib/python3.8/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/home/max/.local/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/max/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/max/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/max/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/max/.local/lib/python3.8/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 "/opt/anaconda/lib/python3.8/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/opt/anaconda/lib/python3.8/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /home/max/.local/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: invalid ELF header

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.

(Comment originally posted by maxogden)

agentmorris commented 1 year ago

Oh that is because the link above is for the mac version. When I installed Anaconda I got python 3.8 but apparently there is no supported release of tensorflow 1.13.1 for python 3.8, so I did:

conda create -n py37 python=3.7 pip tensorflow
conda activate py37

and now pip install tensorflow==1.13.1 works


(Comment originally posted by maxogden)

agentmorris commented 1 year ago

for windows should we use same command i am using vs code


(Comment originally posted by Zarrarabid)

agentmorris commented 1 year ago

@zarrarrabid, the same commands should work on Windows, but... when this issue was opened in 2021, MegaDetector required TensorFlow. Since the release of MegaDetector v5 in 2022, you only need TensorFlow for running old versions of MegaDetector, so my first question would be... are you sure you want to install TensorFlow at all?