humza
(humza)
December 6, 2021, 8:05pm
1
Traceback (most recent call last):
** File “test.py”, line 55, in **
** from torchvision.transforms import transforms as T**
** File “/home/manager/env/lib/python3.8/site-packages/torchvision/init .py”, line 4, in **
** from .extension import _HAS_OPS**
** File “/home/manager/env/lib/python3.8/site-packages/torchvision/extension.py”, line 101, in **
** _check_cuda_version()**
** File “/home/manager/env/lib/python3.8/site-packages/torchvision/extension.py”, line 80, in _check_cuda_version**
** _version = torch.ops.torchvision._cuda_version()**
RuntimeError: random_device could not be read
Not sure whats wrong, whenever I try to run my model in a script on cuda device I get this error.
If I import “from torchvision.transforms import transforms as T” in a console it runs fine.
I have tried installing latest to historic versions of pytorch but no luck.
My system has ubuntu 20.04 installed. I am also using tensorflow along with pytorch in the script. I have started facing this issue after upgrading to 20.04 from 16.04.
This would point to a broken installation in the other environment you are using (I don’t know how you are executing the script in the failing case).
I just want to write that I see a very similar problem. I reported it also here:
opened 08:58AM - 26 May 23 UTC
### 🐛 Describe the bug
Code:
```python
import tensorflow
import torch
```…
This hangs in some cases in the `import torch`.
Importing it the other way around, or also just importing Torch does not hang. However, I'm reporting this here because the stacktrace looks still suspicious.
Specifically, on my system, Ubuntu 22.04, using the distrib Python 3.10, I have TensorFlow 2.12 and PyTorch 2.0.1. Same also with Python 3.11.
The stacktrace of the hang:
```
0x00007ffff7d51992 in __GI___libc_read (fd=0, buf=0x7fffffffa6f7, nbytes=1) at ../sysdeps/unix/sysv/linux/read.c:26
26 ../sysdeps/unix/sysv/linux/read.c: No such file or directory.
(gdb) bt
#0 0x00007ffff7d51992 in __GI___libc_read (fd=0, buf=0x7fffffffa6f7, nbytes=1) at ../sysdeps/unix/sysv/linux/read.c:26
#1 0x00007ffff43af518 in std::random_device::_M_getval() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007fff5d55a6ef in _GLOBAL__sub_I_IpcFabricConfigClient.cpp () from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so
#3 0x00007ffff7fc947e in call_init (l=<optimized out>, argc=argc@entry=3, argv=argv@entry=0x7fffffffd1c8, env=env@entry=0x555557198d40) at ./elf/dl-init.c:70
#4 0x00007ffff7fc9568 in call_init (env=0x555557198d40, argv=0x7fffffffd1c8, argc=3, l=<optimized out>) at ./elf/dl-init.c:33
...
```
The `fd=0`, coming from `std::random_device::_M_getval` looks very suspicious to me. It looks like the `std::random_device` is not properly initialized? Code [here](https://github.com/gcc-mirror/gcc/blob/d156c6054200237b707f9fb44ae9958d926b0745/libstdc%2B%2B-v3/src/c%2B%2B11/random.cc#L582) and [here](https://github.com/pytorch/kineto/blob/6bf8eeb9955a2e975e494ae8dffd2259680e771b/libkineto/src/IpcFabricConfigClient.cpp#L26).
In other cases, I have also seen the error "random_device could not be read". This seems to be very related, maybe it got another uninitialized `_M_fd` value.
I also reported this here: https://github.com/rwth-i6/returnn/issues/1339
Some related issues:
https://discuss.pytorch.org/t/random-device-could-not-be-read/138697 (very related)
https://github.com/JohnSnowLabs/spark-nlp/issues/5943
https://discuss.tensorflow.org/t/tensorflow-linux-wheels-are-being-upgraded-to-manylinux2014/8339
https://github.com/h2oai/datatable/issues/2453
https://github.com/robjinman/pro_office_calc/issues/5
https://github.com/boostorg/fiber/issues/249
https://github.com/h2oai/datatable/issues/2453
https://github.com/microsoft/LightGBM/issues/1516
### Versions
PyTorch version: 2.0.1+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A
OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: 15.0.7
CMake version: version 3.26.3
Libc version: glibc-2.35
Python version: 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-5.15.0-46-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce GTX 980
Nvidia driver version: 530.41.03
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: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 6
On-line CPU(s) list: 0-5
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz
CPU family: 6
Model: 158
Thread(s) per core: 1
Core(s) per socket: 6
Socket(s): 1
Stepping: 10
CPU(s) scaling MHz: 42%
CPU max MHz: 4100.0000
CPU min MHz: 800.0000
BogoMIPS: 6000.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 pni pclmulqdq dtes64 monitor ds_cpl smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
L1d cache: 192 KiB (6 instances)
L1i cache: 192 KiB (6 instances)
L2 cache: 1.5 MiB (6 instances)
L3 cache: 9 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-5
Vulnerability Itlb multihit: KVM: Mitigation: VMX unsupported
Vulnerability L1tf: Mitigation; PTE Inversion
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Retbleed: Mitigation; IBRS
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; IBRS, IBPB conditional, RSB filling
Vulnerability Srbds: Mitigation; Microcode
Vulnerability Tsx async abort: Mitigation; TSX disabled
Versions of relevant libraries:
[pip3] flake8==4.0.1
[pip3] numpy==1.23.5
[pip3] torch==2.0.1
[pip3] torchaudio==2.0.2
[pip3] torchdata==0.6.1
[pip3] triton==2.0.0
[conda] Could not collect
opened 01:41PM - 25 May 23 UTC
File `IpcFabricConfigClient.cpp`.
```
$ gdb --args python3 -m pytest tests/t… est_rf_array.py
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
...
Reading symbols from python3...
(gdb) r
Starting program: /work/tools/users/zeyer/linuxbrew/bin/python3 -m pytest tests/test_rf_array.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
================================================================== test session starts ==================================================================
platform linux -- Python 3.11.2, pytest-7.3.1, pluggy-1.0.0
rootdir: /u/zeyer/code/returnn
configfile: pytest.ini
collecting ... [Detaching after vfork from child process 2130305]
[Detaching after vfork from child process 2130306]
[Detaching after vfork from child process 2130307]
warning: File "/u/zeyer/.linuxbrew-homefs/Cellar/gcc/12.2.0/lib/gcc/current/libstdc++.so.6.0.30-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /u/zeyer/.linuxbrew-homefs/Cellar/gcc/12.2.0/lib/gcc/current/libstdc++.so.6.0.30-gdb.py
line to your configuration file "/u/zeyer/.config/gdb/gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/u/zeyer/.config/gdb/gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"
[Detaching after vfork from child process 2130356]
[Detaching after vfork from child process 2130357]
[Detaching after vfork from child process 2130360]
Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44 pthread_kill.c: No such file or directory.
(gdb) bt
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1 0x00007ffff77ececf in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2 0x00007ffff77a2ea2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007ffff778e45c in __GI_abort () at abort.c:79
#4 0x00007fffeefd48d9 in ?? () from /work/tools/users/zeyer/linuxbrew/opt/gcc/lib/gcc/current/libstdc++.so.6
#5 0x00007fffeefdff0a in ?? () from /work/tools/users/zeyer/linuxbrew/opt/gcc/lib/gcc/current/libstdc++.so.6
#6 0x00007fffeefdff75 in std::terminate() () from /work/tools/users/zeyer/linuxbrew/opt/gcc/lib/gcc/current/libstdc++.so.6
#7 0x00007fffeefe01c7 in __cxa_throw () from /work/tools/users/zeyer/linuxbrew/opt/gcc/lib/gcc/current/libstdc++.so.6
#8 0x00007fffeefd7253 in std::__throw_runtime_error(char const*) () from /work/tools/users/zeyer/linuxbrew/opt/gcc/lib/gcc/current/libstdc++.so.6
#9 0x00007fffef00acc3 in std::random_device::_M_getval() () from /work/tools/users/zeyer/linuxbrew/opt/gcc/lib/gcc/current/libstdc++.so.6
#10 0x00007fff5f04169f in _GLOBAL__sub_I_IpcFabricConfigClient.cpp () from /u/zeyer/.local/lib/python3.11/site-packages/torch/lib/libtorch_cpu.so
#11 0x00007ffff7fcad6e in call_init (env=0x4cdc7e0, argv=0x7fffffffd668, argc=4, l=<optimized out>) at dl-init.c:70
#12 call_init (l=<optimized out>, argc=4, argv=0x7fffffffd668, env=0x4cdc7e0) at dl-init.c:26
#13 0x00007ffff7fcae54 in _dl_init (main_map=0x4fb9c80, argc=4, argv=0x7fffffffd668, env=0x4cdc7e0) at dl-init.c:117
#14 0x00007ffff78ae4f5 in __GI__dl_catch_exception (exception=<optimized out>, operate=<optimized out>, args=<optimized out>) at dl-error-skeleton.c:182
#15 0x00007ffff7fd1b76 in dl_open_worker (a=0x7fffffff9570) at dl-open.c:808
#16 dl_open_worker (a=a@entry=0x7fffffff9570) at dl-open.c:771
#17 0x00007ffff78ae4a9 in __GI__dl_catch_exception (exception=<optimized out>, operate=<optimized out>, args=<optimized out>) at dl-error-skeleton.c:208
#18 0x00007ffff7fd1d3a in _dl_open (file=0x7fffb5b1f9d0 "/u/zeyer/.local/lib/python3.11/site-packages/torch/_C.cpython-311-x86_64-linux-gnu.so",
mode=<optimized out>, caller_dlopen=0x7ffff7cf8a5f <_PyImport_FindSharedFuncptr+127>, nsid=-2, argc=4, argv=0x7fffffffd668, env=0x4cdc7e0)
at dl-open.c:883
#19 0x00007ffff77e75f8 in dlopen_doit (a=a@entry=0x7fffffff97e0) at dlopen.c:56
#20 0x00007ffff78ae4a9 in __GI__dl_catch_exception (exception=exception@entry=0x7fffffff9740, operate=<optimized out>, args=<optimized out>)
at dl-error-skeleton.c:208
#21 0x00007ffff78ae54f in __GI__dl_catch_error (objname=0x7fffffff97a0, errstring=0x7fffffff97a8, mallocedp=0x7fffffff979f, operate=<optimized out>,
args=<optimized out>) at dl-error-skeleton.c:227
#22 0x00007ffff77e7176 in _dlerror_run (operate=operate@entry=0x7ffff77e75a0 <dlopen_doit>, args=args@entry=0x7fffffff97e0) at dlerror.c:138
#23 0x00007ffff77e7676 in dlopen_implementation (dl_caller=<optimized out>, mode=<optimized out>, file=<optimized out>) at dlopen.c:71
#24 ___dlopen (file=<optimized out>, mode=<optimized out>) at dlopen.c:81
#25 0x00007ffff7cf8a5f in _PyImport_FindSharedFuncptr () from /work/tools/users/zeyer/linuxbrew/lib/libpython3.11.so.1.0
#26 0x00007ffff7ce6a10 in _PyImport_LoadDynamicModuleWithSpec () from /work/tools/users/zeyer/linuxbrew/lib/libpython3.11.so.1.0
#27 0x00007ffff7ce66b8 in _imp_create_dynamic () from /work/tools/users/zeyer/linuxbrew/lib/libpython3.11.so.1.0
#28 0x00007ffff7c3d13e in cfunction_vectorcall_FASTCALL () from /work/tools/users/zeyer/linuxbrew/lib/libpython3.11.so.1.0
#29 0x00007ffff7c6962d in _PyEval_EvalFrameDefault () from /work/tools/users/zeyer/linuxbrew/lib/libpython3.11.so.1.0
...
#124 0x00007ffff7cf8cf8 in Py_RunMain () from /work/tools/users/zeyer/linuxbrew/lib/libpython3.11.so.1.0
#125 0x00007ffff7cf8ab9 in Py_BytesMain () from /work/tools/users/zeyer/linuxbrew/lib/libpython3.11.so.1.0
#126 0x00007ffff778f1b7 in __libc_start_call_main (main=main@entry=0x401040 <main>, argc=argc@entry=4, argv=argv@entry=0x7fffffffd668) at ../sysdeps/nptl/libc_start_call_main.h:58
#127 0x00007ffff778f26c in __libc_start_main_impl (main=0x401040 <main>, argc=4, argv=0x7fffffffd668, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd658) at ../csu/libc-start.c:392
#128 0x0000000000401071 in _start () at ../sysdeps/x86_64/start.S:115
```
I'm posting this because I have not found such stacktrace on Google at all, or any stacktrace related to IpcFabricConfigClient.
What TensorFlow version did you use? I noticed that I get the hang in PyTorch when I use TensorFlow 2.12, but not when I use TensorFlow 2.10. But different CUDA versions/setups might also have influenced this observation.
univanxx
(Ivan)
August 10, 2023, 1:54pm
5
For me importing torchvision package (or other packages using it) before importing tensorflow solved the problem. Wonder why is this happening…
humza
(humza)
August 10, 2023, 2:39pm
6
Some versions of TensorFlow with PyTorch cause this problem. You can try downgrading or upgrading your TensorFlow. For me, it worked by downgrading the TensorFlow
| univanxx Ivan August 10 |
For me importing torchvision package (or other packages using it) before importing tensorflow solved the problem. Wonder why is this happening…
yyyuhan
(Yuhan)
September 6, 2023, 7:50pm
7
1 Like