Repository: pytorch
Issue: Pytorch not calling to C code from a docker container
Labels: needs reproduction,triaged,module: docker,module: __torch_function__

### 🐛 Describe the bug

I'm trying to run a StableDiffusionPipeline from a docker container by a Celery worker. When ran locally everything works fine, but when launched in a container execution just stops when python attempts to call `_has_torch_function_variadic` for come checkup.

It doesn't produce any message, it's basically falling into the void.

It seems that calls to C code happen on a tokenization of a prompt, when it attempts to make a forward call in a `CLIPTextModel`. I'm not sure if it's an issue of a docker settings or me screwing up some parameters, but it is certainly clear that the issue comes up when PyTorch is attempting to make a call to this exact function.

Here's an example of a code i'm trying to run:
```python
pipe = StableDiffusionPipeline.from_pretrained(
        "prompthero/openjourney-v4",
        torch_dtype=torch.float16,
)

with torch.autocast('cuda'):
    image = self.pipe(           # execution stops here
        data.question,
        num_inference_steps=150,
        num_images_per_prompt=4,
    ).images
```

Here's a Dockerfile and docker-compose.yml I'm usigs:

```Dockerfile
FROM python:3.10

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /code/

COPY requirements.txt /code/
RUN pip install -r requirements.txt

COPY build.py /code/
COPY docker-build.sh /code/

RUN ./docker-build.sh

COPY . /code/
```
```yaml
version: '3.7'

services:
  celery:
    restart: always
    build:
      context: .
      dockerfile: ./Dockerfile
    image: air_local_ml_celery
    container_name: air_local_ml_celery
    env_file: ./.env
    command: celery -A ml_local.celery_app worker -l INFO --concurrency 4
    deploy:
      resources:
        reservations:
          devices:
          - driver: nvidia
            count: 1
            capabilities: [gpu]
```

I'm using Celery version 5.3.0 and Torch 2.0.1 on Python 3.10

### 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 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.26.4
Libc version: glibc-2.31

Python version: 3.10.12 (main, Jun  7 2023, 12:45:35) [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-73-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 10.1.243
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3060
Nvidia driver version: 530.30.02
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
Byte Order:                      Little Endian
Address sizes:                   48 bits physical, 48 bits virtual
CPU(s):                          12
On-line CPU(s) list:             0-11
Thread(s) per core:              2
Core(s) per socket:              6
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       AuthenticAMD
CPU family:                      25
Model:                           80
Model name:                      AMD Ryzen 5 5600G with Radeon Graphics
Stepping:                        0
Frequency boost:                 enabled
CPU MHz:                         1700.000
CPU max MHz:                     3900,0000
CPU min MHz:                     1400,0000
BogoMIPS:                        7785.19
Virtualization:                  AMD-V
L1d cache:                       192 KiB
L1i cache:                       192 KiB
L2 cache:                        3 MiB
L3 cache:                        16 MiB
NUMA node0 CPU(s):               0-11
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 and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
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 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 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 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm

Versions of relevant libraries:
[pip3] numpy==1.24.3
[pip3] torch==2.0.1
[pip3] triton==2.0.0
[conda] Could not collect


cc @hameerabbasi @rgommers @peterbell10 @ezyang