Unable to format dataset to CUDA Tensors
{'login': 'gchhablani', 'id': 29076344, 'node_id': 'MDQ6VXNlcjI5MDc2MzQ0', 'avatar_url': 'https://avatars.githubusercontent.com/u/29076344?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/gchhablani', 'html_url': 'https://github.com/gchhablani', 'followers_url': 'https://api.github.com/users/gchhablani/followers', 'following_url': 'https://api.github.com/users/gchhablani/following{/other_user}', 'gists_url': 'https://api.github.com/users/gchhablani/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/gchhablani/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/gchhablani/subscriptions', 'organizations_url': 'https://api.github.com/users/gchhablani/orgs', 'repos_url': 'https://api.github.com/users/gchhablani/repos', 'events_url': 'https://api.github.com/users/gchhablani/events{/privacy}', 'received_events_url': 'https://api.github.com/users/gchhablani/received_events', 'type': 'User', 'site_admin': False}
[]
[]
Hi ! You can get CUDA tensors with

```python
dataset.set_format("torch", columns=columns, device="cuda")
```

Indeed `set_format` passes the `**kwargs` to `torch.tensor` Hi @lhoestq,

Thanks a lot. Is this true for all format types?

As in, for 'torch', I can have `**kwargs` to `torch.tensor` and for 'tf' those args are passed to `tf.Tensor`, and the same for 'numpy' and 'pandas'? Yes the keywords arguments are passed to the convert function like `np.array`, `torch.tensor` or `tensorflow.ragged.constant`.
We don't support the kwargs for pandas on the other hand. Thanks @lhoestq,
Would it be okay if I added this to the docs and made a PR? Sure ! Feel free to open a PR to improve the documentation :)  Closing this issue as it has been resolved.
Hi,

I came across this [link](https://huggingface.co/docs/datasets/torch_tensorflow.html) where the docs show show to convert a dataset to a particular format. I see that there is an option to convert it to tensors, but I don't see any option to convert it to CUDA tensors.

I tried this, but Dataset doesn't support assignment:
```
  columns=['input_ids', 'token_type_ids', 'attention_mask', 'start_positions','end_positions']

        samples.set_format(type='torch', columns = columns)
        for column in columns:
            samples[column].to(torch.device(self.config.device))
```
There should be an option to do so, or if there is already a way to do this, please let me know.

Thanks,
Gunjan
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/1762/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}