Problem with GPU
Author: marcomameli1992
Pull request: no
Labels: name: bug

### System Info


Hello, I'm using windows 11, with RTX2080 and python 3.9. The packages configuration is based on pytorch 1.11 + transformer4.19.0 and when I try to use the transformer in my code with the GPU I receive an error that the data that I pass can't be converted to numpy array. I have posted the problem on the forum at that link: https://discuss.huggingface.co/t/vit-problem-with-gpu-usage-require-image-to-be-numpy/18678/2
I think that is a bug because the input of the network is on the gpu and I do not understand why it is necessary to convert to numpy array.

How can I solve that bug?



### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

I use the image from shapenet.
The image are extracted from a saved tensor.


### Expected behavior

```shell
I expect that when the gpu is used there are no problem on the conversion of the input to GPU.
```


Comments:
You could try to upgrade the **numpy** version with `pip install numpy --upgrade`

I have updated the numpy package to the latest one (1.23.0) but It not work. I don't understand where is the problem.

Are you using the correct version of pytorch that suits your machine? I have no other idea why it might not work...

I using torch 1.11 for windows with gpu support

I have no clue then

Hi @marcomameli1992

Please don't put the issue description inside **\`\`\`shell ... \`\`\`** block, as this makes it hard to read 🙏 .

Regarding the issue, it would be much easier if you can provide a **minimal** code snippet to reproduce the issue. Currently, we don't really know what goes wrong without detailed information.


Dear I use the code here on [github](https://github.com/marcomameli1992/p2m) I make it public for simplicity.

The dataset that I use is from that [link](https://drive.google.com/file/d/1Z8gt4HdPujBNFABYrthhau9VZW10WWYe/view?usp=sharing)

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

Hi @marcomameli1992 Sorry for this late reply.

In order for us to help (if you still need help), it would be very helpful to provide a **minimal** code snippet that reproduces the issue, which could be run directly.

With only a link to a GitHub repository page, we don't really know how to use it, and it also makes the debugging more difficult.


With a very quick look, it looks like you create `pool = FeaturePooling(im)` which doesn't transform the image. Only when `pred_points = model_gcn(graph, pool)` which invokes

https://github.com/marcomameli1992/p2m/blob/7e64071ce2a701044cab58f3c0e7877562157ab1/model/mesh_network.py#L31

will perform the data transformation. I believe this is not the usual good practice. You could try to perform the data transformation (feature extraction) - on CPU (with `numpy` or `torch`), then feed the extracted features into a model (after put them on GPU).