aimet icon indicating copy to clipboard operation
aimet copied to clipboard

ModuleNotFoundError: No module named 'libpymo'

Open luchangli03 opened this issue 3 years ago • 19 comments

When I tried to use aimet 1.14.0 for tensorflow, I got this error. Do you know how to solve it?

luchangli03 avatar Feb 25 '21 13:02 luchangli03

It was okay to import libpymo yesterday, but I have the same error today. I am using aimet 1.14.0 for tensorflow on colab.

suakim avatar Feb 25 '21 16:02 suakim

I found it's because the envs are not set properly.

luchangli03 avatar Feb 26 '21 01:02 luchangli03

@luchangli03 may I ask how to solve this problem? I have the same problem.

kingbackyang avatar Mar 01 '21 08:03 kingbackyang

you need modify the aimet_common/bin/envsetup.sh to set cuda env and set LD_LIBRARY_PATH and PYTHONPATH properly source /root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/bin/envsetup.sh

export LD_LIBRARY_PATH=/root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu:/root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/:/root/anaconda3/envs/aimet/lib/:$LD_LIBRARY_PATH

export PYTHONPATH=/root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu:$PYTHONPATH

luchangli03 avatar Mar 01 '21 08:03 luchangli03

@luchangli03 Thanh u! Your solution works.

kingbackyang avatar Mar 01 '21 09:03 kingbackyang

I tried with ubuntu 18.04, but it still occurs this error: ModuleNotFoundError: No module named 'libpymo' In the environment variables, it includes the paths as below:

LD_LIBRARY_PATH=/usr/l00ocal/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:/home/skim/pythonenv/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu:/home/skim/pythonenv/lib/python3
.6/site-packages/aimet_common:/home/skim/pythonenv/lib/:

PYTHONPATH=/home/skim/pythonenv/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu

I don't know why it can't load the libpymo module even though the paths are already included in the env. What else could be wrong ?

suakim avatar Mar 01 '21 14:03 suakim

fixed the issue by adding PYTHONPATH in the environment variables in pycharm configuration image

suakim avatar Mar 01 '21 21:03 suakim

Hi @luchangli03 @suakim @kingbackyang - Thank you for reporting this and also suggesting resolutions. We are looking at ways to automatically take care of this dependency resolution. Please track issue https://github.com/quic/aimet/issues/497 for updates.

quic-ssiddego avatar Mar 10 '21 19:03 quic-ssiddego

Hello, I have tried all the solutions suggeted in this issue, but I keep getting that same error.

I have set my variables as follows:

export LD_LIBRARY_PATH=/data/anaconda/envs/resnet50_pytorch2/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu:/data/anaconda/envs/resnet50_pytorch2/lib/python3.6/site-packages/aimet_common/:/data/anaconda/envs/resnet50_pytorch2/lib/:$LD_LIBRARY_PATH

export PYTHONPATH=/data/anaconda/envs/resnet50_pytorch2/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu:$PYTHONPATH

I have also tried, similarly to @suakim to set the variables in Vscode, but I keep getting that error.

I checked, and the PYTHONPATH and LD_LIBRARY_PATH variables were indeed set: image

Does any have any idea what else I can do? Thanks!

lovodkin93 avatar Oct 07 '21 12:10 lovodkin93

@luchangli03 Thanks, it works!

TigerVersusT avatar Nov 24 '21 13:11 TigerVersusT

you need modify the aimet_common/bin/envsetup.sh to set cuda env and set LD_LIBRARY_PATH and PYTHONPATH properly source /root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/bin/envsetup.sh

export LD_LIBRARY_PATH=/root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu:/root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/:/root/anaconda3/envs/aimet/lib/:$LD_LIBRARY_PATH

export PYTHONPATH=/root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu:$PYTHONPATH

Hi have you tired version 1.16 onwards? I tried to make them run, but even after setting the env variables, it still encounter the libpymo issue

PaulZhangIsing avatar Dec 02 '21 09:12 PaulZhangIsing

I have the same issue, I have tried everything here and I still had the same issue ModuleNotFoundError: No module named 'libpymo'

Silk760 avatar Dec 15 '21 02:12 Silk760

I have the same issue, I have tried everything here and I still had the same issue ModuleNotFoundError: No module named 'libpymo'

It is the so package inside the AIMET. Probably you should search for it and record its path later you add it into LD_LIBRARY_PATH loh....

PaulZhangIsing avatar Dec 15 '21 18:12 PaulZhangIsing

