mlcommons / chakra

Repository for MLCommons Chakra schema and tools
https://mlcommons.org/working-groups/research/chakra/
Apache License 2.0
67 stars 38 forks source link

Import error when running Chakra #155

Closed HeRaNO closed 2 weeks ago

HeRaNO commented 2 months ago

Describe the Bug

Following the guide and run chakra_converter, it failed saying ImportError.

According to astra-sim/astra-sim#214, I upgrade protobuf to 5.28.2, and it runs well. But it warns:

/home/syzoj/chakra_env/lib/python3.10/site-packages/google/protobuf/runtime_version.py:112: UserWarning: Protobuf gencode version 5.27.2 is older than the runtime version 5.28.2 at et_def.proto. Please avoid checked-in Protobuf gencode that can be obsolete.

Steps to Reproduce

Logs

ubuntu@ubuntu-virtual-machine:~$ python3 -m venv chakra_env
ubuntu@ubuntu-virtual-machine:~$ source chakra_env/bin/activate
(chakra_env) ubuntu@ubuntu-virtual-machine:~$ pip install https://github.com/mlcommons/chakra/archive/refs/heads/main.zip
Collecting https://github.com/mlcommons/chakra/archive/refs/heads/main.zip
  Downloading https://github.com/mlcommons/chakra/archive/refs/heads/main.zip
     | 590.8 kB 686.6 kB/s 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting networkx
  Downloading networkx-3.3-py3-none-any.whl (1.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 1.3 MB/s eta 0:00:00
Collecting pydot
  Downloading pydot-3.0.1-py3-none-any.whl (22 kB)
Collecting protobuf==4.*
  Downloading protobuf-4.25.5-cp37-abi3-manylinux2014_x86_64.whl (294 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 294.6/294.6 KB 3.1 MB/s eta 0:00:00
Collecting graphviz
  Downloading graphviz-0.20.3-py3-none-any.whl (47 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 47.1/47.1 KB 6.3 MB/s eta 0:00:00
Collecting pyparsing>=3.0.9
  Downloading pyparsing-3.1.4-py3-none-any.whl (104 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.1/104.1 KB 5.9 MB/s eta 0:00:00
Building wheels for collected packages: chakra
  Building wheel for chakra (pyproject.toml) ... done
  Created wheel for chakra: filename=chakra-0.0.4-py3-none-any.whl size=55748 sha256=b2d6cac922c8245fee78b9ad92bcf4876fa2b51f75c093a6d5a717a3ea027414
  Stored in directory: /tmp/pip-ephem-wheel-cache-al6otvcu/wheels/1b/de/ab/8fa015d740e7d539fac66317a13b78254d356d5e1dfac42d9e
Successfully built chakra
Installing collected packages: pyparsing, protobuf, networkx, graphviz, pydot, chakra
Successfully installed chakra-0.0.4 graphviz-0.20.3 networkx-3.3 protobuf-4.25.5 pydot-3.0.1 pyparsing-3.1.4
(chakra_env) ubuntu@ubuntu-virtual-machine:~$ git clone https://github.com/facebookresearch/param.git
Cloning into 'param'...
remote: Enumerating objects: 5015, done.
remote: Counting objects: 100% (2005/2005), done.
remote: Compressing objects: 100% (366/366), done.
remote: Total 5015 (delta 1763), reused 1774 (delta 1619), pack-reused 3010 (from 1)
Receiving objects: 100% (5015/5015), 5.30 MiB | 2.21 MiB/s, done.
Resolving deltas: 100% (2876/2876), done.
(chakra_env) ubuntu@ubuntu-virtual-machine:~$ cd param/et_replay/
(chakra_env) ubuntu@ubuntu-virtual-machine:~/param/et_replay$ git checkout 7b19f586dd8b267333114992833a0d7e0d601630
Note: switching to '7b19f586dd8b267333114992833a0d7e0d601630'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 7b19f58 Datatype precision for compute kernel
(chakra_env) ubuntu@ubuntu-virtual-machine:~/param/et_replay$ pip install .
Processing /home/ubuntu/param/et_replay
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: et_replay
  Building wheel for et_replay (pyproject.toml) ... done
  Created wheel for et_replay: filename=et_replay-0.5.0-py3-none-any.whl size=305374 sha256=f39d7daf5efd4033de21ee84aeea09f6321e19fbcabf602834d956954810f6b7
  Stored in directory: /tmp/pip-ephem-wheel-cache-3m8b73fr/wheels/25/7a/e8/2e27c71b46cc6d83a5ebabe625737b708d485ae6c131b2be0e
Successfully built et_replay
Installing collected packages: et_replay
Successfully installed et_replay-0.5.0
(chakra_env) ubuntu@ubuntu-virtual-machine:~/param/et_replay$ cd ~/chakra_env/
(chakra_env) ubuntu@ubuntu-virtual-machine:~/chakra_env$ cd ..
(chakra_env) ubuntu@ubuntu-virtual-machine:~$ chakra_converter --help
Traceback (most recent call last):
  File "/home/ubuntu/chakra_env/bin/chakra_converter", line 5, in <module>
    from chakra.src.converter.converter import main
  File "/home/ubuntu/chakra_env/lib/python3.10/site-packages/chakra/src/converter/converter.py", line 4, in <module>
    from .pytorch_converter import PyTorchConverter
  File "/home/ubuntu/chakra_env/lib/python3.10/site-packages/chakra/src/converter/pytorch_converter.py", line 5, in <module>
    from ...schema.protobuf.et_def_pb2 import (
  File "/home/ubuntu/chakra_env/lib/python3.10/site-packages/chakra/schema/protobuf/et_def_pb2.py", line 9, in <module>
    from google.protobuf import runtime_version as _runtime_version
ImportError: cannot import name 'runtime_version' from 'google.protobuf' (/home/ubuntu/chakra_env/lib/python3.10/site-packages/google/protobuf/__init__.py)
(chakra_env) ubuntu@ubuntu-virtual-machine:~$ 
HeRaNO commented 1 month ago

Dup issue: #151