microsoft / microxcaling

PyTorch emulation library for Microscaling (MX)-compatible data formats
MIT License
165 stars 21 forks source link

examples ffn_mx.py - Module not found error - no module named mx (needs path.append('..')) #9

Closed lessw2020 closed 3 months ago

lessw2020 commented 1 year ago

Running the new example ffn_mx.py I get:

(pytorch) ubuntu@ip-172-31-66-198:~/microxcaling/examples$ bash run_mx6.sh 
Traceback (most recent call last):
  File "/home/ubuntu/microxcaling/examples/ffn_mx.py", line 6, in <module>
    from mx import Linear, LayerNorm
ModuleNotFoundError: No module named 'mx'

fix was to just add a path reference to mx:


import sys
sys.path.append('..')

However, not sure that there isn't a better way (i.e. setup.py from main dir) to resolve this.

Note that the example only works on single gpu...hangs on multi-gpu. Will open sep issue for that to differentiate.

mgolub2-ms commented 1 year ago

Hi!

One way that is a bit cleaner than appending to the sys.path is using PYTHONPATH, for example:

PYTHONPATH=~/microxcaling/mx bash run_mx6.sh

We'll also look into setting up a python package as well soon.

zks878 commented 11 months ago

I have tried two methods, but I still can't solve the problem.

The first:

>>> import sys
>>> sys.path.append("/home1/zks878/mx/microxcaling/mx/")
>>> print(sys.path)
['', '/home1/zks878/.conda/envs/zks878/lib/python39.zip', '/home1/zks878/.conda/envs/zks878/lib/python3.9', '/home1/zks878/.conda/envs/zks878/lib/python3.9/lib-dynload', '/home1/zks878/.conda/envs/zks878/lib/python3.9/site-packages', '/home1/zks878/mx/microxcaling/mx/']
>>>
(zks878) zks878@imdl5:~/mx/microxcaling/examples$ bash run_mxfp6.sh
Traceback (most recent call last):
  File "/home1/zks878/mx/microxcaling/examples/ffn_mx_manual.py", line 6, in <module>
    from mx import Linear, LayerNorm
ModuleNotFoundError: No module named 'mx'

The second:

(zks878) zks878@imdl5:~/mx/microxcaling/examples$ PYTHONPATH=~/home1/zks878/mx/microxcaling/mx
(zks878) zks878@imdl5:~/mx/microxcaling/examples$ bash run_mxfp6.sh
Traceback (most recent call last):
  File "/home1/zks878/mx/microxcaling/examples/ffn_mx_manual.py", line 6, in <module>
    from mx import Linear, LayerNorm
ModuleNotFoundError: No module named 'mx'

What should I do?

rensushan commented 5 months ago

You'd better install microscaling module by runing "python install ." under microscaling directory. Then you can use MX module in your own python code.