I did and this is my path ['', '/content', '/env/python', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages', '/usr/local/lib/python3.7/dist-packages/IPython/extensions', '/root/.ipython', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu/aimet_tensor_quantizer-0.0.0-py3.6-linux-x86_64.egg/', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu/aimet_tensor_quantizer-0.0.0-py3.6-linux-x86_64.egg/']

I mean I tried everything and I always end up with same issue

Silk760 avatar Dec 15 '21 18:12 Silk760

I did and this is my path ['', '/content', '/env/python', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages', '/usr/local/lib/python3.7/dist-packages/IPython/extensions', '/root/.ipython', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu/aimet_tensor_quantizer-0.0.0-py3.6-linux-x86_64.egg/', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu/aimet_tensor_quantizer-0.0.0-py3.6-linux-x86_64.egg/']

I mean I tried everything and I always end up with same issue

But in the first place, where is your AIMET installed?

PaulZhangIsing avatar Dec 15 '21 19:12 PaulZhangIsing

I did and this is my path ['', '/content', '/env/python', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages', '/usr/local/lib/python3.7/dist-packages/IPython/extensions', '/root/.ipython', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu/aimet_tensor_quantizer-0.0.0-py3.6-linux-x86_64.egg/', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu', '/usr/local/lib/python3.7/dist-packages/aimet_common/x86_64-linux-gnu/aimet_tensor_quantizer-0.0.0-py3.6-linux-x86_64.egg/'] I mean I tried everything and I always end up with same issue

But in the first place, where is your AIMET installed?

what do you mean where is installed I follow this for google Colab, is there any terminal instruction you want me to run and the the results, I would love to do this if you will help me to solve this issue thanks https://github.com/quic/aimet/blob/develop/packaging/google_colab/Install_AIMET_GoogleColab_torch_gpu.ipynb

Silk760 avatar Dec 15 '21 19:12 Silk760

Hello, everybody

Before this, I have always had this problem, until today I went to check my environment variables. As the document "https://github.com/quic/aimet/blob/develop/packaging/google_colab/google_colab_install.md" says, these environment variables are necessary and correct, so make sure that the variable path and the actual file path correspond correctly. It is best to add them to .bashrc, which can ensure that in most cases Quote these variables correctly. At present, I have solved this problem in 3.7, so I think this suggestion is worth trying, after all, it won't take too much time.

Good luck, and can solve this problem smoothly !

WindSeeker-jhon avatar Dec 20 '21 03:12 WindSeeker-jhon

you need modify the aimet_common/bin/envsetup.sh to set cuda env and set LD_LIBRARY_PATH and PYTHONPATH properly source /root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/bin/envsetup.sh

export LD_LIBRARY_PATH=/root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu:/root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/:/root/anaconda3/envs/aimet/lib/:$LD_LIBRARY_PATH

export PYTHONPATH=/root/anaconda3/envs/aimet/lib/python3.6/site-packages/aimet_common/x86_64-linux-gnu:$PYTHONPATH

so good,Thank you

fmbao avatar Apr 29 '22 06:04 fmbao

I tried every methods ahead and found no use. But after I found my souce code have a libpymo.so provided by project author and I deleted it , it works!! Because that one conflits with my env and being searched firstly.

my env is ubuntu20, python38, torch, gpu

  1. install aimet-torch
  2. delete unrelevant libpymo.so
  3. add path in code:
import sys
sys.path.append('/home/xxxx/anaconda3/envs/xxxx/lib/python3.8/site-packages/aimet_common')
import libpymo

JaphiaChen avatar Sep 07 '22 12:09 JaphiaChen

Closing this issue due to inactivity. Please re-open it/ create a new issue if you need further help.

quic-mangal avatar Apr 04 '23 15:04 quic-mangal

Resolving ModuleNotFoundError: No module named 'libpymo' in AIMET

As suggested in the docs , you should put your code inside this block in Colab :

%%bash
sh /usr/local/lib/python3.8/site-packages/aimet_common/bin/envsetup.sh
python -c "

<PUT YOUR CODE HERE>

"

Note: If you use local Linux environment, first open a terminal and run the following in that terminal :

source /usr/local/lib/python3.8/site-packages/aimet_common/bin/envsetup.sh

After that, you can run your scripts in the same terminal and hopefully it works!

This solution worked for me in Colab using AIMET 1.28.0. I hope it'll be helpful for you too!

Quick Explanation:

  • Executing envsetup.sh ensures the environment variables (LD_LIBRARY_PATH and PYTHONPATH) are set correctly for finding the libpymo module.

Additional Considerations:

  • Replace /usr/local/lib/python3.8/site-packages/aimet_common/bin/envsetup.sh with the actual path on your system if it differs.
  • Ensure you have a compatible version of AIMET installed (check documentation for specific requirements).
  • By following these steps, you should be able to successfully import and utilize the libpymo module within your AIMET code on Google Colab or your local Linux environment.

image

canyagmur avatar May 03 '24 11:05 canyagmur