Error "in void don't know how to serialize this type of index" when saving index to disk when device=0 (GPU)
{'login': 'corticalstack', 'id': 3995321, 'node_id': 'MDQ6VXNlcjM5OTUzMjE=', 'avatar_url': 'https://avatars.githubusercontent.com/u/3995321?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/corticalstack', 'html_url': 'https://github.com/corticalstack', 'followers_url': 'https://api.github.com/users/corticalstack/followers', 'following_url': 'https://api.github.com/users/corticalstack/following{/other_user}', 'gists_url': 'https://api.github.com/users/corticalstack/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/corticalstack/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/corticalstack/subscriptions', 'organizations_url': 'https://api.github.com/users/corticalstack/orgs', 'repos_url': 'https://api.github.com/users/corticalstack/repos', 'events_url': 'https://api.github.com/users/corticalstack/events{/privacy}', 'received_events_url': 'https://api.github.com/users/corticalstack/received_events', 'type': 'User', 'site_admin': False}
[]
[]
Hi @corticalstack ! Thanks for reporting. Indeed in the recent versions of Faiss we must use `getDevice` to check if the index in on GPU.

I'm opening a PR I fixed this issue. It should work fine now.
Feel free to try it out by installing `datasets` from source.
Otherwise you can wait for the next release of `datasets` (in a few days) Thanks for such a quick fix and merge to master, pip installed git master, tested all OK
Error serializing faiss index.  Error as follows:

`Error in void faiss::write_index(const faiss::Index*, faiss::IOWriter*) at /home/conda/feedstock_root/build_artifacts/faiss-split_1612472484670/work/faiss/impl/index_write.cpp:453: don't know how to serialize this type of index`


Note:

`torch.cuda.is_available()` reports:

```
Cuda is available
cuda:0

```

Adding index, device=0 for GPU.

`dataset.add_faiss_index(column='embeddings', index_name='idx_embeddings', device=0)`

However, during a quick debug, self.faiss_index has no attr "device" when checked in` search.py, method save`, so fails to transform gpu index to cpu index.  If I add index without device, index is saved OK.


```
def save(self, file: str):
        """Serialize the FaissIndex on disk"""
        import faiss  # noqa: F811

        if (
            hasattr(self.faiss_index, "device")
            and self.faiss_index.device is not None
            and self.faiss_index.device > -1
        ):
            index = faiss.index_gpu_to_cpu(self.faiss_index)
        else:
            index = self.faiss_index
        faiss.write_index(index, file)
```

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