Bazel使用tensorflow和cuda创建.so文件的错误 [英] Bazel Errors on creating .so file with tensorflow and cuda
问题描述
我可以创建一个.so文件与tensorflow / bazel,但没有cuda。如果我尝试bazel build -c opts --config = cuda:lib.so我得到一个未定义的引用main(..)。有没有办法摆脱引用main(...)的错误?
这是我的BUILD文件
cc_binary(
name =lib.so,
srcs = [
lib.cc,
jni.h,
jni_md.h,
lib.h,
jni_utils.h,jni_utils.cc
]
copts = tf_copts(),
linkopts = [-shared],
deps = [
// tensorflow / core:tensorflow,
// tensorflow / core:framework,
// tensorflow / cc:cc_ops,
// tensorflow / core:all_kernels $ b@opencv //:opencv
],
)
遇到这些错误:
失败:crosstool_wrapper_driver_is_not_gcc失败:执行错误命令
(.text + 0x20)原因是你只需要设置linkshared = 1即可,因为我们需要设置linkshared = 1,否则返回false。到BUILD上
cc_binary(
name =lib.so,
srcs = [
lib.cc,
jni.h,
jni_md.h,
lib.h,
jni_utils.h,jni_utils .cc
],
copts = tf_copts(),
linkshared = 1,
deps =
// tensorflow / core:tensorflow,
// tensorflow / core:framework,
// tensorflow / cc:cc_ops,
/ core:all_kernels,
@opencv //:opencv
],
)
$ b b
Im able to create a .so file with tensorflow / bazel but without cuda. If i try bazel build -c opts --config=cuda :lib.so i get an undefined reference to main(..). Would there be a way to get rid of the errors referring to main (...) ?
Here is my BUILD file
cc_binary(
name = "lib.so",
srcs = [
"lib.cc",
"jni.h",
"jni_md.h",
"lib.h",
"jni_utils.h", "jni_utils.cc"
],
copts = tf_copts(),
linkopts = ["-shared"],
deps = [
"//tensorflow/core:tensorflow",
"//tensorflow/core:framework",
"//tensorflow/cc:cc_ops",
"//tensorflow/core:all_kernels",
"@opencv//:opencv"
],
)
Im getting these errors:
failed: crosstool_wrapper_driver_is_not_gcc failed: error executing command (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status
Turns out you just need to set linkshared = 1 onto the BUILD
cc_binary(
name = "lib.so",
srcs = [
"lib.cc",
"jni.h",
"jni_md.h",
"lib.h",
"jni_utils.h", "jni_utils.cc"
],
copts = tf_copts(),
linkshared = 1,
deps = [
"//tensorflow/core:tensorflow",
"//tensorflow/core:framework",
"//tensorflow/cc:cc_ops",
"//tensorflow/core:all_kernels",
"@opencv//:opencv"
],
)
这篇关于Bazel使用tensorflow和cuda创建.so文件的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!