PSROIAlign
PSROIAlign copied to clipboard
undefined symbol problem
I wrote a custom op, and use gcc cmd to build it, it worked well. Then I try to rewirte the build script with cmake, and use your CMakeLists.txt as example, but when calling the op, it gives the undefined symbol error. It seems the op is skipped by the cmake. The following is gcc script and cmakelists. could you give some advice? gcc script
TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )
nvcc -std=c++11 -c -o resize_trilinear.cu.o resize_trilinear.cu.cc \
${TF_CFLAGS[@]} -I/usr/local \
-D GOOGLE_CUDA=1 \
-x cu -Xcompiler -fPIC -DNDEBUG --expt-relaxed-constexpr
g++ -std=c++11 -shared -o libresize_trilinear.so resize_trilinear.cc resize_trilinear.cu.o \
${TF_CFLAGS[@]} -I/usr/local/cuda/include \
${TF_LFLAGS[@]} -lcudart \
-D GOOGLE_CUDA=1 \
-fPIC -O2
CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(resize_trilinear)
set(CMAKE_CXX_STANDARD 11)
#enable_language(CUDA)
find_package(CUDA REQUIRED)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} \
-gencode arch=compute_61,code=sm_61 \
-D GOOGLE_CUDA=1 -x cu \
-Xcompiler -fPIC -DNDEBUG \
--expt-relaxed-constexpr")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-std=c++11 \
-DGOOGLE_CUDA=1 \
-fPIC -O2")
set(TF_INC /home/zoud/program/anaconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/include)
set(TF_LIB /home/zoud/program/anaconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core)
cuda_compile(RESIZE_TRILINEAR_CU_O resize_trilinear.cu.cc MODULE OPTIONS -I$TF_INC -I/usr/local)
include_directories(${TF_INC} /usr/local/cuda/include)
link_directories(${TF_LIB} /usr/local/cuda/lib64)
#add_link_options(-Wl,--no-as-needed)
#add_link_options(-Wl,--allow-multiple-definition)
add_library(resize_trilinear SHARED
${RESIZE_TRILINEAR_CU_O}
resize_trilinear.h
resize_trilinear.cc)
target_link_libraries(resize_trilinear
libtensorflow_framework.so.2
libcudart.so)