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

"meta-reference-gpu" inline-client gives error: RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. #1211

Open
1 of 2 tasks
wukaixingxp opened this issue Feb 21, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@wukaixingxp
Copy link
Contributor

System Info

python -m torch.utils.collect_env
/home/kaiwu/miniconda3/envs/llama/lib/python3.10/runpy.py:126: RuntimeWarning: 'torch.utils.collect_env' found in sys.modules after import of package 'torch.utils', but prior to execution of 'torch.utils.collect_env'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))
Collecting environment information...
PyTorch version: 2.5.1+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

OS: CentOS Stream 9 (x86_64)
GCC version: (GCC) 11.5.0 20240719 (Red Hat 11.5.0-2)
Clang version: Could not collect
CMake version: version 3.30.2
Libc version: glibc-2.34

Python version: 3.10.14 (main, Mar 21 2024, 16:24:04) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.4.3-0_fbk15_zion_2630_gf27365f948db-x86_64-with-glibc2.34
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA H100
GPU 1: NVIDIA H100
GPU 2: NVIDIA H100
GPU 3: NVIDIA H100
GPU 4: NVIDIA H100
GPU 5: NVIDIA H100
GPU 6: NVIDIA H100
GPU 7: NVIDIA H100

Nvidia driver version: 535.154.05
cuDNN version: Probably one of the following:
/usr/lib64/libcudnn.so.8.9.2
/usr/lib64/libcudnn_adv_infer.so.8.9.2
/usr/lib64/libcudnn_adv_train.so.8.9.2
/usr/lib64/libcudnn_cnn_infer.so.8.9.2
/usr/lib64/libcudnn_cnn_train.so.8.9.2
/usr/lib64/libcudnn_ops_infer.so.8.9.2
/usr/lib64/libcudnn_ops_train.so.8.9.2
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      52 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             384
On-line CPU(s) list:                0-383
Vendor ID:                          AuthenticAMD
Model name:                         AMD EPYC 9654 96-Core Processor
CPU family:                         25
Model:                              17
Thread(s) per core:                 2
Core(s) per socket:                 96
Socket(s):                          2
Stepping:                           1
Frequency boost:                    enabled
CPU(s) scaling MHz:                 79%
CPU max MHz:                        3707.8120
CPU min MHz:                        1500.0000
BogoMIPS:                           4792.65
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 invpcid_single hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid overflow_recov succor smca fsrm flush_l1d
Virtualization:                     AMD-V
L1d cache:                          6 MiB (192 instances)
L1i cache:                          6 MiB (192 instances)
L2 cache:                           192 MiB (192 instances)
L3 cache:                           768 MiB (24 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-95,192-287
NUMA node1 CPU(s):                  96-191,288-383
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Vulnerable: eIBRS with unprivileged eBPF
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] onnx==1.16.2
[pip3] onnxruntime==1.19.2
[pip3] torch==2.5.1
[pip3] torchaudio==2.5.1
[pip3] torchvision==0.20.1
[pip3] triton==3.1.0
[conda] blas                      1.0                         mkl  
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] libjpeg-turbo             2.0.0                h9bf148f_0    pytorch
[conda] mkl                       2023.1.0         h213fc3f_46344  
[conda] mkl-service               2.4.0           py310h5eee18b_1  
[conda] mkl_fft                   1.3.11          py310h5eee18b_0  
[conda] mkl_random                1.2.8           py310h1128e8f_0  
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] pytorch                   2.5.1           py3.10_cuda12.4_cudnn9.1.0_0    pytorch
[conda] pytorch-cuda              12.4                 hc786d27_7    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torch                     2.5.1                    pypi_0    pypi
[conda] torchaudio                2.5.1               py310_cu124    pytorch
[conda] torchtriton               3.1.0                     py310    pytorch
[conda] torchvision               0.20.1                   pypi_0    pypi
[conda] triton                    3.1.0                    pypi_0    pypi

pip list | grep llama_
llama_models                             0.1.3
llama_stack                              0.1.3
llama_stack_client                       0.1.3

Information

  • The official example scripts
  • My own modified scripts

🐛 Describe the bug

python test_rag.py using "meta-reference-gpu" inline-client gives error: RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.. This script works if set provider_name = "together", but failed on provider_name = "meta-reference-gpu". Please help!

the script is the following:

import os
import uuid

from llama_stack.distribution.library_client import LlamaStackAsLibraryClient
from llama_stack_client.lib.agents.agent import Agent
from llama_stack_client.lib.agents.event_logger import EventLogger
from llama_stack_client.types import Document
from llama_stack_client.types.agent_create_params import AgentConfig
from termcolor import cprint

# model_id = "meta-llama/Llama-3.3-70B-Instruct"
model_id = "meta-llama/Llama-3.2-11B-Vision-Instruct"

provider_name = "meta-reference-gpu"
os.environ["INFERENCE_MODEL"] = model_id
client = LlamaStackAsLibraryClient(provider_name)
_ = client.initialize()
urls = ["chat.rst", "llama3.rst", "memory_optimizations.rst", "lora_finetune.rst"]
documents = [
    Document(
        document_id=f"num-{i}",
        content=f"https://raw.githubusercontent.com/pytorch/torchtune/main/docs/source/tutorials/{url}",
        mime_type="text/plain",
        metadata={},
    )
    for i, url in enumerate(urls)
]

vector_db_id = f"test-vector-db-{uuid.uuid4().hex}"
client.vector_dbs.register(
    vector_db_id=vector_db_id,
    embedding_model="all-MiniLM-L6-v2",
    embedding_dimension=384,
)
client.tool_runtime.rag_tool.insert(
    documents=documents,
    vector_db_id=vector_db_id,
    chunk_size_in_tokens=512,
)
agent_config = AgentConfig(
    model=model_id,
    instructions="You are a helpful assistant",
    enable_session_persistence=False,
    toolgroups=[
        {
            "name": "builtin::rag",
            "args": {
                "vector_db_ids": [vector_db_id],
            },
        }
    ],
)
rag_agent = Agent(client, agent_config)
session_id = rag_agent.create_session("test-session")
user_prompts = [
    "What are the top 5 topics that were explained? Only list succinct bullet points.",
]
for prompt in user_prompts:
    cprint(f"User> {prompt}", "green")
    response = rag_agent.create_turn(
        messages=[{"role": "user", "content": prompt}],
        session_id=session_id,
    )
    for log in EventLogger().log(response):
        log.print()

Error logs

python test_rag.py 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/spawn.py", line 125, in _main
    prepare(preparation_data)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/runpy.py", line 289, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/kaiwu/work/llama-stack-apps/examples/imagetag/test_rag.py", line 17, in <module>
    _ = client.initialize()
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/distribution/library_client.py", line 135, in initialize
    return asyncio.run(self.async_client.initialize())
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/distribution/library_client.py", line 202, in initialize
    self.impls = await construct_stack(self.config, self.custom_provider_registry)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/distribution/stack.py", line 203, in construct_stack
    await register_resources(run_config, impls)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/distribution/stack.py", line 94, in register_resources
    await method(**obj.model_dump())
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/providers/utils/telemetry/trace_protocol.py", line 89, in async_wrapper
    result = await method(self, *args, **kwargs)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/distribution/routers/routing_tables.py", line 248, in register_model
    registered_model = await self.register_object(model)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/distribution/routers/routing_tables.py", line 195, in register_object
    registered_obj = await register_object_with_provider(obj, p)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/distribution/routers/routing_tables.py", line 56, in register_object_with_provider
    return await p.register_model(obj)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/providers/utils/telemetry/trace_protocol.py", line 89, in async_wrapper
    result = await method(self, *args, **kwargs)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/providers/inline/inference/meta_reference/inference.py", line 132, in register_model
    await self.load_model(model.identifier, llama_model)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/providers/utils/telemetry/trace_protocol.py", line 89, in async_wrapper
    result = await method(self, *args, **kwargs)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/providers/inline/inference/meta_reference/inference.py", line 84, in load_model
    self.generator.start()
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/providers/inline/inference/meta_reference/model_parallel.py", line 84, in start
    self.__enter__()
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/providers/inline/inference/meta_reference/model_parallel.py", line 96, in __enter__
    self.group.start()
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/providers/inline/inference/meta_reference/parallel_utils.py", line 319, in start
    self.request_socket, self.process = start_model_parallel_process(
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/site-packages/llama_stack/providers/inline/inference/meta_reference/parallel_utils.py", line 294, in start_model_parallel_process
    process.start()
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/context.py", line 288, in _Popen
    return Popen(process_obj)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "/home/kaiwu/miniconda3/envs/llama/lib/python3.10/multiprocessing/spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

Expected behavior

"meta-reference-gpu" inline-client should initiate successfully and be able to run RAG.

@wukaixingxp wukaixingxp added the bug Something isn't working label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants