ColossalAI
ColossalAI copied to clipboard
[BUG]: ImportError: cannot import name 'ColoInitContext' from 'colossalai.zero'
🐛 Describe the bug
When I run examples/single_node/train_sft.sh, I meet this bug I have tried various methods, but this bug still exists.
colossalai: 0.2.8
Environment
No response
yes, I had the same problem.
@LarryZhangy Have you resolved this problem?
I have the same problem.
@LarryZhangy Have you resolved this problem?
yes, use v0.2.8 and example code from this version.
@LarryZhangy Have you resolved this problem?
yes, use v0.2.8 and example code from this version.
Sorry, I didn't understand what you meant. I mean, how can you solve this problem? Can you help me
@sharejing ,我之前弄错了colosaala的版本,官方的tag: 0.2.7的容器镜像里面的colosaalai的版本是0.2.0的,但我试用的代码例子是v0.2.7里面的。更新下容器里面的软件版本就行。因为最新的代码,ColoInitContext在这个位置: from colossalai.utils.model.colo_init_context import ColoInitContext
I met the same bug when running train_sft.sh in the applications-Chat-examples path. It seems that import colossalai.zero.gemini
will lead to an importerror.
@sharejing ,我之前弄错了colosaala的版本,官方的tag: 0.2.7的容器镜像里面的colosaalai的版本是0.2.0的,但我试用的代码例子是v0.2.7里面的。更新下容器里面的软件版本就行。因为最新的代码,ColoInitContext在这个位置: from colossalai.utils.model.colo_init_context import ColoInitContext
@LarryZhangy hi, I didn't find ColoInitContext in colossalai.utils.model.colo_init_context from the main branch. wondering how you solved this problem?
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
I understand what you mean, thank you, thank you~~ I will try v0.2.7
@sharejing ,我之前弄错了colosaala的版本,官方的tag: 0.2.7的容器镜像里面的colosaalai的版本是0.2.0的,但我试用的代码例子是v0.2.7里面的。更新下容器里面的软件版本就行。因为最新的代码,ColoInitContext在这个位置: from colossalai.utils.model.colo_init_context import ColoInitContext
@LarryZhangy hi, I didn't find ColoInitContext in colossalai.utils.model.colo_init_context from the main branch. wondering how you solved this problem?
@LarryZhangy 非常感谢,不过我目前是想做train_sft.sh,我看了一下v0.2.7的examples里没有这个,v0.2.8和v0.2.7的代码改动差别非常大,自己去修改难度有点大。
@JinghongZeng 确实在主分支(v0.2.8)上是没有这个的,ColoinitContext的路径在:colossalai/zero/gemini/colo_init_context.py
v0.2.7和v0.2.8的差别很大,不知道为什么会报import error
@sharejing ,我之前弄错了colosaala的版本,官方的tag: 0.2.7的容器镜像里面的colosaalai的版本是0.2.0的,但我试用的代码例子是v0.2.7里面的。更新下容器里面的软件版本就行。因为最新的代码,ColoInitContext在这个位置: from colossalai.utils.model.colo_init_context import ColoInitContext
@LarryZhangy hi, I didn't find ColoInitContext in colossalai.utils.model.colo_init_context from the main branch. wondering how you solved this problem?
@LarryZhangy 非常感谢,不过我目前是想做train_sft.sh,我看了一下v0.2.7的examples里没有这个,v0.2.8和v0.2.7的代码改动差别非常大,自己去修改难度有点大。
@JinghongZeng 确实在主分支(v0.2.8)上是没有这个的,ColoinitContext的路径在:colossalai/zero/gemini/colo_init_context.py
v0.2.7和v0.2.8的差别很大,不知道为什么会报import error
@sharejing thanks for your info. hoping this issue can be resolved soon.
@sharejing I figured out this importerror on my device. This is due to difference between colossaial packages in the python directory and those git from source. My steps to solve this issue are as follows:
- I install colossalai using
pip install colossalai
, so first uninstall it usingpip uninstall colossalai
. - Then install colossalai from source using
git clone https://github.com/hpcaitech/ColossalAI.git cd ColossalAI pip install .
- Go to the python directory where python packages are installed. For example, the path on my linux device is
/home/user/.local/lib/python3.10/site-packages/colossalai/
. - Check if the zero folder is in this path and check if the gemini folder is in this path.
- The _analyzer folder is not in the package, so I download this folder from github and copy it to the package directory directly, otherwise modulenotfound error may pop out.
- Don't copy colossalai from source directly to the python directory, as the op_builder folder will be missing.
I think the colossalai pakcage is still in development, so there are many differences between versions. Maybe this is still a bug.
Hoping this would be helpful to you.
Hi guys, we have updated a lot. Please check the latest code and install from source.
There are significant differences between the main branch and the released versions (such as 0.2.7 and 0.2.8) of colossalai. I noticed that there was an update for the zero-related files in April. I found that it's easy to select the main branch or the tag for version 0.2.7 at this link https://github.com/hpcaitech/ColossalAI/tree/main/colossalai, and then search for the desired class or file in that version.