`dlopen: cannot load any more object with static TLS` after installing sentencepiece
Author: cyk1337
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.19.2  (tried 4.20 / 4.21dev)
- Platform: Linux-3.10.0_3-0-0-12-x86_64-with-centos-6.3-Final
- Python version: 3.7.11
- PyTorch version (GPU?): 1.7.0 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Y
- Using distributed or parallel set-up in script?: N

### Who can help?

@SaulLu

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction


```python
from transformers import AutoTokenizer
model_name_or_path="./t5-v1_1-base"  # `path to t5-v1_1-base`
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, cache_dir=None, use_fast=True)
```

### Expected behavior

Expected error:
```bash
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/models/auto/tokenization_auto.py", line 573, in from_pretrained
    return tokenizer_class_fast.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/tokenization_utils_base.py", line 1791, in from_pretrained
    **kwargs,
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/tokenization_utils_base.py", line 1929, in _from_pretrained
    tokenizer = cls(*init_inputs, **init_kwargs)
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/models/t5/tokenization_t5_fast.py", line 141, in __init__
    **kwargs,
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/tokenization_utils_fast.py", line 119, in __init__
    "Couldn't instantiate the backend tokenizer from one of: \n"
ValueError: Couldn't instantiate the backend tokenizer from one of: 
(1) a `tokenizers` library serialization file, 
(2) a slow tokenizer instance to convert or 
(3) an equivalent slow tokenizer class to instantiate and convert. 
You need to have sentencepiece installed to convert a slow tokenizer to a fast one.
```

Then I try to install sentencepiece 0.1.96  via `pip install sentencepiece`
```bash
Installing collected packages: sentencepiece
Successfully installed sentencepiece-0.1.96
```
But the OSError occurs.

```bash
Traceback (most recent call last):
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/utils/import_utils.py", line 872, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/models/t5/modeling_t5.py", line 24, in <module>
    import torch
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/torch/__init__.py", line 189, in <module>
    _load_global_deps()
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/torch/__init__.py", line 142, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen: cannot load any more object with static TLS

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "t5_mlm/run_t5_mlm.py", line 35, in <module>
    from transformers import (
  File "<frozen importlib._bootstrap>", line 1032, in _handle_fromlist
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/utils/import_utils.py", line 863, in __getattr__
    value = getattr(module, name)
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/utils/import_utils.py", line 862, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/home/cyk/anaconda3/envs/pt1.7/lib/python3.7/site-packages/transformers/utils/import_utils.py", line 876, in _get_module
    ) from e
RuntimeError: Failed to import transformers.models.t5.modeling_t5 because of the following error (look up to see its traceback):
dlopen: cannot load any more object with static TLS
```

Comments:
Hi @cyk1337,

`"./t5-v1_1-base"` looks like a local path, could you share its content with us so that we can reproduce the error please?

> Hi @cyk1337,
> 
> `"./t5-v1_1-base"` looks like a local path, could you share its content with us so that we can reproduce the error please?

Hi @SaulLu , please refer to [https://huggingface.co/google/t5-v1_1-base/tree/main](https://huggingface.co/google/t5-v1_1-base/tree/main) for tokenizer files.

Thanks, unfortunately I didn't succeed in reproducing your error.

I see in your stack trace the mention of `t5_mlm/run_t5_mlm.py`, are you running this code? If yes, can you try to just run the snippet you shared with me? :smile: 

I have rerun the provided snippet separately but find it works. The whole script seems not work due to some dependency conflicts. I just tried to adjust their import orders and temporarily resolved it. I suspect it results from some  conflicts from common dependencies that the libraries require. Thank you for your help and will reopen it if it reoccurs.🤝