Следующий код относится к моему файлу CMakeList, и он может хорошо работать на CUDA 9.2 Ubuntu 14. Однако, когда я пытаюсь запустить его на нашем новом сервере, я получаю сообщение об ошибке.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -std=c++11")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
cmake_minimum_required(VERSION 3.0)
project(LMM)
set(DYLD_LIBRARY_PATH /usr/local/include)
find_package(GSL REQUIRED)
find_package(BLAS REQUIRED)
find_package(CUDA)
if (CUDA_FOUND)
message("CUDA found")
else()
message("CUDA not found, doing something alternatively")
endif()
include_directories(test_cuda PRIVARE
${GSL_INCLUDE_DIRS}
${BLAS_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
${CUDA_CUBLAS_DIRS}
${PROJECT_SOURCE_DIR})
add_executable(GPU_LMM main.cpp aux.cpp)
target_link_libraries( GPU_LMM PRIVATE
${GSL_LIBRARY}
${BLAS_LIBRARIES}
${CUDA_LIBRARIES})
Информация журнала выглядит следующим образом.
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Found GSL: /usr/include (found version "2.4")
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- A library with BLAS API found.
-- Found CUDA: /usr/local/cuda (found version "10.0")
CUDA found
-- Configuring done
-- Generating done
Однако, когда я запускаю свою программу, я получаю следующее сообщение об ошибке.
aux.cpp:(.text+0x28d1): undefined reference to `cublasSetVector'
aux.cpp:(.text+0x290e): undefined reference to `cublasSetMatrix'
aux.cpp:(.text+0x2942): undefined reference to `cublasSetMatrix'
aux.cpp:(.text+0x2994): undefined reference to `cublasSgemv_v2'
aux.cpp:(.text+0x29e0): undefined reference to `cublasSgemv_v2'
aux.cpp:(.text+0x2a32): undefined reference to `cublasSgemv_v2'
aux.cpp:(.text+0x2a6c): undefined reference to `cublasSaxpy_v2'
aux.cpp:(.text+0x2b4a): undefined reference to `cublasSetMatrix'
aux.cpp:(.text+0x2bed): undefined reference to `cublasSgemv_v2'
aux.cpp:(.text+0x2c3c): undefined reference to `cublasSgemv_v2'
aux.cpp:(.text+0x2c7c): undefined reference to `cublasScopy_v2'
aux.cpp:(.text+0x2cb4): undefined reference to `cublasSaxpy_v2'
aux.cpp:(.text+0x2d1e): undefined reference to `cublasSgemv_v2'
aux.cpp:(.text+0x2d6a): undefined reference to `cublasSgemv_v2'
aux.cpp:(.text+0x2dbc): undefined reference to `cublasSgemv_v2'
aux.cpp:(.text+0x2df6): undefined reference to `cublasSaxpy_v2'
aux.cpp:(.text+0x2e25): undefined reference to `cublasGetVector'
aux.cpp:(.text+0x2e50): undefined reference to `cublasGetVector'
Я удостоверяюсь, что я установил Cublas на сервер, потому что я могу воспроизвести официальную демонстрацию Cublas. Когда я добавляю CUDA_CUBLAS_LIBRARIES
, я получаю следующую ошибку.
-- A library with BLAS API found.
CUDA found
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_cublas_device_LIBRARY (ADVANCED)
linked by target "GPU_LMM" in directory /home/szhangcj/C++/LMM
-- Configuring incomplete, errors occurred!