I have those warnings:
2017-09-26 14:50:45.956966: 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.
2017-09-26 14:50:45.956986: 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.
2017-09-26 14:50:45.956990: 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.
2017-09-26 14:50:45.956996: 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.
So, based on what I found on internet, I then followed this link:
https://www.tensorflow.org/install/install_sources
However, when I try:
$ python
and :
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
The output should be : Hello, TensorFlow!
However, I don't get that at all...
emixam23#pt-mguittet:~/Workspace$ python
Python 3.6.2 (default, Sep 4 2017, 16:58:35)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-09-26 14:56:33.905065: 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.
2017-09-26 14:56:33.905096: 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.
2017-09-26 14:56:33.905105: 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.
2017-09-26 14:56:33.905112: 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.
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
>>>
Even after I installed it, I still have the warnings, why so? I used Xcode 7.3 and I didn't put the GPU in the ./configuration process.
Any idea? :/ Thank in advance !
You can mask these warnings like so:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
Notice that your program still output 'Hello, TensorFlow!', just simply after all of the warnings regarding SSE4.2.
Why are you saying it doesn't seem to install?
You are getting what you expected (Hello, Tensorflow!) but you are also getting these warnings. Regarding the warnings, they have been discussed here: Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
Regarding the "b'" before Hello, Tensorflow!, see What does the 'b' character do in front of a string literal?.
Hope it helps.
Related
I have this code to disable GPU usage:
import numpy as np
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
import tensorflow as tf
w = tf.Variable(
[
[1.],
[2.]
])
I get this output still, not sure why :
E:\MyTFProject\venv\Scripts\python.exe E:/MyTFProject/tfvariable.py
2021-11-03 14:09:16.971644: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-11-03 14:09:16.971644: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2021-11-03 14:09:19.563793: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2021-11-03 14:09:19.566793: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: newtonpc
2021-11-03 14:09:19.567793: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: mypc
2021-11-03 14:09:19.567793: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
TF Version: '2.6.1'
Not able to stop it from loading Cuda DLLs. I dont want to setup cuda just right now. Maybe later.
I am using the latest PyCharm and installed tensorflow as given in the site with pip.
You can try to reinstall tensorflow with CPU-only version. The links are available here depending on your OS and your python version:
https://www.tensorflow.org/install/pip?hl=fr#windows_1
After reading this tutorial https://www.tensorflow.org/guide/using_gpu I checked GPU session on this simple code
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2,3], name = 'a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape = [3,2], name = 'b')
c = tf.matmul(a, b)
with tf.Session(config=tf.ConfigProto(log_device_placement=True)) as sess:
x = sess.run(c)
print(x)
The output was
2018-08-07 18:44:59.019144: I
tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports
instructions that this TensorFlow binary was not compiled to use: AVX2
FMA Device mapping: no known devices. 2018-08-07 18:44:59.019536: I
tensorflow/core/common_runtime/direct_session.cc:288] Device mapping:
MatMul: (MatMul): /job:localhost/replica:0/task:0/device:CPU:0
2018-08-07 18:44:59.019902: I
tensorflow/core/common_runtime/placer.cc:886] MatMul:
(MatMul)/job:localhost/replica:0/task:0/device:CPU:0 a: (Const):
/job:localhost/replica:0/task:0/device:CPU:0 2018-08-07
18:44:59.019926: I tensorflow/core/common_runtime/placer.cc:886] a:
(Const)/job:localhost/replica:0/task:0/device:CPU:0 b: (Const):
/job:localhost/replica:0/task:0/device:CPU:0 2018-08-07
18:44:59.019934: I tensorflow/core/common_runtime/placer.cc:886] b:
(Const)/job:localhost/replica:0/task:0/device:CPU:0 [[ 22. 28.] [
49. 64.]]
As you see there is no calculation done by GPU.
and when I changed the code to use GPU's configuration and process fraction:
conf = tf.ConfigProto()
conf.gpu_options.per_process_gpu_memory_fraction = 0.4
with tf.Session(config = conf) as sess:
x = sess.run(c)
print(x)
The output was
2018-08-07 18:52:22.681221: I
tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports
instructions that this TensorFlow binary was not compiled to use: AVX2
FMA [[ 22. 28.] [ 49. 64.]]
What can I do to run the session on GPU card? Thank you.
It is most certainly possible to run tensorflow on AMD GPUs. About 2 years back ROCm was released which gets things done. However, the is a caveat, that it runs only on Linux as of now owing to its open-source origins. So if you are willing to use Linux then you can most certainly train your DL models using AMD GPUs. That said the amount of support you will get is low as the community is still not large enough. Google search for ROCm and you can get instructions on how to get it set up and running on a Linux machine. May be it will work with WSL2 in windows, but I have not tried it yet and so cannot comment on that.
here is a link to ROCm installation docs
You can use TensorflowJS, the Javascript version of tensorflow.
TensorflowJS does not have any HW limitation and can run on all the gpu supporting webGL.
The api is pretty similar to tf in python and the project provides scripts to convert your models from python to JS
I believe TensorFlow-GPU only support GPU card with CUDA Compute Capability >= 3.0 of NVIDIA.
The following TensorFlow variants are available for installation:
TensorFlow with CPU support only. If your system does not have a NVIDIA® GPU, you must install this version. This version of TensorFlow is usually easier to install, so even if you have an NVIDIA GPU, we recommend installing this version first.
TensorFlow with GPU support. TensorFlow programs usually run much faster on a GPU instead of a CPU. If you run performance-critical applications and your system has an NVIDIA® GPU that meets the prerequisites, you should install this version. See TensorFlow GPU support for details.
https://www.tensorflow.org/install/install_linux
Just two days ago, after much work on my part downloading and installing the latest stable GPU version of tensorflow, my tensorflow installation was behaving correctly as I wanted, and it reported this:
$ source activate tensorflowgpu
(tensorflowgpu) ga#ga-HP-Z820:~$ python
Python 3.5.4 |Anaconda, Inc.| (default, Nov 20 2017, 18:44:38)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant("Hello tensorflow")
>>> sess = tf.Session()
2018-01-22 12:37:32.119300: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
2018-01-22 12:37:33.339324: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.797
pciBusID: 0000:41:00.0
totalMemory: 7.92GiB freeMemory: 7.80GiB
2018-01-22 12:37:33.339414: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:41:00.0, compute capability: 6.1)
>>> print(sess.run(hello))
b'Hello tensorflow'
Sadly however, to my complete surprise today my tensorflow installation is misbehaving because it is reporting the following, that is, it's using the CPU version. What in the world happened to it, and how do I make it behave correctly again, that is, reinstate the GPU version of tensorflow? This is my privately owned workstation of which I am the sole user.
ga#ga-HP-Z820:~$ source activate tensorflowgpu
(tensorflowgpu) ga#ga-HP-Z820:~$ ipython
Python 3.5.4 |Anaconda custom (64-bit)| (default, Nov 20 2017, 18:44:38)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
...
In [2]: import tensorflow as tf
...: hello = tf.constant("Hello tensorflow")
...: sess = tf.Session()
...:
2018-01-24 12:34:56.792676: 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.
2018-01-24 12:34:56.792719: 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.
2018-01-24 12:34:56.792729: 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.
Now looking closer, todauy my python (not ipython) does the following, which is good behavior again. That's strange -- the 2 pythons load different tensorflows. So how do I compel ipython and python to both use the GPU version of tensorflow? I really use ipython more, esp. for jupyter notebooks.
(tensorflowgpu) ga#ga-HP-Z820:~$ python
Python 3.5.4 |Anaconda, Inc.| (default, Nov 20 2017, 18:44:38)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant("Hello tensorflow")
>>> sess = tf.Session()
2018-01-24 12:50:35.846985: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
2018-01-24 12:50:37.222662: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.797
pciBusID: 0000:41:00.0
totalMemory: 7.92GiB freeMemory: 7.80GiB
2018-01-24 12:50:37.222721: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:41:00.0, compute capability: 6.1)
I had followed the installation instructions for tensorflow GPU on linux ubuntu at tensorflow website. It did not say to remove the CPU version first.
Edit -- As follows, I explicitly queried the tf versions. It confirms that the two different versions that are installed are being loaded by python vs ipython. I would want to cause both pythons to use only the newer version of tf, somehow.
(tensorflowgpu) ga#ga-HP-Z820:~$ python
Python 3.5.4 |Anaconda, Inc.| (default, Nov 20 2017, 18:44:38)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'1.4.1'
>>>
(tensorflowgpu) ga#ga-HP-Z820:~$ ipython
Python 3.5.4 |Anaconda custom (64-bit)| (default, Nov 20 2017, 18:44:38)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import tensorflow as tf
In [2]: tf.__version__
Out[2]: '1.3.0'
You'll need to install the kernel in ipython, so that it knows about your environment. Currently, ipython is picking up the default python on your system, not the environment one. You can install the kernel by (make sure your environment is active)
pip install ipykernel
python -m ipykernel install --user --name tensorflowgpu
Now, just select this kernel when running ipython
I downloaded CUDA Toolkit 8.0 GA2, cuDNN v6.0 for CUDA 8 and tensorflow 1.4. I have an Nvidia 740M graphics chip. I tried running this code to test tensorflow:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
This is what it returns:
2017-11-09 16:25:42.999638: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compil
ed to use: AVX AVX2
2017-11-09 16:25:43.007712: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_driver.cc:406] failed call to cuInit: CUDA_ERROR_UNKNOWN
2017-11-09 16:25:43.010457: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_diagnostics.cc:158] retrieving CUDA diagnostic information for host: DESKTOP-06398IN
2017-11-09 16:25:43.010576: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_diagnostics.cc:165] hostname: DESKTOP-06398IN
b'Hello, TensorFlow!'
What does the error CUDA_ERROR_UNKNOWN mean? How do I fix it? Thanks
Updating the graphics driver fixed it.
I train the model with the shell command:
python src/facenet_train.py \
--batch_size 15 \
--gpu_memory_fraction 0.25 \
--models_base_dir trained_model_2017_05_15_10_24 \
--pretrained_model trained_model_2017_05_15_10_24/20170515-121856/model-20170515-121856.ckpt-182784 \
--model_def models.nn2 \
--logs_base_dir logs \
--data_dir /data/user_set/training/2017_05_15_10_24 \
--lfw_pairs /data/user_set/lfw_pairs.txt \
--image_size 224 \
--lfw_dir /data/user_set/lfw \
--optimizer ADAM \
--max_nrof_epochs 1000 \
--learning_rate 0.00001
but i get error infomation like this when use my own trained model:
2017-05-17 14:23:05.448285: 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.
2017-05-17 14:23:05.448318: 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.
2017-05-17 14:23:05.448324: 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.
2017-05-17 14:23:05.448329: 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.
2017-05-17 14:23:05.448334: 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.
2017-05-17 14:23:05.674872: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0
with properties:
name: Quadro M4000
major: 5 minor: 2 memoryClockRate (GHz) 0.7725
pciBusID 0000:03:00.0
Total memory: 7.93GiB
Free memory: 2.89GiB
2017-05-17 14:23:05.674917: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0
2017-05-17 14:23:05.674935: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y
2017-05-17 14:23:05.674957: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating
TensorFlow device (/gpu:0) -> (device: 0, name: Quadro M4000, pci bus
id: 0000:03:00.0)
Traceback (most recent call last):
File "forward.py", line 21, in
images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0")
File "/home/chen/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2563, in get_tensor_by_name
return self.as_graph_element(name, allow_tensor=True, allow_operation=False)
File "/home/chen/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2414, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "/home/chen/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2456, in _as_graph_element_locked
"graph." % (repr(name), repr(op_name)))
KeyError: "The name 'input:0' refers to a Tensor which does not exist. The operation, 'input', does not exist in the graph."
get feature code:
import tensorflow as tf
import facenet
w_MODEL_PATH_='/home/chen/demo_dir/facenet_tensorflow_train/trained_model_2017_05_15_10_24/20170515-121856'
with tf.Graph().as_default():
with tf.Session() as sess:
# load the model
meta_file, ckpt_file = facenet.get_model_filenames(w_MODEL_PATH_)
facenet.load_model(w_MODEL_PATH_, meta_file, ckpt_file)
# print("model_path:", w_MODEL_PATH_,"meta_file:", meta_file,"ckpt_file:", ckpt_file)
# Get input and output tensors
# ops = tf.get_default_graph().get_operations()
#
# print(ops)
images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0")
embeddings = tf.get_default_graph().get_tensor_by_name("embeddings:0")
phase_train_placeholder = tf.get_default_graph().get_tensor_by_name("phase_train:0")
image_size = images_placeholder.get_shape()[1]
embedding_size = embeddings.get_shape()[1]
# print(image_size)
paths = ['one.png', 'two.png']
# Run forward pass to calculate embeddings
images = facenet.load_data(paths, do_random_crop=False, do_random_flip=False, image_size=image_size,
do_prewhiten=True)
# print("images:", idx, images)
feed_dict = {images_placeholder: images, phase_train_placeholder: False}
# print(idx,"embeddings:", embeddings)
emb_array = sess.run(embeddings, feed_dict=feed_dict)
# print(idx, "emb_array:", emb_array)
print(emb_array)
I don't know how to use my own trained model, please help.
If you are talking about the last part then use this code to see what operations your model has.
for i in tf.get_default_graph().get_operations():
print(i.name)
If you are talking about the optimizations.
You are getting this error because you need to compile tensorflow on your own machine. It is very easy to do.
You can read the documentation for the full list of options, but essentially you need to do a few steps.
https://www.tensorflow.org/install/install_sources
git clone tensorflow
repo install
bazel a tensorflow build system
configure tensorflow
build tensorflow
install tensorflow in your environment if that is anaconda or virtualenv if you are using python
that is it, of course other required libraries will need to be installed. It is pretty easy to do on Ubuntu.
Alternatively you could try the conda forge version of tensorflow-gpu if you are using anaconda, but I cannot verify it is also compiled with optimizations for your cpu.
https://conda-forge.org/
install anaconda
add the conda forge repo url
update conda
install tensorflow-gpu