LucasAlegre / morl-baselines

Multi-Objective Reinforcement Learning algorithms implementations.
https://lucasalegre.github.io/morl-baselines
MIT License
294 stars 47 forks source link

AttributeError: module 'cdd' has no attribute 'Matrix' #93

Closed PatrickYanZ closed 8 months ago

PatrickYanZ commented 8 months ago

Hi team, I am working on testing highway-env under pythongpi_pd_highway.py gpi-ls false 1

It encounter the error as here around 10000 steps. Do you have any idea to overide this error below ?

Traceback (most recent call last):
  File "gpi_pd_highway_bs.py", line 69, in <module>
    fire.Fire(main)
  File "/Users/zi6106738/.pyenv/versions/3.8.16/lib/python3.8/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/Users/zi6106738/.pyenv/versions/3.8.16/lib/python3.8/site-packages/fire/core.py", line 475, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/Users/zi6106738/.pyenv/versions/3.8.16/lib/python3.8/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "gpi_pd_highway_bs.py", line 58, in main
    agent.train(
  File "/Users/zi6106738/.pyenv/versions/3.8.16/lib/python3.8/site-packages/morl_baselines/multi_policy/gpi_pd/gpi_pd.py", line 844, in train
    w = linear_support.next_weight(
  File "/Users/zi6106738/.pyenv/versions/3.8.16/lib/python3.8/site-packages/morl_baselines/multi_policy/linear_support/linear_support.py", line 72, in next_weight
    W_corner = self.compute_corner_weights()
  File "/Users/zi6106738/.pyenv/versions/3.8.16/lib/python3.8/site-packages/morl_baselines/multi_policy/linear_support/linear_support.py", line 345, in compute_corner_weights
    vertices = compute_poly_vertices(A, b)
  File "/Users/zi6106738/.pyenv/versions/3.8.16/lib/python3.8/site-packages/morl_baselines/multi_policy/linear_support/linear_support.py", line 332, in compute_poly_vertices
    mat = cdd.Matrix(np.hstack([b, -A]), number_type="float")
AttributeError: module 'cdd' has no attribute 'Matrix'

I manually reinstall cdd as

zi6106738@***** morl-baselines % pip show cdd          
Name: cdd
Version: 0.1.12
Summary: improved file system navigation with cd
Home-page: https://github.com/daltonserey/cdd
Author: Dalton Serey
Author-email: daltonserey@gmail.com
License: GNU Affero General Public License v3
Location: /Users/zi6106738/.pyenv/versions/3.8.16/lib/python3.8/site-packages
Requires: 
Required-by: 

But still have the error as here.

Thanks

LucasAlegre commented 8 months ago

Hi @PatrickYanZ ,

As stated in https://github.com/LucasAlegre/morl-baselines/blob/main/pyproject.toml#L44C8-L44C18 , the library name is actually pycddlib, so you should install it with:

pip install pycddlib

PatrickYanZ commented 8 months ago

Hi @LucasAlegre , thanks your prompt response. pip install pycddlib partially works. but I change my env variable.

I fixed in this way

export CPATH=/opt/homebrew/include:$CPATH in my bash profile then install as CFLAGS="-I/opt/homebrew/include" pip install pycddlib

So far the training is good,Thanks!

ffelten commented 8 months ago

Indeed, there is a problem with the install of pycddlib on macos. I remembered there was a trick but I didn't remember exactly what. Happy it's solved :)

RuohLiuq commented 2 months ago

I tried pip install pycddlib and pip install cdd, but it still reported AttributeError: module 'cdd' has no attribute 'Matrix'. Then I tried pip install cdd==0.1.2, and it worked.

LucasAlegre commented 2 months ago

The "cdd" library installed via "pip install cdd" is never used in our library, and can be uninstalled. You need to install only "pip install pycddlib"

KaixuanDai commented 1 week ago

The python interpreter imports the python_cddmodule incorrectly and needs to remove it by: pip uninstall python-cdd Then, install the pycddlib and libgmp according to: https://pycddlib.readthedocs.io/en/latest/quickstart.html https://gmpy2.readthedocs.io/en/latest/