Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: AttributeError: module 'pynvml' has no attribute '__version__' #113

Open
Inferno2211 opened this issue Jan 14, 2025 · 0 comments
Open

Comments

@Inferno2211
Copy link

When I try running the app_launch.bat, I get the following error:

Traceback (most recent call last):
File "E:\rtx\ChatWithRTX\RAG\trt-llm-rag-windows-main\app.py", line 28, in
from trt_llama_api import TrtLlmAPI
File "E:\rtx\ChatWithRTX\RAG\trt-llm-rag-windows-main\trt_llama_api.py", line 42, in
from utils import (DEFAULT_HF_MODEL_DIRS, DEFAULT_PROMPT_TEMPLATES,
File "E:\rtx\ChatWithRTX\RAG\trt-llm-rag-windows-main\utils.py", line 22, in
import tensorrt_llm
File "E:\rtx\ChatWithRTX\env_nvd_rag\lib\site-packages\tensorrt_llm_init_.py", line 18, in
import tensorrt_llm.runtime as runtime
File "E:\rtx\ChatWithRTX\env_nvd_rag\lib\site-packages\tensorrt_llm\runtime_init_.py", line 22, in
from .model_runner import ModelRunner
File "E:\rtx\ChatWithRTX\env_nvd_rag\lib\site-packages\tensorrt_llm\runtime\model_runner.py", line 24, in
from .. import profiler
File "E:\rtx\ChatWithRTX\env_nvd_rag\lib\site-packages\tensorrt_llm\profiler.py", line 46, in
elif pynvml.version < '11.5.0':
AttributeError: module 'pynvml' has no attribute 'version'
Press any key to continue . . .

The fix was to:
Edit the file at "[your_installation]\ChatWithRTX\env_nvd_rag\lib\site-packages\tensorrt_llm\profiler.py"

Add "import pkg_resources" at top of file

import torch import tensorrt as trt import pkg_resources

And replace the lines from 46 onwards with:

if pynvml is None:
    logger.warning(
        "A required package 'psutil' is not installed. Will not "
        "monitor the device memory usages. Please install the package "
        "first, e.g, 'pip install pynvml>=11.5.0'.")

try:
    pynvml_version = pkg_resources.get_distribution("pynvml").version
    if pynvml_version < '11.5.0':
        logger.warning(f'Found pynvml=={pynvml_version}. Please use pynvml>=11.5.0 to get accurate memory usage')
        # Legacy support or alternative behavior
        _device_get_memory_info_fn = pynvml.nvmlDeviceGetMemoryInfo
    else:
        _device_get_memory_info_fn = partial(pynvml.nvmlDeviceGetMemoryInfo,
                                             version=pynvml.nvmlMemory_v2)
except pkg_resources.DistributionNotFound:
    logger.warning("pynvml is not installed. Please install it using `pip install pynvml>=11.5.0`.")
    pynvml_version = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant