Environment:
win10
vs2017
After checking the information, three plans are tentatively decided:
- C++ calls the written python script
- cmake compiles tf source code, c++ calls and realizes offline prediction
- Call by finding python modules, classes, methods, and construction parameters
The first solution is implemented. I wrote a classified demo, created a new virtual environment, and packaged the things needed. This package is large, and the entire app integrated into the client is large. If there are other options, I definitely don't choose this one!
Try the second option:
When compiling tensorflow, I found out that NCCL was not installed. Some blogs are really pits. Why are the pits copied intact? The pits of others are also your pits. I especially want to complain! !
https://developer.nvidia.com/nccl
sudo dpkg -i nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb
sudo apt update
sudo apt install libnccl2 libnccl-dev
sudo cp /usr/lib/x86_64-linux-gnu/libnccl.so.2 /usr/local/cuda/lib
sudo cp /usr/include/nccl.h /usr/local/cuda/include/
nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb link:
link: https://pan.baidu.com/s/1jl_e4T8XZSMItRifDCAmvQ
extraction code: l9j3
The matters needing attention when compiling tensorflow are:
- The tensorflow version I chose 1.10
- The default installation address of python3.5: /usr/bin/python3.5
- Choose the location of various python libraries according to the version you want to compile
- ubuntu16.04 chose gcc-4.8
- There seems to be nothing wrong with the others
Several python libraries are installed:
sudo pip3.5 install -U --user pip six numpy wheel mock
sudo pip3.5 install -U --user keras_applications==1.0.5 --no-deps
sudo pip3.5 install -U --user keras_preprocessing==1.0.3 --no-deps
The following is the compilation:
because I want to use cuda to accelerate, I gave an additional parameter. It is said that there are a lot of pits here. I am still compiling this and I am a little worried. At this step, I read many blogs and said not to add sudo, otherwise there will be There are many unexpected errors. I don't like adding sudo when using bazel itself, so I didn't add them. Wait for the result! !
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
The blog has just been published and I saw it successfully! Happy~
After verification, the compiled tf can correctly output what you want!
Next, compile and generate the .so file, and compile the C++API library:
bazel build //tensorflow:libtensorflow_cc.so
The compilation was successful, and another small goal was achieved! ! !
Um, why do I need to load the complete path for my guide package? Leave a question! !
This is too ugly! ! !
Compile the excellent references seen by tensorflow:
https://blog.csdn.net/HappyCtest/article/details/86747306