HuggingFaceInstructEmbeddings hangs in Docker container, but runs fine on MacOS
Labels: name: area: embeddings, name: area: doc loader, name: area: vector store, name: auto:bug

### System Info

requirements.txt:
```
langchain==0.0.254
atlassian-python-api==3.36.0
chromadb==0.3.25
huggingface-hub==0.16.4
torch==2.0.1
sentence-transformers==2.2.2
InstructorEmbedding==1.0.0
p4python==2023.1.2454917
lxml==4.9.2
bs4==0.0.1
```

Dockerfile
```Dockerfile
FROM python:3.10

# Create a directory for your application
WORKDIR /app

COPY requirements.txt .

# Upgrade pip
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3.10 get-pip.py
RUN python3.10 -m pip install --upgrade pip
RUN python3.10 -m pip install -r requirements.txt

# RUN python3.10 preload.py
RUN python3.10 -m pip install openai tiktoken
RUN apt-get update && apt-get install -y vim

COPY . .

ENTRYPOINT sleep infinity;
```

Host where I am running Docker: (Am also running python3.10 on this)
```bash
Software:

    System Software Overview:

      System Version: macOS 13.4 (22F66)
      Kernel Version: Darwin 22.5.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal

Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: Mac14,10
      Chip: Apple M2 Pro
      Total Number of Cores: 12 (8 performance and 4 efficiency)
      Memory: 32 GB
```

### Who can help?

@agola11 @hwchase17 

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [X] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [X] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Run this script with above requirements.txt in docker container set up by Dockerfile 

```python
from langchain.embeddings import HuggingFaceEmbeddings, HuggingFaceInstructEmbeddings
from langchain.embeddings import OpenAIEmbeddings
from langchain.document_loaders import ConfluenceLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter

loader = ConfluenceLoader(...)

documents = loader.load(...)

text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
texts = text_splitter.split_documents(documents)

embeddings = HuggingFaceInstructEmbeddings(model_name= "hkunlp/instructor-large",  model_kwargs={"device": "cpu"})

#Vector Database Storage: Store the generated embeddings in a vector database, allowing for efficient similarity searches.
db = Chroma.from_documents(texts, embeddings) # Stuck here
```

Successful runs where I am able to upload embeddings to db:
- Running this on my mac (no Docker)
- Running this in Docker container with OpenAIEmbeddings

Runs that get stuck:
- Running this in Docker container with HuggingFaceEmbeddings or HuggingFaceInstructEmbeddings

When I manually interrupt that stuck process, here is the traceback:
```bash
raceback (most recent call last):
  File "/app/context.py", line 26, in <module>
    ctx_manager.register_documents(paths, text_splitter_type, text_splitter_params,
  File "/app/context_manager/context_manager/context_manager.py", line 197, in register_documents
    self._vectordb_manager.add_documents(texts, embeddings,
  File "/app/context_manager/db_managers/db_managers.py", line 92, in add_documents
    vectorstore = Chroma.from_documents(
  File "/usr/local/lib/python3.10/site-packages/langchain/vectorstores/chroma.py", line 603, in from_documents
    return cls.from_texts(
  File "/usr/local/lib/python3.10/site-packages/langchain/vectorstores/chroma.py", line 567, in from_texts
    chroma_collection.add_texts(texts=texts, metadatas=metadatas, ids=ids)
  File "/usr/local/lib/python3.10/site-packages/langchain/vectorstores/chroma.py", line 187, in add_texts
    embeddings = self._embedding_function.embed_documents(texts)
  File "/usr/local/lib/python3.10/site-packages/langchain/embeddings/huggingface.py", line 77, in embed_documents
    embeddings = self.client.encode(texts, **self.encode_kwargs)
  File "/usr/local/lib/python3.10/site-packages/sentence_transformers/SentenceTransformer.py", line 165, in encode
    out_features = self.forward(features)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/container.py", line 217, in forward
    input = module(input)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/sentence_transformers/models/Transformer.py", line 74, in forward
    output_states = self.auto_model(**trans_features, return_dict=False)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/transformers/models/t5/modeling_t5.py", line 1935, in forward
    encoder_outputs = self.encoder(
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/transformers/models/t5/modeling_t5.py", line 1094, in forward
    layer_outputs = layer_module(
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/transformers/models/t5/modeling_t5.py", line 754, in forward
    hidden_states = self.layer[-1](hidden_states)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/transformers/models/t5/modeling_t5.py", line 343, in forward
    forwarded_states = self.DenseReluDense(forwarded_states)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/transformers/models/t5/modeling_t5.py", line 288, in forward
    hidden_states = self.wi(hidden_states)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)
KeyboardInterrupt
```

I thought it may be the CPU usage, but on my Mac, the CPU usage maxes out at around 270% and does not get stuck. However, in Docker, the CPU usage maxes out to 600% (reserved 6 CPUs), and still gets stuck. Memory is also lower than the limit in both environements.

### Expected behavior

Texts are supposed to get encoded then uploaded to vectorDB