PyTorch hangs at import when used together with TensorFlow
Labels: triaged, topic: binaries

### 🐛 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