Skip to content

Commit

Permalink
Compress CUDA device code in libfaiss.so (#2091)
Browse files Browse the repository at this point in the history
Summary:
Pass `-Xfatbin=-compress-all` to `nvcc` so device code is compressed when embedded in `libfaiss.so`.

In our testing[[1]](https://github.com/rapidsai/cudf/pull/7583)[[2]](https://gist.githubusercontent.com/robertmaynard/2cfb4ba27afcd7e52b2deccce3b78c29/raw/0a0d3b48e82ab26c2dac5af00e428333e852b8a5/results.txt), compressing device code has negligible (or no) impact on compile, load, or run times, but significantly reduces the library size on disk:

```bash
# cmake -GNinja -B build -S . \
#  -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF \
#  -DFAISS_ENABLE_GPU=ON -DFAISS_ENABLE_PYTHON=OFF \
#  -DCMAKE_CUDA_ARCHITECTURES="60-real;70-real;75-real;80-real;86"

# v1.7.0:
$ du -Shc build/faiss/libfaiss.so
318M	build/faiss/libfaiss.so

# this PR:
$ du -Shc build/faiss/libfaiss.so
160M	build/faiss/libfaiss.so
```

Pull Request resolved: #2091

Reviewed By: mdouze

Differential Revision: D32597803

Pulled By: wickedfoo

fbshipit-source-id: a2adb43aea0fa24a9581abe14a7d90a6e98523ce
  • Loading branch information
trxcllnt authored and facebook-github-bot committed Nov 22, 2021
1 parent b598f55 commit fbf6b4a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions faiss/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,5 @@ endforeach()
find_package(CUDAToolkit REQUIRED)
target_link_libraries(faiss PRIVATE CUDA::cudart CUDA::cublas)
target_link_libraries(faiss_avx2 PRIVATE CUDA::cudart CUDA::cublas)
target_compile_options(faiss PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-Xfatbin=-compress-all>)
target_compile_options(faiss_avx2 PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-Xfatbin=-compress-all>)

0 comments on commit fbf6b4a

Please sign in to comment.