Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'functools' has no attribute 'cached_property' #43

Closed
olaviinha opened this issue May 6, 2022 · 4 comments
Closed

module 'functools' has no attribute 'cached_property' #43

olaviinha opened this issue May 6, 2022 · 4 comments

Comments

@olaviinha
Copy link

Second cell in Colab Notebook results in the following error.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-2-152851d66c54>](https://localhost:8080/#) in <module>()
     14 import seqio
     15 import t5
---> 16 import t5x
     17 
     18 from mt3 import metrics_utils

4 frames
[/content/t5x/__init__.py](https://localhost:8080/#) in <module>()
     15 """Import API modules."""
     16 
---> 17 import t5x.adafactor
     18 import t5x.checkpoints
     19 import t5x.decoding

[/content/t5x/adafactor.py](https://localhost:8080/#) in <module>()
     61 import jax.numpy as jnp
     62 import numpy as np
---> 63 from t5x import utils
     64 from t5x.optimizers import OptimizerDef
     65 from t5x.optimizers import OptimizerState

[/content/t5x/utils.py](https://localhost:8080/#) in <module>()
     41 import numpy as np
     42 import seqio
---> 43 from t5x import checkpoints
     44 from t5x import optimizers
     45 from t5x import partitioning

[/content/t5x/checkpoints.py](https://localhost:8080/#) in <module>()
     50 from t5x import checkpoint_utils
     51 from t5x import optimizers
---> 52 from t5x import partitioning
     53 from t5x import state_utils
     54 from t5x import train_state as train_state_lib

[/content/t5x/partitioning.py](https://localhost:8080/#) in <module>()
     45   cached_property = property  # pylint: disable=invalid-name
     46 else:
---> 47   cached_property = functools.cached_property  # pylint: disable=invalid-name
     48 
     49 

AttributeError: module 'functools' has no attribute 'cached_property'
@trevorwelch
Copy link

My guess is that the t5x library needs to make an update for backwards compatibility like so: GEM-benchmark/GEM-metrics#69

This seems to be related to python 3.7 vs. 3.8, Colab is currently running 3.7

@trevorwelch
Copy link

Workaround:

  1. Download a copy of the Colab notebook locally
  2. Find the kernelspec around line 538, replace it like so:
    "kernelspec": {
      "name": "py38",
      "display_name": "Python 3.8"
    }
  1. Upload/import the modified notebook
  2. Add the following to the top of the notebook and run it:
!wget -O mini.sh https://repo.anaconda.com/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh
!chmod +x mini.sh
!bash ./mini.sh -b -f -p /usr/local
!conda install -q -y jupyter
!conda install -q -y google-colab -c conda-forge
!python -m ipykernel install --name "py38" --user
  1. sys.version should now show '3.8.1 (default, Jan 8 2020, 22:29:32) \n[GCC 7.3.0]'

  2. Under Runtime select Change runtime type and select Python3.8

The session fails to recognize GPU/TPU but everything else runs, transcription works

@olaviinha
Copy link
Author

olaviinha commented May 6, 2022

Awesome, thanks!

Another workaround appears to be adding the following line to the beginning of filet5x/partitioning.py:

# pylint: disable-next=unused-import

(...live in Colab after t5x installation.)

@olaviinha
Copy link
Author

This problem seems to have magically disappeared without further need to perform either of the workarounds above. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants