首页 > 编程问答 >初始化 pytorch RPC 时 getBar1SizeOfGpu 出现运行时错误

初始化 pytorch RPC 时 getBar1SizeOfGpu 出现运行时错误

时间:2024-07-23 07:58:58浏览次数:17  
标签:python pytorch rpc

我在系统上使用 PyTorch 和 RPC 后端时遇到运行时错误。错误信息如下: 谁能告诉我为什么会出现这个问题以及如何解决它?谢谢。

Traceback (most recent call last):
  File "/work/personal_workspace/torchrpc_test.py", line 20, in <module>
    rpc.init_rpc(name= f"worker_{ompi_world_rank}", backend=BackendType.TENSORPIPE,
  File "/work/personal_workspace/venv/lib/python3.9/site-packages/torch/distributed/rpc/__init__.py", line 200, in init_rpc
    _init_rpc_backend(backend, store, name, rank, world_size, rpc_backend_options)
  File "/work/personal_workspace/venv/lib/python3.9/site-packages/torch/distributed/rpc/__init__.py", line 233, in _init_rpc_backend
    rpc_agent = backend_registry.init_backend(
  File "/work/personal_workspace/venv/lib/python3.9/site-packages/torch/distributed/rpc/backend_registry.py", line 104, in init_backend
    return backend.value.init_backend_handler(*args, **kwargs)
  File "/work/personal_workspace/venv/lib/python3.9/site-packages/torch/distributed/rpc/backend_registry.py", line 353, in _tensorpipe_init_backend_handler
    api._init_rpc_states(agent)
  File "/work/personal_workspace/venv/lib/python3.9/site-packages/torch/distributed/rpc/api.py", line 119, in _init_rpc_states
    _set_and_start_rpc_agent(agent)
RuntimeError: In getBar1SizeOfGpu at tensorpipe/channel/cuda_gdr/context_impl.cc:242 "": No such file or directory
--------------------------------------------------------------------------

我的代码是这样的

import os
import torch
import torch.distributed.rpc as rpc
from torch.distributed.rpc import BackendType
ompi_world_size = int(os.getenv('OMPI_COMM_WORLD_SIZE', 0))
ompi_world_rank = int(os.getenv('OMPI_COMM_WORLD_RANK', 0))

def recv_tensor(tensors,from_rank):
    print(f"Received tensors: {tensors} from rank {from_rank}")

if __name__ == '__main__':
    print(f"world_size: {ompi_world_size}, world_rank: {ompi_world_rank}")

    options = rpc.TensorPipeRpcBackendOptions(
        num_worker_threads=16,
        #device_maps={f"worker_{i}": {0: 0} for i in range(ompi_world_size)},
        init_method=f"file:///work/personal_workspace/data/sharedfile_rpc",
        rpc_timeout=30,
    )
    rpc.init_rpc(name= f"worker_{ompi_world_rank}", backend=BackendType.TENSORPIPE,
                rank=ompi_world_rank, world_size= ompi_world_size,
                rpc_backend_options=options)
    if rpc.is_available():
        print(f"RPC is available from rank {ompi_world_rank}")
    
    tensor = torch.ones(ompi_world_rank)
    rpc.rpc_sync("worker_0", recv_tensor, args=(tensor,ompi_world_rank))

    rpc.shutdown()

我使用 mpirun 在我的集群中运行上面的代码。 环境是

Collecting environment information...
PyTorch version: 2.3.1+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.25.0
Libc version: glibc-2.35

Python version: 3.9.13 (main, Oct 19 2022, 17:23:07)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-100-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA H100 PCIe
Nvidia driver version: 550.90.07
cuDNN version: Could not collect
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:                      46 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             48
On-line CPU(s) list:                0-47
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Platinum 8468
CPU family:                         6
Model:                              143
Thread(s) per core:                 1
Core(s) per socket:                 48
Socket(s):                          1
Stepping:                           8
Frequency boost:                    enabled
CPU max MHz:                        2101.0000
CPU min MHz:                        800.0000
BogoMIPS:                           4200.00
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          2.3 MiB (48 instances)
L1i cache:                          1.5 MiB (48 instances)
L2 cache:                           96 MiB (48 instances)
L3 cache:                           105 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-47
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 rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] kfac_pytorch==0.4.1
[pip3] numpy==1.26.3
[pip3] torch==2.3.1
[pip3] torch-tb-profiler==0.4.3
[pip3] torchdata==0.7.1
[pip3] torchelastic==0.2.2
[pip3] torchinfo==1.5.2
[pip3] torchtext==0.18.0
[pip3] torchvision==0.18.1
[pip3] triton==2.3.1
[conda] mkl                       2022.2.1            intel_16993    file:///system/apps/ubuntu/20.04-202210/oneapi/2022.3.1/conda_channel
[conda] mkl-dpcpp                 2022.2.1            intel_16993    file:///system/apps/ubuntu/20.04-202210/oneapi/2022.3.1/conda_channel
[conda] mkl-service               2.4.0           py39h7634626_12    file:///system/apps/ubuntu/20.04-202210/oneapi/2022.3.1/conda_channel
[conda] mkl_fft                   1.3.1           py39h1909d4f_16    file:///system/apps/ubuntu/20.04-202210/oneapi/2022.3.1/conda_channel
[conda] mkl_random                1.2.2           py39h94ca54a_16    file:///system/apps/ubuntu/20.04-202210/oneapi/2022.3.1/conda_channel
[conda] mkl_umath                 0.1.1           py39h0348192_26    file:///system/apps/ubuntu/20.04-202210/oneapi/2022.3.1/conda_channel
[conda] numpy                     1.21.4          py39h8dc10e9_16    file:///system/apps/ubuntu/20.04-202210/oneapi/2022.3.1/conda_channel
[conda] numpy-base                1.21.4          py39h97bc315_16    file:///system/apps/ubuntu/20.04-202210/oneapi/2022.3.1/conda_channel
[conda] torch                     2.0.0+cu118              pypi_0    pypi
[conda] torch-cluster             1.6.1+pt20cu118          pypi_0    pypi
[conda] torch-geometric           2.3.0                    pypi_0    pypi
[conda] torch-scatter             2.1.1+pt20cu118          pypi_0    pypi
[conda] torch-sparse              0.6.17+pt20cu118          pypi_0    pypi
[conda] torch-spline-conv         1.2.2+pt20cu118          pypi_0    pypi
[conda] torchaudio                2.0.1+cu118              pypi_0    pypi
[conda] torchvision               0.15.1+cu118             pypi_0    pypi
[conda] triton                    2.0.0                    pypi_0    pypi

Chatgpt告诉我更新我的pytorch,我这样做了,但是没有用。

我使用的系统是由管理员管理的,我所能做的就是修改Python虚拟环境或加载不同版本的cuda。


The error message "RuntimeError: In getBar1SizeOfGpu at tensorpipe/channel/cuda_gdr/context_impl.cc:242 "": No such file or directory" suggests that there is an issue with the CUDA GDR (GPU Direct RDMA) component of the TensorPipe backend in PyTorch.

This issue might be caused by one of the following reasons:

1. Missing CUDA GDR Support:

  • Your system or CUDA installation might not have the necessary libraries or drivers for CUDA GDR.
  • Solution: Verify that your system and CUDA version support CUDA GDR. Check the NVIDIA documentation and your system's hardware specifications.

2. Incompatible CUDA Versions:

  • There might be a mismatch between the CUDA version used to build PyTorch and the one available in your environment.
  • Solution:
    • Ensure that the CUDA version used to build PyTorch is compatible with your system's CUDA driver.
    • You can rebuild PyTorch from source using the appropriate CUDA version or try a different PyTorch installation built with a compatible CUDA version.

3. Incorrect Library Paths:

  • The required CUDA GDR libraries might not be in the system's library path.
  • Solution:
    • Verify that the directory containing the CUDA GDR libraries is included in your LD_LIBRARY_PATH environment variable.
    • For example, you can add the following line to your shell configuration file (e.g., .bashrc ): bash export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
    • Replace /usr/local/cuda/lib64 with the actual path to your CUDA library directory.

4. File System Permissions:

  • Insufficient file system permissions might be preventing access to the CUDA GDR libraries.
  • Solution:
    • Check the permissions on the CUDA GDR library files and ensure that the user running the PyTorch script has read access to them.

Since you mentioned limited access to the system, try the following:

  1. Contact your system administrator: Inform them about the issue and provide the error message. They might be able to install the necessary CUDA GDR components or resolve any system-level configurations.

  2. Request a different PyTorch environment: If possible, request your administrator to provide a PyTorch environment built with a compatible CUDA version and with proper CUDA GDR support.

  3. Consider alternative backends: If CUDA GDR is not feasible, explore using other PyTorch RPC backends, such as Gloo or MPI, which might not require CUDA GDR and could be easier to configure in your environment.

标签:python,pytorch,rpc
From: 78723384

相关文章

  • 从Python中的列表列表中提取随机列表选择
    我有一个从图像生成的RGB值列表:color_list=[(192,155,120),(132,81,65),(226,226,199),(76,94,117),(140,157,178),(17,34,54),(217,213,139),(134,171,144),(98,123,95),(109,145,96),(181,109,92),(71,47,39),......
  • 这段代码是否保证Python对象被立即删除?
    我正在将Redis异步客户端与Celery一起使用,但在两者之间的集成方面遇到了一些问题。上下文是我需要删除redis.Redis实例(在构造函数中创建)以便关闭连接(该对象有一个close方法,但当asyncio事件循环关闭时我无法使用它,heal_client方法仅在这些情况下才会使用。我的代码如......
  • python selenium 行为错误:AttributeError:“Context”对象没有属性“driver”
    我正在使用pythonselenium与Behavior包一起工作。这是代码:@given('theuserisontheloginpage')defstep_given_user_on_login_page(context):PATH='C:/Users/PycharmProjects/ui_test/chromedriver-win32/chromedriver.exe'context.driver=......
  • python 脚本中的路点用于处理大数据集
    我编写了一个脚本,将一堆来自api的请求写入csv文件。该api中有数千个请求,并且在结束循环/退出程序之前永远不会结束。如何合并航路点,以便如果再次发生停顿,它会自动继续前进并最终打印所有请求?我尝试了一些不起作用的方法,但我不知道下一步该怎么做。以下是使用航路点......
  • Python 中的 SSL 模块不可用(在 OSX 上)
    我在OSX10.13上的virtualenv中运行时遇到问题。我已经运行了pipinstall并且路径brewinstallopenssl指向/usr/local/include/openssl有谁知道如何解决这一问题?在我重新安装../opt/openssl/include/openssl使用python后,这种......
  • AWS Elastic Beanstalk chown PythonPath 错误
    我正在AWS的elasticbeanstalk上部署一个Web应用程序,遇到了同样的错误:[StageApplication].Stoprunningthecommand.Error:chown/var/app/staging/venv/bin/python:nosuchfileordirectory.我在我的环境配置中看到属性:PYTHONPATH:/var/......
  • Python:支持索引的内存对象数据库?
    我正在做一些数据整理,如果我可以将一堆字典放入内存数据库中,然后对其运行简单的查询,这会简单得多。例如,类似:people=db([{"name":"Joe","age":16},{"name":"Jane","favourite_color":"red"},])over_16=db.filter(age__g......
  • 如何平衡 PyTorch 数据集?
    我有一个不平衡的PyTorch数据集。A和V样本的数量远低于其他样本我想平衡我的数据集,即使我必须删除属于主流类的样本。怎么办?现在,如果某些类的数量超过某个固定值,我只需删除某些类的样本。这在技术上比较复杂并且不方便。也许有一些sklearn或PyTorch方法可......
  • 如何构建一维数组的二维数组的特定 Python 结构?
    如何构建一维数组(即行向量)的二维数组的特定结构以满足特定我正在维护的遗留程序的结构?我可以在此结构中生成正确的内容all_measurements[:12]array([[0.,0.,0.,2.],[0.02,0.334,0.04,2.24],[0.04,0.668,0.08,2.48],...........
  • 如何使用 Python Flask 将新的咖啡馆(元素)添加到数据库(SQLite)?
    这是我的代码:@app.route("/add",methods=["POST"])defpost_new_cafe():new_cafe=Cafe(name=request.form.get("name"),map_url=request.form.get("map_url"),img_url=request.form.get("img......