# Cannot install Faiss in Google Collab

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcannot-install-faiss-in-google-collab%2F39451%3E%5C
**Category:** 🤗Datasets\
**Created:** [May 11, 2023, 12:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcannot-install-faiss-in-google-collab%2F39451 "2023-05-11T00:07:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkoh12](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/dkoh12/32/16035_2.png) [@dkoh12](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdkoh12)%5C
**Post date:** [May 11, 2023, 12:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcannot-install-faiss-in-google-collab%2F39451%2F1 "2023-05-11T00:07:41Z")

</div>

Has anyone gotten FAISS index to work in Google Collab (free version)?

I tried following the example mentioned in the doc.

> **[Search index](https://huggingface.co/docs/datasets/v1.13.0/faiss_es.html)**
>
> FAISS and ElasticSearch enables searching for examples in a dataset. This can be useful when you want to retrieve specific examples from a dataset that are r...

However it throws an error at `add_faiss_index()` method saying you must install Faiss to use FaissIndex. This is despite the fact that I do

```auto
!pip install faiss-cpu
!pip install faiss-gpu

```

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmariosasko)%5C
**Post date:** [May 11, 2023, 5:09pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcannot-install-faiss-in-google-collab%2F39451%2F2 "2023-05-11T17:09:25Z")

</div>

You can find the solution to this issue in the [Discord thread](https://discord.com/channels/879548962464493619/1106008166422028319/1106008166422028319).

---

<div class="post-metadata">

**Author:** ![marcoespinoza](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/marcoespinoza/32/39666_2.png) [@marcoespinoza](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmarcoespinoza)%5C
**Post date:** [January 23, 2025, 5:44pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcannot-install-faiss-in-google-collab%2F39451%2F3 "2025-01-23T17:44:37Z")

</div>

Were you able able to find a solution? I am encountering the same issue but in Snowflake. I have tried to follow the Discord threat but it seems it has been deleted.

---

<div class="post-metadata">

**Author:** ![GabrielPereiraIPCB](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/gabrielpereiraipcb/32/39682_2.png) [@GabrielPereiraIPCB](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FGabrielPereiraIPCB)%5C
**Post date:** [January 23, 2025, 10:28pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcannot-install-faiss-in-google-collab%2F39451%2F4 "2025-01-23T22:28:05Z")

</div>

I am getting the same problems. I do `!pip install faiss-gpu` and it gives me a message error. I ignore it and run the code and it actually works. Later I try to run again and it doesn’t and have this issue with faiss.

Trying to fix it but so far nothing

---

<div class="post-metadata">

**Author:** ![marcoespinoza](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/marcoespinoza/32/39666_2.png) [@marcoespinoza](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmarcoespinoza)%5C
**Post date:** [January 24, 2025, 12:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcannot-install-faiss-in-google-collab%2F39451%2F5 "2025-01-24T12:52:30Z")

</div>

I found the solution. The following code should fix it.

```auto
!apt install -y libomp-dev
!python -m pip install --upgrade faiss-gpu

```

---

<div class="post-metadata">

**Author:** ![dzungever](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dzungever](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdzungever)%5C
**Post date:** [June 10, 2025, 3:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcannot-install-faiss-in-google-collab%2F39451%2F6 "2025-06-10T15:05:39Z")

</div>

I used this command and it works.

```auto
!pip install faiss-gpu-cu11==1.10.0

```

---

<div class="post-metadata">

**Author:** ![oguzinc](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/oguzinc/32/56980_2.png) [@oguzinc](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Foguzinc)%5C
**Post date:** [December 31, 2025, 1:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcannot-install-faiss-in-google-collab%2F39451%2F7 "2025-12-31T13:16:44Z")

</div>

```auto
!pip install faiss-gpu-cu12

```

This does work for me too. Depending on your cuda version you might need to install faiss-gpu-cu12. You can check your cuda version:

```auto
import torch
print(torch.version.cuda)

```

Another thing to note, I got an error when I imported datasets library and then installed faiss, maybe somethings are cached. It’s better to do the installation first and then import all your libraries.
