Open KevinCL16 opened 5 months ago
I met the same error. I build the container based on nvcr.io/nvidia/pytorch:24.04-py3 docker image and install xformers from source code to maintain torch version. (Otherwise, it made a torch version conflict for me.) After build from source with "pip install -e ." command, I tried
python3 -m vllm.entrypoints.api_server ....
Then, below error happens.
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/workspace/vllm/vllm/entrypoints/openai/api_server.py", line 25, in <module>
from vllm.entrypoints.openai.serving_chat import OpenAIServingChat
File "/workspace/vllm/vllm/entrypoints/openai/serving_chat.py", line 19, in <module>
from vllm.model_executor.guided_decoding import (
File "/workspace/vllm/vllm/model_executor/guided_decoding/__init__.py", line 5, in <module>
from vllm.model_executor.guided_decoding.lm_format_enforcer_decoding import (
File "/workspace/vllm/vllm/model_executor/guided_decoding/lm_format_enforcer_decoding.py", line 8, in <module>
from lmformatenforcer.integrations.vllm import (
File "/usr/local/lib/python3.10/dist-packages/lmformatenforcer/integrations/vllm.py", line 34, in <module>
def build_vllm_token_enforcer_tokenizer_data(tokenizer: Union[vllm.LLM, PreTrainedTokenizerBase]) -> TokenEnforcerTokenizerData:
AttributeError: module 'vllm' has no attribute 'LLM'
I changed the root directory name. And it solved the problem.
I have encountered the same problem as you @KevinCL16 . It might be because you have placed the Python file for running the model (assuming it's called run.py
) and the vllm repository folder in the same directory. Even if you have run pip install -e .
to install the vllm package into site-packages, run.py
will still try to import modules from the current directory's vllm/
first (whereas the modules are actually in vllm/vllm/
), causing the import to fail. Try moving run.py
to a different location and then try from vllm import LLM, SamplingParams
, perhaps you can solve this problem.
I met the same error. I build the container based on nvcr.io/nvidia/pytorch:24.04-py3 docker image and install xformers from source code to maintain torch version. (Otherwise, it made a torch version conflict for me.) After build from source with "pip install -e ." command, I tried
python3 -m vllm.entrypoints.api_server ....
Then, below error happens.
Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/workspace/vllm/vllm/entrypoints/openai/api_server.py", line 25, in <module> from vllm.entrypoints.openai.serving_chat import OpenAIServingChat File "/workspace/vllm/vllm/entrypoints/openai/serving_chat.py", line 19, in <module> from vllm.model_executor.guided_decoding import ( File "/workspace/vllm/vllm/model_executor/guided_decoding/__init__.py", line 5, in <module> from vllm.model_executor.guided_decoding.lm_format_enforcer_decoding import ( File "/workspace/vllm/vllm/model_executor/guided_decoding/lm_format_enforcer_decoding.py", line 8, in <module> from lmformatenforcer.integrations.vllm import ( File "/usr/local/lib/python3.10/dist-packages/lmformatenforcer/integrations/vllm.py", line 34, in <module> def build_vllm_token_enforcer_tokenizer_data(tokenizer: Union[vllm.LLM, PreTrainedTokenizerBase]) -> TokenEnforcerTokenizerData: AttributeError: module 'vllm' has no attribute 'LLM'
I encounted the same problem.
Please make sure the vllm
folder is not at the directory you run the command.
This way worked for me.
Your current environment
How would you like to use vllm
594 Like in the previous issue, I tried to install from the repo using pip install -e . and had trouble importing LLM.
I got around this issue by using:
However, I ran into another error:
I wonder if using pip install -e . is bugged?