[Switch] Ubuntu solves the tensorflow prompt that SSE3/4.1/4.2 is not compiled

The prompt message that appears on my machine is as follows:
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.  
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.  
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.  
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.  
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.  
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
 
Then it should be noted that these are warnings, not errors. These warings mean: You have these instruction sets available on your machine, and using them will speed up your CPU, but your TensorFlow is compiled without using these instruction sets.
 
The pip install command used by my tensorflow when installing, this installation method will have this problem. There are two main solutions, one is to modify the display level of the warning information so that this information no longer appears, the other is to recompile and install tensorflow by yourself, and use these instruction sets when compiling. Here I try the second solution. And since I don't have an efficient GPU on my machine, what I'm trying to install is the CPU version.
 
First, uninstall the already installed tensorflow:
sudo pip uninstall tensorflow  
 
Then, clone the Tensorflow repository:
git clone --recurse-submodules https://github.com/tensorflow/tensorflow  
 
The above command will create a folder called "tensorflow" in your current folder, where the downloaded files are stored.
 
Since the Bazel tool is used when compiling and installing tensorflow, let's install Bazel next. Follow the instructions on the official website (https://bazel.build/versions/master/docs/install-ubuntu.html) and enter the following commands:
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list  
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - 
sudo apt-get update && sudo apt-get install bazel
sudo apt-get upgrade bazel  
 
Then install other dependencies required by tensorflow
sudo apt-get install python-numpy python-dev python-pip python-wheel  
 
Then go to the tensorflow folder and run the tensorflow configuration program:
cd tensorflow/  
./configure  
 
For me I got an error like this during configuration:
Problem with java installation: couldn't find/access rt.jar in /usr/lib/jvm/java-9-openjdk-amd64  
 
I didn't study the reason carefully, but after I uninstalled java-9 with the following command, there is no problem.
sudo apt-get purge openjdk-9*  
 
Then use the following command to generate a pip installation package:
bazel build -c opt --copt = -msse3 --copt = -msse4.1 --copt = -msse4.2 --copt = -mavx --copt = -mavx2 --copt = -mfma // tensorflow / tools / pip_package: build_pip_package  
 
This is a rather time-consuming process.
 
The above command will generate a script called build_pip_package. Run the script as follows to create a pip installation package in the /tmp/tensorflow_pkg folder:
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg  
 
Then run the following command to install. It should be noted that, due to different platforms, the names of packages may be different.
sudo pip install /tmp/tensorflow_pkg/tensorflow-1.1.0rc1-cp27-cp27mu-linux_x86_64.whl
 
A successful installation means you're done.
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326485822&siteId=291194637