Comments (20)
Try doing find package like "find_package(TensorflowCC COMPONENTS Shared)". If it fixes your issue!
from tensorflow_cc.
I am also getting the same error. Can you please include TensorflowCCConfig.cmake file to find tensorflow cc library and all the required includes? Thanks!
from tensorflow_cc.
My issue got resolved after doing sudo make install. @kerolos Have you done make install after doing make. Thanks!
from tensorflow_cc.
Thanks a lot @achalshah20 for your help. i solved it by
target_link_libraries (example TensorflowCC::Shared) instead of target_link_libraries (example ${TensorflowCC::Shared})
from tensorflow_cc.
Hi, sorry for the delay. Glad you fixed it.
If you want to install to userspace (without sudo
), e.g., to folder ~/.local
, you have to configure the project with:
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
For userspace installation, don't forget to set the appropriate environmental variables in your .bashrc
/ .zshrc
:
# register ~/.local system hierarchy
export PATH="${HOME}/.local/bin:$PATH"
export LIBRARY_PATH="${HOME}/.local/lib:$LIBRARY_PATH"
export LD_LIBRARY_PATH="${HOME}/.local/lib:$LD_LIBRARY_PATH"
export CPLUS_INCLUDE_PATH="${HOME}/.local/include:$CPLUS_INCLUDE_PATH"
from tensorflow_cc.
I'm also getting this error when trying to link to the static library.
I have been able to build tensorflow_cc for static library and I can see TensorflowCCConfig.cmake in the build folder in tensorflow_cc/build. When I try to link TensorflowCC from example/build as it is explained in README.md I get the same error as above.
Why is example project not able to find TensorflowCCConfig.cmake in tensorflow_cc project?
This is the line producing the error:
find_package(TensorflowCC REQUIRED)
from tensorflow_cc.
Hi, the example does not search for TensorflowCCConfig.cmake
in the tensorflow_cc
folder. Instead, CMake itself is searching for the config file, so it has to be installed somewhere where CMake expects it. Did you run make install
after building the project?
from tensorflow_cc.
No, I didn't.
Thank you so much, I almost gave up.
from tensorflow_cc.
@FloopCZ Trying to package TF in a deb archive with the C / C++ / Python API, but I'm running into this issue with the shared library:
I have the root directory as /usr/lib/tensorflow
, which contains the include
and lib
directories that this installs. As can be seen with the cmake files & C++ libs, here:
/usr/lib/tensorflow/lib/cmake
└── TensorflowCC
├── TensorflowCCConfig.cmake
├── TensorflowCCConfigVersion.cmake
└── TensorflowCCSharedTargets.cmake
/usr/lib/tensorflow/lib/tensorflow_cc
├── libprotobuf.a
└── libtensorflow_cc.so
When setting the following (ion shell syntax for environment variables):
export LIBRARY_PATH = /usr/lib/tensorflow/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH = /usr/lib/tensorflow/lib:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH = /usr/lib/tensorflow/include:$CPLUS_INCLUDE_PATH
Then attempting to configure with:
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
find_package(TensorflowCC REQUIRED)
find_package(CUDA)
add_executable(example example.cpp)
target_link_libraries(example TensorflowCC::Shared)
if(CUDA_FOUND)
target_link_libraries(example ${CUDA_LIBRARIES})
endif()
I get this error:
CMake Error at CMakeLists.txt:6 (add_executable):
Target "example" links to target "TensorflowCC::Shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
What other actions are required to get CMake to find the files?
from tensorflow_cc.
I have been using tensorflow_cc deb package from last 4-5 months.
It is happening because tensorflowcc.so file is in /usr/lib/tensorflow_cc. It is not in cmake rpath by default so your example is not able to find tensorflow library.
I generally use "-DCMAKE_INSTALL_RPATH=/usr/lib/tensorflow_cc" while compiling my project. It works!
from tensorflow_cc.
The problem is that CMake cannot find the config files (by default, they should be installed in /usr/local/lib/cmake
or /usr/lib/cmake
, so I suppose you changed the CMAKE_INSTALL_PREFIX
). This is not really related to tensorflow_cc
project, though.
Are you sure your commands for env variables are correct? There should be no spaces around =
. Check their contents by
echo $LD_LIBRARY_PATH
from tensorflow_cc.
In that case error should be somethings like below, right ? I may be wrong but I remember I faced similar error and using rpath fixed my issue!:
CMake Warning at modules/PoseNN/CMakeLists.txt:27 (find_package):
By not providing "FindTensorflowCC.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"TensorflowCC", but CMake did not find one.
Could not find a package configuration file provided by "TensorflowCC"
with any of the following names:
TensorflowCCConfig.cmake
tensorflowcc-config.cmake
Add the installation prefix of "TensorflowCC" to CMAKE_PREFIX_PATH or set
"TensorflowCC_DIR" to a directory containing one of the above files. If
"TensorflowCC" provides a separate development package or SDK, be sure it
has been installed.
from tensorflow_cc.
Hmm, @achalshah20 there might be something in what you say. But still, I am confused, if TensorflowCCConfig.cmake
is properly found, why aren't the TensorflowCCSharedTargets.cmake
? The folder hierarchy seems to be correct:
/usr/lib/tensorflow/lib/cmake
└── TensorflowCC
├── TensorflowCCConfig.cmake
├── TensorflowCCConfigVersion.cmake
└── TensorflowCCSharedTargets.cmake
@mmstick You can try to set RPATH as @achalshah20 suggests, but is it possible that you have two installations of tensorflow_cc
and one is without the shared lib? What does
find /usr /home /opt -name "TensorflowCCConfig.cmake"
say on your system?
from tensorflow_cc.
@achalshah20 Not quite. My error is literally just that.
-- Configuring done
CMake Error at CMakeLists.txt:6 (add_executable):
Target "example" links to target "TensorflowCC::Shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
-- Generating done
-- Build files have been written to: /home/mmstick/cuda-example/cc/build
@FloopCZ When configuring the project within my debian/rules
file, I use DCMAKE_INSTALL_PREFIX=$(PREFIX)
to set the prefix to the build root at $(shell pwd)/usr/lib/tensorflow1.9-cuda9.2
, which the debian/postinst
script then uses update-alternatives
to link /usr/lib/tensorflow
to /usr/lib/tensorflow1.9-cuda9.2
.
When dpkg-buildpackage in sbuild creates the deb archive, it strips the $(shell pwd)
part of the paths. Hence the files ending up where they do, accessible at /usr/lib/tensorflow/{lib,include}
and /usr/lib/tensorflow1.9-cuda9.2/{lib,include}
. The idea is to do with TF what we've done with CUDA + cuDNN, by making it trivial to install and alternate between multiple versions of the same toolkit through update-alternatives
for Pop!_OS users. Docker containers need not apply.
The build rules look like
#!/usr/bin/make -f
%:
dh $@
export CUDA_TOOLKIT_PATH=/usr/lib/cuda-9.2
export HOME = $(shell pwd)/cache
WHEEL_DIR = python-wheel
WHEEL = tensorflow-1.9.0-cp36-cp36m-linux_x86_64.whl
C_API = libtensorflow.so
CC_API = libtensorflow_cc.so
PREFIX := usr/lib/tensorflow1.9-cuda9.2
LIB = $(PREFIX)/lib
INCLUDE = $(PREFIX)/include
PYTHON_TARGET = $(LIB)/python3.6/
override_dh_auto_configure:
bash debian/deps.sh
override_dh_auto_build:
bash debian/deps.sh
mkdir build
cd build && cmake -DTENSORFLOW_STATIC=OFF -DTENSORFLOW_SHARED=ON \
-DCMAKE_INSTALL_PREFIX=../$(PREFIX) .. \
&& make
cd build/tensorflow && ./bazel-bin/tensorflow/tools/pip_package/build_pip_package \
$(WHEEL_DIR)
override_dh_auto_install:
# C++ API
cd build && make install
# C API
mkdir -p $(LIB) $(INCLUDE)/tensorflow/c/eager/
cd build/tensorflow \
&& cp -r tensorflow/c/c_api.h tensorflow/c/c_api_experimental.h \
../../$(INCLUDE)/tensorflow/c \
&& cp -r tensorflow/c/eager/c_api.h \
../../$(INCLUDE)/tensorflow/c/eager \
&& cp ./bazel-bin/bin/tensorflow/libtensorflow.so \
../../$(LIB)
# Python API
cd build/tensorflow && \
pip3 install $(WHEEL_DIR)/$(WHEEL) -t ../../$(PYTHON_TARGET)
override_dh_shlibdeps:
I've done slight modifications to your CMake scripts to also build the C & Python APIs, and to fix the issue with Bazel putting the lib files in .bazel-bin/bin
instead of the ./bazel-bin
directory. The package builds and everything seems to be in their correct locations. I can build C & Python examples when providing the include / lib paths through environment variables, but I haven't yet figured out CMake.
Are you sure your commands for env variables are correct?
The ion shell does not follow POSIX shell conventions. Spaces are allowed before and after the =
. Multiple variables may also be defined at the same time when setting variables or exports. It's close enough to look like POSIX, though.
~/c/c/build # echo $LD_LIBRARY_PATH
/usr/lib/tensorflow/lib:
~/c/c/build # let x y = "a string" [ an array of words ]
~/c/c/build # echo $x
a string
~/c/c/build # for word in @y; echo $word; end
an
array
of
words
I haven't changed the CMAKE_INSTALL_PREFIX
environment variable, during the build schroot, or on my system. In fact, I've zero experience with using CMake (I don't write C++ software, mostly Rust here).
from tensorflow_cc.
@FloopCZ This is what I get:
~/c/c/build # find /usr /home /opt -name "TensorflowCCConfig.cmake"
/usr/lib/tensorflow1.9-cuda9.2/lib/cmake/TensorflowCC/TensorflowCCConfig.cmake
/usr/lib/cmake/TensorflowCC/TensorflowCCConfig.cmake
from tensorflow_cc.
After removing /usr/lib/cmake/TensorflowCC
(left over from when I built it outside of a schroot), I'm now getting
CMake Error at CMakeLists.txt:3 (find_package):
By not providing "FindTensorflowCC.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"TensorflowCC", but CMake did not find one.
Could not find a package configuration file provided by "TensorflowCC" with
any of the following names:
TensorflowCCConfig.cmake
tensorflowcc-config.cmake
Add the installation prefix of "TensorflowCC" to CMAKE_PREFIX_PATH or set
"TensorflowCC_DIR" to a directory containing one of the above files. If
"TensorflowCC" provides a separate development package or SDK, be sure it
has been installed.
-- Configuring incomplete, errors occurred!
See also "/home/mmstick/cuda-example/cc/build/CMakeFiles/CMakeOutput.log".
See also "/home/mmstick/cuda-example/cc/build/CMakeFiles/CMakeError.log".
from tensorflow_cc.
Setting the RPATH doesn't seem to work.
~/c/c/build # cmake -DCMAKE_INSTALL_RPATH=/usr/lib/tensorflow1.9-cuda9.2/lib/tensorflow_cc/ ..
CMake Error at CMakeLists.txt:3 (find_package):
By not providing "FindTensorflowCC.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"TensorflowCC", but CMake did not find one.
Could not find a package configuration file provided by "TensorflowCC" with
any of the following names:
TensorflowCCConfig.cmake
tensorflowcc-config.cmake
Add the installation prefix of "TensorflowCC" to CMAKE_PREFIX_PATH or set
"TensorflowCC_DIR" to a directory containing one of the above files. If
"TensorflowCC" provides a separate development package or SDK, be sure it
has been installed.
-- Configuring incomplete, errors occurred!
from tensorflow_cc.
Seems I can get it past that point if I add
list(APPEND CMAKE_PREFIX_PATH "/usr/lib/tensorflow/lib/cmake")
Before the find_package
s.
from tensorflow_cc.
I seem to have a winner:
~/c/c/build # ./example
2018-07-26 14:02:29.916603: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-07-26 14:02:30.038109: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:897] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-07-26 14:02:30.038791: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1392] Found device 0 with properties:
name: GeForce GTX 1070 major: 6 minor: 1 memoryClockRate(GHz): 1.645
pciBusID: 0000:01:00.0
totalMemory: 7.92GiB freeMemory: 6.58GiB
2018-07-26 14:02:30.038806: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1471] Adding visible gpu devices: 0
2018-07-26 14:02:30.260710: I tensorflow/core/common_runtime/gpu/gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-07-26 14:02:30.260739: I tensorflow/core/common_runtime/gpu/gpu_device.cc:958] 0
2018-07-26 14:02:30.260745: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0: N
2018-07-26 14:02:30.260918: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6342 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1)
2018-07-26 14:02:30.335185: I /home/mmstick/cuda-example/cc/example.cpp:21] 19
-3
from tensorflow_cc.
Nice. So two installations + unusual prefix.
from tensorflow_cc.
Related Issues (20)
- what is the Tensorflow version that i can compile with bazel 3.7.1? HOT 1
- Build Failed
- subprocess.CalledProcessError: Command '['bazel', 'build', '-c', 'opt', '//mediapipe_api:mediapipe_proto_srcs']' returned non-zero exit status 1. HOT 1
- tensorflow_cc slow startup, tensorflow over python works as expected HOT 7
- Bazel build fails on both macOS and Ubuntu HOT 3
- Where are certain tensorflow c/cc files? HOT 3
- Use system Eigen and/or provide FindEigen.cmake
- error while built HOT 1
- support for new versions of tensorflow
- It seems that Tensorflow_cc does not use the GPU on my installation HOT 19
- Tag/release 2.6/2.7/2.8 HOT 4
- is there a way to do this in windows HOT 2
- Duplicate #136 code and meet make errors HOT 16
- error downloads file from llvm repository HOT 2
- Inconsistent CUDA toolkit path: /usr vs /usr/lib HOT 2
- Conan package
- how to include tensorflow lite libraries also
- Cc1plus error when building tensorflow HOT 1
- Linking step fails with undefined symbols. HOT 4
- Still requires building tensorflow HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorflow_cc.