GithubHelp home page GithubHelp logo

Comments (20)

achalshah20 avatar achalshah20 commented on June 26, 2024 1

Try doing find package like "find_package(TensorflowCC COMPONENTS Shared)". If it fixes your issue!

from tensorflow_cc.

achalshah20 avatar achalshah20 commented on June 26, 2024

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.

achalshah20 avatar achalshah20 commented on June 26, 2024

My issue got resolved after doing sudo make install. @kerolos Have you done make install after doing make. Thanks!

from tensorflow_cc.

kerolos avatar kerolos commented on June 26, 2024

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.

FloopCZ avatar FloopCZ commented on June 26, 2024

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.

Dinu8 avatar Dinu8 commented on June 26, 2024

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.

FloopCZ avatar FloopCZ commented on June 26, 2024

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.

Dinu8 avatar Dinu8 commented on June 26, 2024

No, I didn't.
Thank you so much, I almost gave up.

from tensorflow_cc.

mmstick avatar mmstick commented on June 26, 2024

@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.

achalshah20 avatar achalshah20 commented on June 26, 2024

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.

FloopCZ avatar FloopCZ commented on June 26, 2024

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.

achalshah20 avatar achalshah20 commented on June 26, 2024

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.

FloopCZ avatar FloopCZ commented on June 26, 2024

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.

mmstick avatar mmstick commented on June 26, 2024

@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.

mmstick avatar mmstick commented on June 26, 2024

@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.

mmstick avatar mmstick commented on June 26, 2024

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.

mmstick avatar mmstick commented on June 26, 2024

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.

mmstick avatar mmstick commented on June 26, 2024

Seems I can get it past that point if I add

list(APPEND CMAKE_PREFIX_PATH "/usr/lib/tensorflow/lib/cmake")

Before the find_packages.

from tensorflow_cc.

mmstick avatar mmstick commented on June 26, 2024

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.

FloopCZ avatar FloopCZ commented on June 26, 2024

Nice. So two installations + unusual prefix.

from tensorflow_cc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.