# Cmake variables error when installing faiss-gpu

**URL:** https://discourse.cmake.org/t/cmake-variables-error-when-installing-faiss-gpu/8495
**Category:** Usage
**Created:** [July 11, 2023, 4:30pm UTC](https://discourse.cmake.org/t/cmake-variables-error-when-installing-faiss-gpu/8495 "2023-07-11T16:30:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jcruz13](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/13edae/32.png) [@jcruz13](https://discourse.cmake.org/u/jcruz13)
#### Post date: [July 11, 2023, 4:30pm UTC](https://discourse.cmake.org/t/cmake-variables-error-when-installing-faiss-gpu/8495/1 "2023-07-11T16:30:42Z")

</div>

I’m order to install faiss-gpu, I first needed to install cmake and did it by cloning the cmake repo from [GitHub - Kitware/CMake: Mirror of CMake upstream repository](http://github.com/Kitware/CMake) and running

`./bootstrap && make && make install`

Then to install faiss-gpu I cloned the following repo [GitHub - facebookresearch/faiss: A library for efficient similarity search and clustering of dense vectors.](http://guthub.com/facebookresearch/faiss) Once cloned I changed directory into that folder and ran the following:

`cmake -B build . && make -C -j faiss`

But I get multiple errors related to environment variables not set such as:

```auto
CMake Error at /usr/local/share/cmake-3.27/Modules/CMakeDetermineCUDACompiler.cmake:603 (message):
  Failed to detect a default CUDA architecture.
 
 
 
  Compiler output:
 
Call Stack (most recent call first):
  CMakeLists.txt:62 (enable_language)
 
 
-- Configuring incomplete, errors occurred!
 

```

After doing some research I found this as a possible solution, so I did the following:

```auto
cmake . -DCMAKE_CUDA_ARCHITECTURES=52 61 -DTARGET_NAME=tgt

```

Then the next error is that there is a missing variable: \_CMAKE\_CUDA\_WHOLE\_FLAG

Read above as described in detail.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 17, 2023, 11:58pm UTC](https://discourse.cmake.org/t/cmake-variables-error-when-installing-faiss-gpu/8495/2 "2023-07-17T23:58:56Z")

</div>

Cc: @robert.maynard

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [July 18, 2023, 7:41pm UTC](https://discourse.cmake.org/t/cmake-variables-error-when-installing-faiss-gpu/8495/3 "2023-07-18T19:41:53Z")

</div>

Delete your build directory, and explicitly specify that you wish to use `nvcc` as your CUDA compiler. CMake is trying to use `clang` as the CUDA compiler and failing.

This would roughly look like:

```auto
CUDACXX=/path/to/nvcc cmake -S <faiss-gpu/src/dir> -B <faiss-gpu/build/dir>

```
