Tensorflow serving custom gpu op cannot find dependency when compiling

十年热恋 提交于 2021-02-10 22:18:09

问题


I fallowed the guides on making custom gpu op for tensorflow and could make shared lib. For tensorflow-serving I adapted required paths but I get error when building:

   ERROR: /home/g360/Documents/eduardss/serving/tensorflow_serving/custom_ops/CUSTOM_OP/BUILD:32:1: undeclared inclusion(s) in rule '//tensorflow_serving/custom_ops/CUSTOM_OP:CUSTOM_OP_ops_gpu':
this rule is missing dependency declarations for the following files included by 'tensorflow_serving/custom_ops/CUSTOM_OP/cc/magic_op.cu.cc':
  'external/org_tensorflow/tensorflow/core/platform/stream_executor.h'
  'external/org_tensorflow/tensorflow/stream_executor/cuda/cuda_platform_id.h'
  'external/org_tensorflow/tensorflow/stream_executor/platform.h'
  'external/org_tensorflow/tensorflow/stream_executor/device_description.h'
  'external/org_tensorflow/tensorflow/stream_executor/launch_dim.h'
  'external/org_tensorflow/tensorflow/stream_executor/platform/port.h'
  'external/org_tensorflow/tensorflow/stream_executor/device_options.h'
  'external/org_tensorflow/tensorflow/stream_executor/platform/logging.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/status.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/error.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/status_macros.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/statusor.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/statusor_internals.h'
  'external/org_tensorflow/tensorflow/stream_executor/plugin.h'
  'external/org_tensorflow/tensorflow/stream_executor/trace_listener.h'
  'external/org_tensorflow/tensorflow/stream_executor/device_memory.h'
  'external/org_tensorflow/tensorflow/stream_executor/kernel.h'
  'external/org_tensorflow/tensorflow/stream_executor/kernel_cache_config.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/array_slice.h'
  'external/org_tensorflow/tensorflow/stream_executor/dnn.h'
  'external/org_tensorflow/tensorflow/stream_executor/event.h'
  'external/org_tensorflow/tensorflow/stream_executor/host/host_platform_id.h'
  'external/org_tensorflow/tensorflow/stream_executor/multi_platform_manager.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/initialize.h'
  'external/org_tensorflow/tensorflow/stream_executor/platform/initialize.h'
  'external/org_tensorflow/tensorflow/stream_executor/platform/platform.h'
  'external/org_tensorflow/tensorflow/stream_executor/platform/default/initialize.h'
  'external/org_tensorflow/tensorflow/stream_executor/platform/dso_loader.h'
  'external/org_tensorflow/tensorflow/stream_executor/platform/default/dso_loader.h'
  'external/org_tensorflow/tensorflow/stream_executor/rocm/rocm_platform_id.h'
  'external/org_tensorflow/tensorflow/stream_executor/scratch_allocator.h'
  'external/org_tensorflow/tensorflow/stream_executor/temporary_device_memory.h'
  'external/org_tensorflow/tensorflow/stream_executor/stream.h'
  'external/org_tensorflow/tensorflow/stream_executor/blas.h'
  'external/org_tensorflow/tensorflow/stream_executor/host_or_device_scalar.h'
  'external/org_tensorflow/tensorflow/stream_executor/fft.h'
  'external/org_tensorflow/tensorflow/stream_executor/platform/thread_annotations.h'
  'external/org_tensorflow/tensorflow/stream_executor/temporary_memory_manager.h'
  'external/org_tensorflow/tensorflow/stream_executor/stream_executor.h'
  'external/org_tensorflow/tensorflow/stream_executor/kernel_spec.h'
  'external/org_tensorflow/tensorflow/stream_executor/stream_executor_pimpl.h'
  'external/org_tensorflow/tensorflow/stream_executor/device_memory_allocator.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/threadpool.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/env.h'
  'external/org_tensorflow/tensorflow/stream_executor/lib/thread_options.h'
  'external/org_tensorflow/tensorflow/stream_executor/rng.h'
  'external/org_tensorflow/tensorflow/stream_executor/shared_memory_config.h'
  'external/org_tensorflow/tensorflow/stream_executor/stream_executor_internal.h'
  'external/org_tensorflow/tensorflow/stream_executor/allocator_stats.h'
  'external/org_tensorflow/tensorflow/stream_executor/module_spec.h'
  'external/org_tensorflow/tensorflow/stream_executor/plugin_registry.h'
  'external/org_tensorflow/tensorflow/stream_executor/timer.h'

The function in question imports:

#if GOOGLE_CUDA

#define EIGEN_USE_GPU

#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/util/gpu_kernel_helper.h"

#include "math.h"

#include <iostream>

Of these dependencies I think gpu_kernel_helper.h is the one causing error as my BUILD file dependencies are:

    deps = [
    "@org_tensorflow//tensorflow/core:framework",
    "@org_tensorflow//tensorflow/core:lib",
    "@org_tensorflow//third_party/eigen3",
] + if_cuda_is_configured([":cuda",  "@local_config_cuda//cuda:cuda_headers"]),

If I try to import them directly it bazels complains that there is no BUILD file on path. I'm not really familiar with bazel build process so don't understand exactly how it needs to link imports.

EDIT 1 I used tensorflow-serving 2.1.0 and tensorflow/serving:2.1.0-devel-gpu docker image. Looking in @org_tensorflow/tensorflow/core/BUILD there is actually some reference to 'gpu_kernel_helper.h':

tf_cuda_library(
name = "framework",
hdrs = [
       ...
       "util/gpu_kernel_helper.h",
       ]

But apparently some futher downstream links are missing?


回答1:


Solution: The missing dependency can be linked in with:

"@org_tensorflow//tensorflow/core:stream_executor_headers_lib"


来源:https://stackoverflow.com/questions/60374967/tensorflow-serving-custom-gpu-op-cannot-find-dependency-when-compiling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!