sonnet icon indicating copy to clipboard operation
sonnet copied to clipboard

Issues using Sonnet

Open MoxyFoxy opened this issue 2 years ago • 3 comments

Hello,

I'm having an issue attempting to run a project dependent on Sonnet (more specifically, the DeepMind DNC implementation). I'm getting the error:

Traceback (most recent call last):
  File "PATH\src\dnc_model.py", line 7, in <module>
    from dnc import dnc
  File "PATH\libs\dnc\dnc\dnc.py", line 27, in <module>
    import sonnet as snt
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sonnet\__init__.py", line 2, in <module>
    from graphs import Sonnet, D3Graph, MatplotGraph
ModuleNotFoundError: No module named 'graphs'

Thinking that maybe I'm missing a package, I did the next obvious thing and ran pip install graphs (which I felt is not the solution, that graphs must be an internal package of sorts, but I still gave it a shot) and got the error ImportError: cannot import name 'Sonnet' from 'graphs'

I thought that maybe the version on pip is outdated, and it seems like it is. I then attempted to download the source code and run pip install -e on the extracted folder. However, after that, I get:

Traceback (most recent call last):
  File "PATH\src\dnc_model.py", line 7, in <module>
    from dnc import dnc
  File "PATH\libs\dnc\dnc\dnc.py", line 30, in <module>
    from dnc import access
  File "PATH\libs\dnc\dnc\access.py", line 25, in <module>
    from dnc import addressing
  File "PATH\libs\dnc\dnc\addressing.py", line 58, in <module>
    class CosineWeights(snt.AbstractModule):
AttributeError: module 'sonnet' has no attribute 'AbstractModule'

Does anyone have any idea what I could do to solve these issues? Is there a way I could modify the DNC code to work with modern Sonnet? Is there an alternative to AbstractModule in this use case?

MoxyFoxy avatar Jan 16 '23 22:01 MoxyFoxy

This is the specific spot the error is occurring at: https://github.com/deepmind/dnc/blob/master/dnc/addressing.py#L58

Downloading an older version of Sonnet (if it will still work, that is) would also work, if that's a possibility, though I can't find a way to install an older version.

Also, I realized that it's dm-sonnet and not sonnet for pip install, so I have switched over to that instead of the source version. However, finding the pypi now gives me access to older versions, so I'm going to try playing around with them and see what I can do.

MoxyFoxy avatar Jan 16 '23 23:01 MoxyFoxy

I unfortunately cannot downgrade Sonnet, so that is not an option. There is an issue with tensorflow-probability 0.8.0 (required by Sonnet 1.36) requiring cloudpickle==1.1.1, while Gymnasium, which I am using to simulate and train with, requires cloudpickle>=1.2.0.

MoxyFoxy avatar Jan 16 '23 23:01 MoxyFoxy

Hi @Denzeduous , indeed the first error is from using the wrong Sonnet package 😄

With regards to not being able to downgrade, I'm afraid that DNC requires TF1 and Sonnet <2.

I wonder what wold happen if you installed the old version of cloudpickle to satisfy TFP during install, and then force upgraded it to 1.2.0.

tomhennigan avatar Jan 18 '23 22:01 tomhennigan