Commit 45cdaf3c authored by jerem's avatar jerem Committed by jeremad

fix openCL and CUDA from ubuntu

parent a3d5481f
......@@ -31,20 +31,19 @@ if (WINDOWS)
find_library(NVML nvml PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" NO_DEFAULT_PATH)
endif(WINDOWS)
if (LINUX)
if(LINUX)
set(CUDA_PROPAGATE_HOST_FLAGS "FALSE")
if(TEGRA_DEMO)
set(LINUX_CUDA_PATH ${CUDA_TOOLKIT_TARGET_DIR}/lib)
find_library(GLEW_LIBRARIES GLEW NO_CMAKE_FIND_ROOT_PATH)
find_library(OPENGL_LIBRARIES GL NO_CMAKE_FIND_ROOT_PATH)
else(TEGRA_DEMO)
else()
find_package(GLEW)
find_library(CUDA cuda PATHS "${LINUX_CUDA_PATH}/stubs")
find_library(CUDART cudart PATHS ${LINUX_CUDA_PATH})
find_library(NVML nvidia-ml PATHS "${LINUX_CUDA_PATH}/stubs")
endif(TEGRA_DEMO)
endif()
include_directories(${CMAKE_EXTERNAL_DEPS}/include)
link_directories(${LINUX_CUDA_PATH})
find_library(CUVID nvcuvid)
endif(LINUX)
......
......@@ -50,19 +50,16 @@ include_discovery_vs_headers(${VS_DISCOVERY})
if(NOT ANDROID)
find_package(OpenCL)
endif (NOT ANDROID)
if(OpenCL_FOUND)
endif()
if(OpenCL_FOUND AND GPU_BACKEND_OPENCL)
target_include_directories(${VS_DISCOVERY} PRIVATE ${OpenCL_INCLUDE_DIRS})
target_link_libraries(${VS_DISCOVERY} PUBLIC ${OpenCL_LIBRARY})
# different names on different implementations of find_package(OpenCL)
set(PLATFORM_INDEPENDENT_OPENCL_LIBS ${OpenCL_LIBRARIES} ${OPENCL_LIBRARIES})
target_link_libraries(${VS_DISCOVERY} PRIVATE ${PLATFORM_INDEPENDENT_OPENCL_LIBS})
if(MSVC)
target_link_libraries(${VS_DISCOVERY} PUBLIC ${OpenCL_LIBRARIES})
if(WINDOWS)
target_link_libraries(${VS_DISCOVERY} PRIVATE "DelayImp.lib")
set_target_properties(${VS_DISCOVERY} PROPERTIES LINK_FLAGS "/DELAYLOAD:OpenCL.dll")
endif(MSVC)
endif()
target_compile_definitions(${VS_DISCOVERY} PRIVATE OPENCL_FOUND)
endif(OpenCL_FOUND)
endif()
# ----------------------------------------------------------------------------
# CUDA
......@@ -71,7 +68,7 @@ endif(OpenCL_FOUND)
if(NOT CUDA_FOUND)
include (${CMAKE_SOURCE_DIR}/cmake/getCuda.cmake)
endif (NOT CUDA_FOUND)
if (CUDA_FOUND)
if(CUDA_FOUND)
target_include_directories(${VS_DISCOVERY} PRIVATE ${CUDA_INCLUDE_DIRS})
target_link_libraries(${VS_DISCOVERY} PRIVATE ${CUDA_LIBRARIES})
target_compile_definitions(${VS_DISCOVERY} PRIVATE CUDA_FOUND)
......@@ -136,4 +133,3 @@ if(STAGING)
else()
add_test(NAME ${DEVICE_NAME_TEST} COMMAND ${DEVICE_NAME_TEST})
endif()
......@@ -58,11 +58,15 @@ sudo apt install
libturbojpeg0-dev \
libx264-dev \
ninja-build \
ocl-icd-opencl-dev \
opencl-headers \
portaudio19-dev \
qt5-default \
qtmultimedia5-dev \
qttools5-dev \
swig
swig \
wget \
xxd
# Set up gcc-6 and g++-6 as your compiler
sudo apt-get install gcc-6 g++-6
......
......@@ -5,6 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y \
bison \
ccache \
clang \
doxygen \
flex \
git \
......@@ -22,13 +23,16 @@ RUN apt update && apt install -y \
librtmp-dev \
libx264-dev \
ninja-build \
ocl-icd-opencl-dev \
opencl-headers \
portaudio19-dev \
python-pip \
qt5-default \
qtmultimedia5-dev \
qttools5-dev \
swig \
wget
wget \
xxd
RUN pip install cmake
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
RUN apt-key add 7fa2af80.pub
......
......@@ -5,5 +5,5 @@ ADD . stitchEm
WORKDIR stitchEm
RUN echo ${CUDA_SHORT} > cuda.version
WORKDIR build
RUN cmake -DCMAKE_BUILD_TYPE=Release -DRTMP_NVENC=OFF -DCUDA_TARGET_ARCH="50" -G Ninja ..
RUN cmake -DCMAKE_BUILD_TYPE=Release -DRTMP_NVENC=OFF -DCUDA_TARGET_ARCH="50" -DGPU_BACKEND_CUDA=ON -DGPU_BACKEND_OPENCL=OFF -DDISABLE_OPENCL_SPIR=ON -G Ninja ..
CMD ninja
......@@ -148,9 +148,9 @@ if(ANDROID)
vs_lib_link_libraries("CUDA" ${GLEW} log)
message(STATUS "CUDA_LIBRARIES = ${CUDA_LIBRARIES}")
else()
vs_lib_link_libraries("PUBLIC_CUDA" ${CUDART} ${CUDA_LIBRARIES} ${NVTX})
vs_lib_link_libraries("CUDA" ${CUDART} ${NVTX})
vs_lib_link_libraries("CUDA" ${OpenGL} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLEW})
vs_lib_link_libraries("PUBLIC_CUDA" ${NVML})
vs_lib_link_libraries("PUBLIC_CUDA" ${NVML} ${CUDA_LIBRARIES})
if(CMAKE_CROSSCOMPILING)
# needed by ceres
vs_lib_link_libraries("CUDA" -fopenmp)
......@@ -161,5 +161,5 @@ else()
else()
vs_lib_link_libraries("PUBLIC_CUDA" ${CUDA})
endif()
endif(ANDROID)
endif()
option(DISABLE_OPENCL_SPIR "Skip OpenCL offline compilation and ship kernel sources")
option(CL_ARGS_WORKAROUND "Redefining functions to support OpenCL limitation in parameters format")
if(DISABLE_OPENCL_SPIR)
message(WARNING "Careful: OpenCL offline compilation disabled. Binary will contain all OpenCL kernel sources as plain text!")
else(DISABLE_OPENCL_SPIR)
if(NOT DISABLE_OPENCL_SPIR)
if (LINUX OR ANDROID)
message("No Alternative OpenCL SPIR compiler for Linux")
else(LINUX OR ANDROID)
else()
option(ALTERNATIVE_OPENCL_SPIR "GENERATE an alternative SPIR that will be used if something goes wrong with the main SPIR" ON)
endif(LINUX OR ANDROID)
endif(DISABLE_OPENCL_SPIR)
endif()
endif()
set(CL_BACKEND_SOURCES
src/backend/cl/bilateral/bilateral.cpp
......@@ -92,7 +90,6 @@ add_cppcheck(${VS_LIB_OBJECTS_OPENCL} VS)
# Add compile definitions
# ----------------------------------------------------------------------------
if(DISABLE_OPENCL_SPIR)
message(WARNING "Careful: OpenCL offline compilation disabled. Binary will contain all OpenCL kernel sources as plain text!")
target_compile_definitions(${VS_LIB_OBJECTS_OPENCL} PRIVATE "DISABLE_OPENCL_SPIR")
endif()
if(CL_ARGS_WORKAROUND)
......
......@@ -47,7 +47,7 @@ set(VS_LIB_ROOT_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
if(APPLE)
find_program(OPENCL_OFFLINE_COMPILER openclc
PATHS ${OpenCL_LIBRARY}/Libraries/
PATHS ${OpenCL_LIBRARIES}/Libraries/
/System/Library/Frameworks/OpenCL.framework/Libraries
DOC "OpenCL offline compiler to build spir files from kernel sources")
if (ALTERNATIVE_OPENCL_SPIR)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment