Repository: stable-diffusion-webui
Issue: Importing Torch takes much longer when running in the cloud
Labels: asking-for-help-with-local-system-issues

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

I am averaging about 20 to 40 seconds while importing torch when running as a container in Google Cloud Run.  This takes much longer than running the same container locally on my PC which only takes torch to import in less than a few seconds.  Why is that?

### Steps to reproduce the problem

1. Run in Google Cloud Run.


### What should have happened?

Startup faster

### Sysinfo

Ubuntu
17 GB RAM
8 vCPUs
No GPU

Arguments: --use-cpu all --precision full --no-half --skip-torch-cuda-test --skip-version-check --skip-python-version-check --api --listen --theme dark --log-startup --allow-code

### What browsers do you use to access the UI ?

_No response_

### Console logs

```Shell
################################################################
Launching launch.py...
################################################################
stdout: Using TCMalloc: libtcmalloc_minimal.so.4
stdout: initial startup: done in 0.009s
  prepare environment:
  checks: done in 0.000s
stderr: fatal: No names found, cannot describe anything.
stdout:   git version info: done in 0.176s
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
Version: 1.6.0
Commit hash: 44006297e03a07f28505d54d6ba5fd55e0c1292d
stdout:   torch GPU test: done in 0.002s
stdout:   clone repositores: done in 0.178s
stdout:     run extensions installers:
stdout: Launching Web UI with arguments: -f --use-cpu all --precision full --no-half --skip-torch-cuda-test --skip-version-check --skip-python-version-check --api --listen --theme dark --log-startup --allow-code
stdout: launcher: done in 0.018s
stdout: import torch: done in 14.689s
stdout: import torch: done in 13.457s
stdout: import gradio: done in 5.950s
stdout: no module 'xformers'. Processing without...
stdout: no module 'xformers'. Processing without...
stdout: setup paths: done in 5.534s
stdout: import ldm: done in 0.068s
import sgm: done in 0.000s
stdout: No module 'xformers'. Proceeding without it.
stdout: Warning: caught exception 'Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx', memory monitor disabled
stdout: initialize shared: done in 0.725s
stdout: other imports: done in 5.135s
stdout: opts onchange: done in 0.001s
stdout: setup SD model: done in 0.004s

stdout: setup codeformer: done in 0.736s

stdout: setup gfpgan: done in 0.182s

set samplers: done in 0.000s
stdout: list extensions: done in 0.001s

restore config state file: done in 0.000s

stdout: list SD models: done in 0.029s

stdout: list localizations: done in 0.003s

  load scripts:
T
stdout:   custom_code.py: done in 0.014s

stdout:   img2imgalt.py: done in 0.006s

stdout:   loopback.py: done in 0.005s

stdout:   openvino_accelerate.py: done in 2.415s

stdout:   outpainting_mk_2.py: done in 0.007s

stdout:   poor_mans_outpainting.py: done in 0.006s

stdout:   postprocessing_codeformer.py: done in 0.005s

stdout:   postprocessing_gfpgan.py: done in 0.006s

stdout:   postprocessing_upscale.py: done in 0.007s

stdout:   prompt_matrix.py: done in 0.009s

stdout:   prompts_from_file.py: done in 0.006s

stdout:   refiner.py: done in 0.008s
stdout:   sd_upscale.py: done in 0.005s

stdout:   seed.py: done in 0.008s

stdout:   xyz_grid.py: done in 0.010s

stdout:   ldsr_model.py: done in 0.416s

stdout:   lora_script.py: done in 0.394s

stdout:   scunet_model.py: done in 0.098s

stdout:   swinir_model.py: done in 0.084s

stdout:   hotkey_config.py: done in 0.009s

stdout:   extra_options_section.py: done in 0.008s

stdout: load upscalers: done in 0.149s

stdout: refresh VAE: done in 0.004s

stdout: refresh textual inversion templates: done in 0.001s

stdout: scripts list_optimizers: done in 0.001s

scripts list_unets: done in 0.000s

stdout: 

stdout: Loading weights [6ce0161689] from /app/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors

stdout: 
stdout: reload hypernetworks: done in 0.053s

stdout: initialize extra networks: done in 0.503s

stdout: scripts before_ui_callback: done in 0.038s

stdout: 
stdout: create ui: done in 4.932s

stdout: 

stdout: Running on local URL:  http://0.0.0.0:7860

stdout: 

To create a public link, set `share=True` in `launch()`.

stdout: 

stdout: gradio launch: done in 2.960s

stdout: 

stdout: add APIs: done in 0.409s

  app_started_callback:

stdout: 

stdout:   lora_script.py: done in 0.019s
stdout: Startup time: 59.5s (prepare environment: 0.7s, import torch: 28.1s, import gradio: 5.9s, setup paths: 5.5s, initialize shared: 0.7s, other imports: 5.1s, setup codeformer: 0.7s, setup gfpgan: 0.2s, load scripts: 3.5s, load upscalers: 0.1s, initialize extra networks: 0.5s, create ui: 4.9s, gradio launch: 3.0s, add APIs: 0.4s).

stdout: Creating model from config: /app/stable-diffusion-webui/configs/v1-inference.yaml

stderr: 

vocab.json:   0%|          | 0.00/961k [00:00<?, ?B/s]

stderr: 

vocab.json: 100%|██████████| 961k/961k [00:00<00:00, 5.20MB/s]

stderr: 

vocab.json: 100%|██████████| 961k/961k [00:00<00:00, 5.16MB/s]

stderr: 

merges.txt:   0%|          | 0.00/525k [00:00<?, ?B/s]

stderr: 

merges.txt: 100%|██████████| 525k/525k [00:00<00:00, 2.77MB/s]

stderr: 

merges.txt: 100%|██████████| 525k/525k [00:00<00:00, 2.77MB/s]

stderr: 

special_tokens_map.json:   0%|          | 0.00/389 [00:00<?, ?B/s]

stderr: 
special_tokens_map.json: 100%|██████████| 389/389 [00:00<00:00, 1.98MB/s]

stderr: 

tokenizer_config.json:   0%|          | 0.00/905 [00:00<?, ?B/s]

stderr: 

tokenizer_config.json: 100%|██████████| 905/905 [00:00<00:00, 4.76MB/s]

stderr: 

config.json:   0%|          | 0.00/4.52k [00:00<?, ?B/s]

config.json: 100%|██████████| 4.52k/4.52k [00:00<00:00, 21.0MB/s]

stdout: Applying attention optimization: InvokeAI... done.

stdout: Model loaded in 50.6s (load weights from disk: 10.3s, create model: 2.2s, apply weights to model: 37.4s, calculate empty prompt: 0.5s).
```


### Additional information

_No response_