2

source code

import tensorflow as tf
constant_a = tf.constant('Hello World!')
with tf.Session() as session:
  print(session.run(constant_a))

problem log

2022-04-14 16:26:07.486097: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
  File "....source_code_path/main.py", line 3, in <module>
    with tf.Session() as session:
AttributeError: module 'tensorflow' has no attribute 'Session'

enviroment

running in virtualenv.

python: 3.9.7

tensorflow: 2.8.0

SOS.(TAT)

1 Answers1

1

In tensorflow v2.x, you can print this "Hello World!" with:

import tensorflow as tf
constant_a = tf.constant('Hello World!')
print(constant_a)

You will get tf.Tensor(b'Hello World!', shape=(), dtype=string) in your shell.

About this problem:

This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

It doesn't seem to make any difference in this program. So use this can ignore the warning:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

But, if you want to solve this question, maybe build from source will help. I'll just sit on this shit, because I use tf just for a short period homework... :P

Looking forward to someone answer this question again, with this warning solved.

And, how-to-compile-tensorflow-with-sse4-2-and-avx-instructions.