我在系统上使用 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.
-
Verify that the directory containing the CUDA GDR libraries is included in your
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:
-
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.
-
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.
-
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.