I need to use the C++ API of TensorFlow. Therefore it seems necessary to build TensorFlow from sources, so I do this according to https://www.tensorflow.org/install/install_sources. I want to have the version with GPU support. I run the ./configure with mostly default options.
However when running
bazel build --config=opt --config=cuda
//tensorflow/tools/pip_package:build_pip_package
the following error occurs:
Cuda Configuration Error: cuDNN version detected from
/usr/lib/x86_64-linux-gnu/include/cudnn.h (7.0.3) does not match
TF_CUDNN_VERSION (6)
I had previously CuDNN 7 installled, but then installed cudnn 6 for use with tensorflow. What can I do?
Could you try disable CuDNN 7 from your environment varaities, and try to put the file in cudnn6 folder to the relative folder in your CUDA folder.
This works for me, hope it helps.
Related
I am trying to build TensorFlow 2.4.1 C++ API on Windows 10 and I am having issues.
What I've done so far:
Download TensorFlow Source from the official repo
https://github.com/tensorflow/tensorflow
and switched to the official v2.4.1 tag
Download and install Python 3.6.8 x64
Created a virtual env with python 3.6.8
Created and installed requirements.txt based on the data here
Download and install CUDA 11.0 and cuDNN v8.0.4.30 (for CUDA 11)
Downloaded and installed msys2 and set it's location in PATH
Download and install bazel (3.1.0) as it is the most recent entry here
Then I run the configuration process with python configure.py
I configure for C++ build (tensorflow_cc) with GPU support
Here I had some problem that apparently during the config process windows-style backslashes are accepted as a valid input, but then when you actually run bazel compilation they cause problems, so I reran my configuration to provide linux-style backslashes. Thus CUDA and cuDNN were successfully detected and compilation started.
The full contents of my .tf_configure.bazelrc are below
build --action_env PYTHON_BIN_PATH="D:/code/sdk/tensorflow/venv/Scripts/python.exe"
build --action_env PYTHON_LIB_PATH="D:/code/sdk/tensorflow/venv/lib/site-packages"
build --python_path="D:/code/sdk/tensorflow/venv/Scripts/python.exe"
build --config=xla
build --action_env TF_CUDA_VERSION="11.0"
build --action_env TF_CUDNN_VERSION="8.0.4"
build --action_env TF_CUDA_PATHS="C:/Program Files/NVIDIA GPU Computing
Toolkit/CUDA/v11.0,D:/code/sdk/cudnn-11.0-windows-x64-v8.0.4.30/cuda"
build --action_env CUDA_TOOLKIT_PATH="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0"
build --action_env TF_CUDA_COMPUTE_CAPABILITIES="5.0"
build --config=cuda
build:opt --copt=/arch:AVX
build:opt --host_copt=/arch:AVX
build:opt --define with_default_optimizations=true
build --define=override_eigen_strong_inline=true
test --flaky_test_attempts=3
test --test_size_filters=small,medium
test:v1 --test_tag_filters=-benchmark-test,-no_oss,-no_windows,-no_windows_gpu,-no_gpu,-oss_serial
test:v1 --build_tag_filters=-benchmark-test,-no_oss,-no_windows,-no_windows_gpu,-no_gpu
test:v2 --test_tag_filters=-benchmark-test,-no_oss,-no_windows,-no_windows_gpu,-no_gpu,-oss_serial,-
v1only
test:v2 --build_tag_filters=-benchmark-test,-no_oss,-no_windows,-no_windows_gpu,-no_gpu,-v1only
build --action_env TF_CONFIGURE_IOS="0"
About 20 minutes into the compilation however it failed with the following error:
ERROR: D:/code/sdk/tensorflow/tensorflow/stream_executor/cuda/BUILD:366:1: C++ compilation of rule '//tensorflow/stream_executor/cuda:cudnn_stub' failed (Exit 2): python.exe failed: error executing command
And the reason the command fails to execute is
bazel-out/x64_windows-opt/bin/external/local_config_cuda/cuda/_virtual_includes/cudnn_header\third_party/gpus/cudnn/cudnn.h(61): fatal error C1083: Cannot open include file: 'cudnn_ops_infer.h': No such file or directory
And here I am wondering what is going on? I already provided a path to cuDNN, but apparently bazel doesn't really know about it, even though it previously acknowledged that the path I have provided is correct. Am I missing some environment variable that I need to set to instruct where cuDNN is?
Has anyone built TF C++ v2.4.1 on Windows? There is so little information online, even the official page says nothing about Windows builds. It's only Linux and Mac...
As I was running out of ideas I decided to go take a look at the Bazel build scripts for CUDA
In <REPO>\tensorflow\third_party\gpus\cuda_configure.bzl I saw that cuDNN path is read from env variable CUDNN_INSTALL_PATH
and if not present it will default to /usr/local/include?
Anyway, tried set CUDNN_INSTALL_PATH=D:/code/sdk/cudnn-11.0-windows-x64-v8.0.4.30/cuda and WOOHOO It compiled!
(Pro Tip: Set the env var without any quotes and with linux-style slashes...)
I'm trying to build tensorflow C++ from sources but no success. I followed different tutorials, but each time, there is a different error.
What I want to do is to create a library so I can use it with Qt. I followed this tutorial because it was exactly what I wanted:
https://tuatini.me/building-tensorflow-as-a-standalone-project/
(build on Ubuntu, not on raspberry)
It works fine until I have to use babel.
The tutorial says I have to run this command:
bazel build -c opt --verbose_failures //tensorflow:libtensorflow_cc.so
but it always fails with the error:
ERROR: /home/default/.cache/bazel/_bazel_default/045e1c5e9b482c7b029d706e128fc7e7/external/io_bazel_rules_closure/closure/stylesheets/closure_css_library.bzl:27:13: name 'set' is not defined
I have no idea where I'm supposed to define 'set' (I remove the .cache/bazel folder)
Other tutorials I followed gave me errors such as bazel needs to be > 0.4.3, found 0.13.1 as if it was strings instead of numbers...
Any idea on how to make it work?
Do you need to build Tensorflow 1.3.0? There's an old version of TF that can only be built with Bazel 0.5.1, according to the tutorial. You have Bazel 0.13.1, which doesn't support the keyword set in the build scripts. The latest version of TF is buildable with Bazel 0.13.1.
If you need to build 1.3.0, install an older version of Bazel (e.g. 0.5.4) from https://github.com/bazelbuild/bazel/tags?before=0.4.3.
To be exact, this error comes from one of the dependencies of TF, and not TF itself.
I try to build openCV with Extramodules. If I try to configure the projectfiles (vc14 x32 on windows 10) with cmake there's the error:
CMake Error at opencv_contrib-master/modules/xfeatures2d/cmake/download_vgg.cmake:13 (ocv_download):
Unknown CMake command "ocv_download".
Did anyone ever have this problem and knows how to solve it?
The simple answer is you are using incompatible versions of opencv and opencv_contrib, you might be installing current version of opencv_contrib on maybe opencv2.4.xx
Well, the download link for opencv contrib in CMake script https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d now is 400: Invalid request.
From the commit https://github.com/opencv/opencv_contrib/commit/593e78c5d084aa0a29eb1e0459fc7f7a4dd52ea8 you can try to ignore the added line in CMakeLists include(cmake/download_vgg.cmake) and rebuild.
The below is basing on my experience, I'm not sure it will works for OpenCV 3.0.
Maybe you can try to clone opencv contrib from git, then copy it to somewhere (for example modules directory in opencv source code). Then use CMAKE to set OPENCV_EXTRA_MODULES_PATH. If the hash is correct then it won't download and use the offline package.
I have try and build success OpenCV 2.x with IPP.
Hope it help.
Just follow instructions here.
Make sure you have active internet connection while building Opencv with contrib module.
When you hit config button on cmake(gui), it downloads other files like
vgg_generated_...
boostdesc_binboost_...
boostdesc_lbgm.i
P.S: i compiled Opencv 3.1 with contrib. Cmake downloaded required files & configure was Done.
I've been googling and trying for days now, trying to figure out how to get 32-bit OpenCV working on OS X Lion, but can just find 64-bit version.
So i have the following questions:
OpenCV libraries come in 32-bit or 64-bit arch, is that correct?
How do I get 32-bit OpenCV working on Lion? I've trying the following ways:
- Install OpenCV via MacPorts: nope, MacPorts installs a 64-bit version.BI removed OpenCV and MacPorts.
Install OpenCV 2.4.1 via Homebrew, using the following command:
brew install opencv --build32
but looks like they are 64-bit too. Removed OpenCV and Homebrew.
Install OpenCV 2.4.1 by myself using standard unix makefiles. Nope, they still look like 64-bit.
I've written "they look like 64-bit" because i have to replace OpenC in a Xcode project made under OS X Snow Leopard, targeted for 32-bit Mac, and I always get tons of errors like:
ld: warning: ignoring file /usr/local/Cellar/opencv/2.4.1/lib/libopencv_calib3d.2.4.1.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
so i suppose that the OpenCV stuff is 64-bit. If i force the project to run in 64-bit, it rubs but doesn't work properly and gets stuck.
Is there a standard way to check if my OpenCV libraries are 64-bit or 32-bit?
Where can i get 32-bit OpenCV?
Solved the problem.
Recap: it is possible to have 32-bit OpenCV libraries on 64-bit Mac OSX Lion.
How?
Step 1: Download OpenCV 2.4.0
Step 2: Download and install CMake.
Step 3: Untar the OpenCV package.
Step 4: Make a separate directory inside the OpenCV package for building
mkdir build
cd build
cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 -D CMAKE_C_FLAGS=-m32 -D CMAKE_CXX_FLAGS=-m32 ..
(this will force the 32-bit compile)
make -j8
sudo make install
Step 5: Enjoy!
For forther reference please visit Mac OS X OpenCV Port Page
Thanks all for putting me on the right track:
#karlphilip: I tried to do as you suggested, but without the make options the compile phase fails, because the architectures are incoherent.
#hamstergene: MacPorts got stuck after the new installation, maybe I have some remains of the older install :( (strange, i followed the official instrusctions to remove it).
#Adrien: That's what I've done, but i had to merge 2 approaches :)
I ve had a hard time configuring OpenCv libraries on a number od different OSs. Turns out that the thing is auto-generating a sample project and then bulding business logic inside it.
See the installation instructions here
The web site of the OpenCV project has been significantly upgraded in the last year.
A new tutorial section is avaiable, i was able to install OpenCV on my 32-bit core Mac OS Lion.
A very cool tutorial is also available at Sadeep's Tech Blog, covering an interesting range of details.
Hope this helps!
Here's something you can try: download OpenCV 2.4 sources and edit the CMakeLists.txt in the root directory. Around line 242 you will see:
# ----------------------------------------------------------------------------
# Path for build/platform -specific headers
# ----------------------------------------------------------------------------
set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h")
add_definitions(-DHAVE_CVCONFIG_H)
ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})
below the add_definitions() call, add this one:
add_definitions(-m32)
I've been strugling for two weeks to create an environment for building a gstreamer plugin on windows (needed for a songbird addon).
I've installed MSYS, MinGW and Cygwin, then installed GStreamer OSSBuild, and I also downloaded the sources for Songbird, which come with their own precompiled version of gstreamer.
I was unable to run gst-inspect (or any other gstreamer applications) from the songbird sources and I figured I will settle for OSSBuild (as I was able to run gst-inspect from the compiled OSSBuild).
When following the instructions for building a GST plugin (found here) through, cygwin will not recognize the OSSBuild and the build fails when running autogen, with the following error:
checking for GST... no
configure: error:
You need to install or upgrade the GStreamer development
packages on your system. On debian-based systems these are
libgstreamer0.10-dev and libgstreamer-plugins-base0.10-dev.
on RPM-based systems gstreamer0.10-devel, libgstreamer0.10-devel
or similar. The minimum version required is 0.10.16.
configure failed
I could also not use MSYS or MinGW as they are unable to run autogen at all.
I understand that cygwin should have it's own gstreamer development packages but I couldn't find how to install them.
My question: How do I install the gstreamer packages in cygwin or how do I build using cygwin with the OSSBuild dependencies?
In short, how do I get an environment where I can build a gstreamer plugin under windows?
you can install precompiled gstreamer packages for cygwin at cygwinports. there you will find installation instructions and a list of available packages. you should not need to build them from source.
Configure's most likely going to look for libtool (.la) or pkg-config (.pc) files. Since OSSBuild is built using MSVC, you're not likely to get those files so configure can pick them up. However, you can manually create them and set them in a location to be picked up by the script. I do know that OSSBuild does have as its goal to eventually provide Visual Studio-compatible C/C++ project templates for GStreamer plugins as well as libtool and pkg-config files, but they're not available just yet.
If you checkout the OSSBuild source and can follow MSVC property files, you can see how the plugins are setup and configured.