ubuntu - CMake find_library 找不到 TensorFlow 库

标签 ubuntu tensorflow cmake

我的 CMakeLists.txt 包含以下行:

execute_process(COMMAND "python" "-c" "import tensorflow as tf; print tf.sysconfig.get_lib()" OUTPUT_VARIABLE TF_LIB_DIR)

find_library(TF_LIB 
    NAMES tensorflow_framework 
    PATHS ${TF_LIB_DIR}
    NO_DEFAULT_PATH)

不幸的是 - 找不到tensorflow库。通过执行以下操作可以确认这一点: message(STATUS ${TF_LIB})打印出 TF_LIB-NOTFOUND .

TF_LIB_DIR 设置为 /home/ubuntu/.local/lib/python2.7/site-packages/tensorflow通过execute_process打电话。

该目录的内容是aux-bin contrib core examples include __init__.py __init__.pyc libtensorflow_framework.so python tools

我做错了什么?

最佳答案

我将execute_process调用替换为:

execute_process(COMMAND "python""-c""导入tensorflow as tf; import sys; sys.stdout.write(tf.sysconfig.get_lib() + '/')"OUTPUT_VARIABLE TF_LIB_DIR)

我认为问题要么是缺少路径分隔符,要么是由于 python print 语句附加换行符而写入 OUTPUT_VARIABLE 中的尾随换行符。

关于ubuntu - CMake find_library 找不到 TensorFlow 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49757750/

相关文章:

php - 如何设置 Plover 以便可以在 LAN 上实时播放速记?

python : tensorflow-gpu import errors

machine-learning - TensorFlow - random_crop 在 Cifar10 示例中做什么?

python - 如何在 Tensorflow 中读取二进制文件

c++ - 使用 Cmake 为 Visual Studio 2015 构建 OpenCV 3.0.0 的 DLL

php - Laravel 的 AsgardCMS 无法在 Ubuntu 上正常运行

python - 包控制 : The dependency 'markupsafe' is not currently installed

apache - 试图在 Apache : error 13 (search permissions missing) 上运行 Flask

c++ - 如何只链接到 Conan 包中的某些库?

opencv - Cmake gui 重置参数。如何在cmake gui中设置参数?