talmolab / sleap

A deep learning framework for multi-animal pose tracking.
https://sleap.ai
Other
435 stars 97 forks source link

`tensorflow==2.13` version incompatible in `sleap[pypi]==1.3.2` #1495

Closed roomrys closed 1 year ago

roomrys commented 1 year ago

Discussed in https://github.com/talmolab/sleap/discussions/1483

Originally posted by **Jaspermoray** September 11, 2023 Hi! I'm using colab to do all of sleap's functions, and recently everything broke, I assume because of recent updates. At the moment, I'm getting a tensorflow issue: ```python 2023-09-11 15:16:22.581609: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT Traceback (most recent call last): File "/usr/local/bin/sleap-train", line 5, in from sleap.nn.training import main File "/usr/local/lib/python3.10/dist-packages/sleap/__init__.py", line 14, in import sleap.nn File "/usr/local/lib/python3.10/dist-packages/sleap/nn/__init__.py", line 1, in import sleap.nn.architectures File "/usr/local/lib/python3.10/dist-packages/sleap/nn/architectures/__init__.py", line 7, in from sleap.nn.architectures import pretrained_encoders File "/usr/local/lib/python3.10/dist-packages/sleap/nn/architectures/pretrained_encoders.py", line 47, in from sleap.nn.data.normalization import ensure_rgb File "/usr/local/lib/python3.10/dist-packages/sleap/nn/data/__init__.py", line 2, in from sleap.nn.data import confidence_maps File "/usr/local/lib/python3.10/dist-packages/sleap/nn/data/confidence_maps.py", line 6, in from sleap.nn.data.utils import make_grid_vectors File "/usr/local/lib/python3.10/dist-packages/sleap/nn/data/utils.py", line 4, in from keras.utils import tf_utils ImportError: cannot import name 'tf_utils' from 'keras.utils' (/usr/local/lib/python3.10/dist-packages/keras/utils/__init__.py) INFO:numexpr.utils:NumExpr defaulting to 2 threads. 2023-09-11 15:16:27.665644: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2023-09-11 15:16:29.125970: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT Traceback (most recent call last): File "/usr/local/bin/sleap-train", line 5, in from sleap.nn.training import main File "/usr/local/lib/python3.10/dist-packages/sleap/__init__.py", line 14, in import sleap.nn File "/usr/local/lib/python3.10/dist-packages/sleap/nn/__init__.py", line 1, in import sleap.nn.architectures File "/usr/local/lib/python3.10/dist-packages/sleap/nn/architectures/__init__.py", line 7, in from sleap.nn.architectures import pretrained_encoders File "/usr/local/lib/python3.10/dist-packages/sleap/nn/architectures/pretrained_encoders.py", line 47, in from sleap.nn.data.normalization import ensure_rgb File "/usr/local/lib/python3.10/dist-packages/sleap/nn/data/__init__.py", line 2, in from sleap.nn.data import confidence_maps File "/usr/local/lib/python3.10/dist-packages/sleap/nn/data/confidence_maps.py", line 6, in from sleap.nn.data.utils import make_grid_vectors File "/usr/local/lib/python3.10/dist-packages/sleap/nn/data/utils.py", line 4, in from keras.utils import tf_utils ImportError: cannot import name 'tf_utils' from 'keras.utils' (/usr/local/lib/python3.10/dist-packages/keras/utils/__init__.py) ``` A cursory google told me that its probably a incompatibility with tensorflow and keras, but I don't want to download and use versions that may not be compatible with sleap's other code. So can anybody help?

I'm looking into the issue. To keep from halting, change the pip install sleap[pypi] command to the previous release for the time being pip install sleap==1.3.1. I've also updated all the notebooks online to reflect this in e4fca4f.


Some changes between 1.3.2 and 1.3.1: pip install sleap[pypi] pip install sleap==1.3.1
keras==2.8.0 keras==2.8.0
Keras-Applications==1.0.8 Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2 Keras-Preprocessing==1.1.2
tensorboard==2.13.0 tensorboard==2.8.0
tensorboard-data-server==0.7.1 tensorboard-data-server==0.6.1
--- tensorboard-plugin-wit==1.8.1
tensorflow==2.13.0 tensorflow==2.8.4
tensorflow-datasets==4.9.2 tensorflow-datasets==4.9.2
tensorflow-estimator==2.13.0 tensorflow-estimator==2.8.0
tensorflow-gcs-config==2.13.0 tensorflow-gcs-config==2.13.0
tensorflow-hub==0.14.0 tensorflow-hub==0.14.0
tensorflow-io-gcs-filesystem==0.33.0 tensorflow-io-gcs-filesystem==0.33.0
tensorflow-metadata==1.14.0 tensorflow-metadata==1.14.0
tensorflow-probability==0.20.1 tensorflow-probability==0.20.1
tensorstore==0.1.41 tensorstore==0.1.41

Doing a !pip install tensorflow==2.8.4 after the SLEAP installation fixes the problem... Wondering how the wheel test missed this as we definitely run a training test. Looking at the logs, the wheel test prefers tensorflow==2.11 whereas colab seems to come pre-installed with the latest tensorflow==2.13. We are adding some restrictions in #1485.

roomrys commented 1 year ago

Hi @Jaspermoray,

We released a new version last week which aimed to address your issue. Things should be back in order now!

Thanks, Liezl