Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding custom op instructions lacking the GPU building instructions #22554

Closed
panfengli opened this issue Sep 27, 2018 · 3 comments
Closed

Adding custom op instructions lacking the GPU building instructions #22554

panfengli opened this issue Sep 27, 2018 · 3 comments
Assignees
Labels
type:docs-bug Document issues

Comments

@panfengli
Copy link

panfengli commented Sep 27, 2018

Tensorflow Add a new op tutorial never mention the building instructions for GPU ops.

I find one here, but it met the similar issue with Building custom op instructions out of date .
tensorflow.python.framework.errors_impl.NotFoundError: ./libcuda_op.so: undefined symbol: _ZTIN10tensorflow8OpKernelE

Tensorflow really needs to give some suggestions on how to build GPU ops.

@panfengli
Copy link
Author

panfengli commented Sep 27, 2018

The one from the above link:

cmake_minimum_required(VERSION 3.5)

set(CMAKE_C_COMPILER /opt/cuda/bin/gcc)
set(CMAKE_CXX_COMPILER /opt/cuda/bin/g++)

execute_process(COMMAND python3 -c "import tensorflow; print(tensorflow.sysconfig.get_include())" OUTPUT_VARIABLE Tensorflow_INCLUDE_DIRS)

find_package(CUDA)

set(CMAKE_CXX_FLAGS "-std=c++11 -O2 ${CMAKE_CXX_FLAGS}")

if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 5.0)
  set(CMAKE_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 ${CMAKE_CXX_FLAGS}")
endif()

SET(CUDA_PROPAGATE_HOST_FLAGS ON)

include_directories(${Tensorflow_INCLUDE_DIRS})

cuda_add_library(
    add_one SHARED
    cuda_op_kernel.cu
add_one.cc)

Currently Tensorflow only provides instructions for CPU ops as:

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()))') )
g++ -std=c++11 -shared zero_out.cc -o zero_out.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2

@ppwwyyxx
Copy link
Contributor

The tutorial does mention the build instructions for GPU ops: https://www.tensorflow.org/extend/adding_an_op#gpu_support

@ymodak ymodak added the type:docs-bug Document issues label Sep 27, 2018
@panfengli
Copy link
Author

Thanks! @ppwwyyxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:docs-bug Document issues
Projects
None yet
Development

No branches or pull requests

3 participants