Skip to content

Commit

Permalink
Try building precompiled binaries for GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
milot-mirdita committed Nov 15, 2024
1 parent b63668c commit 73a8127
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ set(USE_SYSTEM_ZSTD 0 CACHE BOOL "Use zstd provided by system instead of bundled

set(ENABLE_CUDA 0 CACHE BOOL "Enable CUDA")

set(PREFER_STATIC 0 CACHE BOOL "Prefer finding .a libs")
if (PREFER_STATIC)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so")
endif()

if (HAVE_SANITIZER)
include(FindUBSan)
include(FindASan)
Expand Down
45 changes: 45 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,38 @@ jobs:
targetPath: $(Build.SourcesDirectory)/build/src/mmseqs
artifactName: mmseqs-linux-$(SIMD)

- job: build_ubuntu_gpu
displayName: Ubuntu MMseqs2
pool:
vmImage: 'Ubuntu-20.04'
timeoutInMinutes: 120
steps:
- checkout: self
submodules: false
- script: |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get install -y gcc-10 g++-10 cuda-nvcc-12-6 build-essential libgcc-10-dev ninja-build
sudo apt-get purge -y cmake
wget https://github.com/Kitware/CMake/releases/download/v3.31.0/cmake-3.31.0-linux-x86_64.sh
chmod +x cmake-3.31.0-linux-x86_64.sh
sudo ./cmake-3.31.0-linux-x86_64.sh --skip-license --prefix=/usr/local
displayName: Install newer G++
- script: |
mkdir build && cd build
export CC=gcc-10 ; export CXX=g++-10; export CUDAHOSTCXX=$CXX; export CUDACXX=/usr/local/cuda/bin/nvcc;
/usr/local/bin/cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DHAVE_TESTS=1 -DENABLE_WERROR=1 -DHAVE_AVX2=1 \
-PREFER_STATIC=1 -DCMAKE_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10 -DBUILD_SHARED_LIBS=OFF \
-DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" \
-DENABLE_CUDA=1 -DCMAKE_CUDA_ARCHITECTURES="75-real;80-real;86-real;89-real;90" ..
cmake --build . -j$(nproc --all)
displayName: Build MMseqs2
- task: PublishPipelineArtifact@0
inputs:
targetPath: $(Build.SourcesDirectory)/build/src/mmseqs
artifactName: mmseqs-linux-gpu

- job: build_ubuntu_cross
displayName: Ubuntu Cross-Compile
pool:
Expand Down Expand Up @@ -252,6 +284,7 @@ jobs:
- build_ubuntu_userguide
- build_macos
- build_ubuntu
- build_ubuntu_gpu
- build_ubuntu_cross
- build_windows
steps:
Expand Down Expand Up @@ -317,6 +350,18 @@ jobs:
archiveFile: $(Build.SourcesDirectory)/mmseqs-linux-sse2.tar.gz
includeRootFolder: true
archiveType: tar
- task: DownloadPipelineArtifact@1
inputs:
artifactName: mmseqs-linux-gpu
targetPath: $(Build.SourcesDirectory)/mmseqs/bin
- script:
chmod +x "${BUILD_SOURCESDIRECTORY}/mmseqs/bin/mmseqs"
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(Build.SourcesDirectory)/mmseqs
archiveFile: $(Build.SourcesDirectory)/mmseqs-linux-cuda12-libc.tar.gz
includeRootFolder: true
archiveType: tar
- task: DownloadPipelineArtifact@1
inputs:
artifactName: mmseqs-linux-POWER9
Expand Down
16 changes: 14 additions & 2 deletions cmake/FindAtomic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ if (ATOMIC_NATIVE)
set(ATOMIC_LIBRARY)
else ()
set(_OLD_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
set(CMAKE_REQUIRED_LIBRARIES "-latomic")
find_library(ATOMIC_LIBRARY_PATH
NAMES atomic
)

if (ATOMIC_LIBRARY_PATH)
set(ATOMIC_LIBRARY ${ATOMIC_LIBRARY_PATH})
else ()
set(ATOMIC_LIBRARY "-latomic")
endif ()

set(CMAKE_REQUIRED_LIBRARIES "${ATOMIC_LIBRARY}")
check_cxx_source_compiles("
int main() {
volatile unsigned __int128 i = 4;
Expand All @@ -32,7 +42,9 @@ else ()
unset(_OLD_CMAKE_REQUIRED_LIBRARIES)
if (ATOMIC_WITH_LIB)
set(ATOMIC_FOUND 1)
set(ATOMIC_LIBRARY -latomic)
else ()
set(ATOMIC_FOUND 0)
unset(ATOMIC_LIBRARY)
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Atomic DEFAULT_MSG ATOMIC_LIBRARY)
Expand Down
20 changes: 15 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,22 @@ find_package(OpenMP QUIET)
if (OPENMP_FOUND)
message("-- Found OpenMP")
target_compile_definitions(mmseqs-framework PUBLIC -DOPENMP=1)
# For GCC we dont want to do this since it breaks macOS static builds
# It will link libgomp.a internally (through -fopenmp I guess)
# and also link libgomp.dylib thus breaking static builds
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Try to get "nearly" static builds working with everything except libc static
if (PREFER_STATIC)
set(FILTERED_LIBRARIES "")
foreach(LIB ${OpenMP_CXX_LIBRARIES})
if (NOT LIB MATCHES "pthread")
list(APPEND FILTERED_LIBRARIES ${LIB})
endif ()
endforeach()
set(OpenMP_CXX_LIBRARIES ${FILTERED_LIBRARIES})
endif ()
if (NOT APPLE)
target_link_libraries(mmseqs-framework ${OpenMP_CXX_LIBRARIES})
endif()
endif ()
if (PREFER_STATIC)
target_link_libraries(mmseqs-framework dl)
endif ()
target_include_directories(mmseqs-framework PUBLIC ${OpenMP_CXX_INCLUDE_DIRS})
append_target_property(mmseqs-framework COMPILE_FLAGS ${OpenMP_CXX_FLAGS})
append_target_property(mmseqs-framework LINK_FLAGS ${OpenMP_CXX_FLAGS})
Expand Down

0 comments on commit 73a8127

Please sign in to comment.