kuprel / min-dalle

min(DALL·E) is a fast, minimal port of DALL·E Mini to PyTorch
MIT License
3.48k stars 256 forks source link

Incompatible with Python 3.10 #31

Closed matthewfranglen closed 2 years ago

matthewfranglen commented 2 years ago

If I install the dependencies in a python 3.10 venv then I get the following error from flax when running image_from_text.py with no options:

  File "/home/matthew/Programming/Python/min-dalle/min_dalle/load_params.py", line 5, in <module>
    from flax import traverse_util, serialization
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/flax/__init__.py", line 18, in <module>
    from . import core as core
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/flax/core/__init__.py", line 15, in <module>
    from .axes_scan import broadcast as broadcast
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/flax/core/axes_scan.py", line 19, in <module>
    import jax
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/jax/__init__.py", line 35, in <module>
    from jax import config as _config_module
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/jax/config.py", line 17, in <module>
    from jax._src.config import config
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/jax/_src/config.py", line 29, in <module>
    from jax._src import lib
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/jax/_src/lib/__init__.py", line 41, in <module>
    import scipy.signal as _signal
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/scipy/signal/__init__.py", line 302, in <module>
    from .filter_design import *
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/scipy/signal/filter_design.py", line 16, in <module>
    from scipy import special, optimize, fft as sp_fft
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/scipy/optimize/__init__.py", line 421, in <module>
    from ._shgo import shgo
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/scipy/optimize/_shgo.py", line 9, in <module>
    from scipy import spatial
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/scipy/spatial/__init__.py", line 107, in <module>
    from . import distance, transform
  File "/home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/scipy/spatial/transform/__init__.py", line 19, in <module>
    from .rotation import Rotation, Slerp
ImportError: /home/matthew/.cache/pypoetry/virtualenvs/min-dalle-13Fe8Z6x-py3.10/lib/python3.10/site-packages/scipy/spatial/transform/rotation.cpython-310-x86_64-linux-gnu.so: undefined symbol: _PyGen_Send

If I downgrade the python version to 3.9 then it works.

gitpushdashf commented 2 years ago

I'm getting this on 3.10:

$ python image_from_text.py --text='a comfy chair that looks like an avocado' --torch --mega --seed=10
...
  File "/Users/me/repos/min-dalle/min_dalle/load_params.py", line 45, in load_dalle_bart_flax_params
    params = serialization.msgpack_restore(f.read())
  File "/Users/me/repos/min-dalle/.venv/lib/python3.10/site-packages/flax/serialization.py", line 350, in msgpack_restore
    state_dict = msgpack.unpackb(
  File "msgpack/_unpacker.pyx", line 205, in msgpack._cmsgpack.unpackb
ValueError: Unpack failed: incomplete input

Edit: Getting the same error on Python 3.9.

matthewfranglen commented 2 years ago

@gitpushdashf I've had that. I think it means your download is incomplete. You should check the size of the files in pretrained/dalle_bart_... (specifically the flax_model.msgpack) rerun setup.sh if they are incomplete.

➜ ls -lh pretrained/dalle_bart*/flax_model.msgpack
-rw-rw-r-- 1 matthew matthew 4.9G Jun 29 10:39 pretrained/dalle_bart_mega/flax_model.msgpack
-rw-rw-r-- 1 matthew matthew 1.7G Jun 18 14:49 pretrained/dalle_bart_mini/flax_model.msgpack

You can check the wandb page for the artifacts too: https://wandb.ai/dalle-mini/dalle-mini/artifacts/DalleBart_model/mega-1-fp16/v14/files

gitpushdashf commented 2 years ago

@gitpushdashf I've had that. I think it means your download is incomplete. You should check the size of the files in pretrained/dalle_bart_... (specifically the flax_model.msgpack) rerun setup.sh if they are incomplete.

➜ ls -lh pretrained/dalle_bart*/flax_model.msgpack
-rw-rw-r-- 1 matthew matthew 4.9G Jun 29 10:39 pretrained/dalle_bart_mega/flax_model.msgpack
-rw-rw-r-- 1 matthew matthew 1.7G Jun 18 14:49 pretrained/dalle_bart_mini/flax_model.msgpack

You can check the wandb page for the artifacts too: https://wandb.ai/dalle-mini/dalle-mini/artifacts/DalleBart_model/mega-1-fp16/v14/files

That worked. Thank you!

kuprel commented 2 years ago

Closing since since flax model was moved. Converted torch params can be downloaded directly now