Documentation doesn't include instructions for applying BertModel to documents using GPU acceleration
Author: rjurney
Pull request: no

# 🐛 Bug

## Information

I am using `BertModel` to encode my documents using the representation I've just fine-tuned and it is not using the GPU to do the encoding. This is bad because encoding is very slow. I have it running on many cores but would prefer GPU acceleration. It is not clear from the documentation how to use the GPU to encode documents using a trained `BertModel`.

Model I am using (Bert, XLNet ...): Bert.

Language I am using the model on (English, Chinese ...): English.

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [x] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1. Use the language model example to fine-tune a bert model
2. Load your BertModel and apply it to text documents:

```python
import numpy as np
import torch

from transformers import BertModel, BertTokenizer


tokenizer = BertTokenizer.from_pretrained('my_model')
bert_model = BertModel.from_pretrained('my_model')

docs = ['I like cats but also dogs', 'I like cars full of cats', 'I like apples but not oranges', 'I like tutus on ballerinas.']
docs = np.tile(docs, 5000)

encoded_docs = []
for doc in docs[0:10]:
    tensor = torch.tensor(tokenizer.encode(doc, add_special_tokens=True)).unsqueeze(0)
    encoded_tensor = bert_model(tensor)
    encoded_ary = encoded_tensor[0].cpu().detach().numpy()
    encoded_docs.append(encoded_ary)

encoded_docs
```

3. While this is going run:

```bash
gpustat -i 1
```

4. See that the GPUs aren't being used.

```bash
[0] Tesla T4         | 31'C,   0 % |     0 / 15109 MB |
[1] Tesla T4         | 31'C,   0 % |     0 / 15109 MB |
[2] Tesla T4         | 32'C,   0 % |     0 / 15109 MB |
[3] Tesla T4         | 30'C,   0 % |     0 / 15109 MB |
```

5. Run this on many cores and see how incredibly slow it still is without GPUs. Get frustrated.

## Expected behavior

I want transformers/PyTorch to use the GPU to encode the text using the Bert model so it is muc faster than doing it in CPU.

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->
     
- `transformers` version:
- Platform: Ubuntu 18.04 Amazon Deep Learning AMI 
- Python version: Python 3.6.10 :: Anaconda, Inc.
- PyTorch version (GPU?): torch==1.4.0
- Tensorflow version (GPU?): 
- Using GPU in script?: Trying
- Using distributed or parallel set-up in script?: In reality I am running this in Dask in an apply, but the example should do the same thing.


Comments:
This is a pretty basic question that's not really about the library:)

Check out the PyTorch doc, in particular, the [60 minute blitz](https://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html). TL;DR: You'll need to move your model and inputs to the device you want with `.to(device)` calls.

@julien-c Ok, thanks I appreciate it :)

You're welcome:)

Closing this for now

@julien-c I am stuck in that I can't figure out how to get the string data to the GPU. Tensor.from_numpy does not support strings. So how do you achieve this? I get errors about the data not being on the save device as the GPU. It works on CPU but I've searched and searched and can't figure out how to get strings onto the GPU. Is there another method that use encoded data? That I can send to the GPU.

If I get it working I'll create an example of GPU encoding :D

It seem that the `encode()` method needs a brother that accepts tokenized/BERT encoded data from the first layer. Then the model will be applied to the data. This makes GPU support easy because you can create a Tensor out of data encoded by a BertTokenizer and send it to a GPU device. No such luck with strings.

Actually I think I'm confused. You don't use encode() to apply the model, do you? Use use SentenceTransformer(data).