How can Tensorflow have no "div" attribute? When I try to run a python program from the command prompt (from tensorflow for dummies page 23 (simple program) I receive this error:
C:\Users\ME\TENSORFLOW\ch3>python simple_math.py
2020-04-26 13:50:29.871436: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-04-26 13:50:29.880652: 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.
2020-04-26 13:50:32.204590: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2020-04-26 13:50:32.212936: E tensorflow/stream_executor/cuda/cuda_driver.cc:351] failed call to cuInit: UNKNOWN ERROR (303)
2020-04-26 13:50:32.228615: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-C7DH370
2020-04-26 13:50:32.236344: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-C7DH370
Traceback (most recent call last):
File "simple_math.py", line 13, in <module>
quot = tf.div(const_a, const_b)
AttributeError: module 'tensorflow' has no attribute 'div'
Did I install a wrong version of python? I installed python 3.7. Or perhaps I did not install tensorflow correctly. The book tensorflow for dummies was published in 2018. Maybe it was intended for another version of python? and/or another version of tensorflow? thank you so much in advance
Here is the code of the "simple.math.py" :
''' Perform simple math operations with TensorFlow '''
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
# Math with constant tensors
const_a = tf.constant(3.6)
const_b = tf.constant(1.2)
total = const_a + const_b
quot = tf.div(const_a, const_b)
# Math with random tensors
rand_a = tf.random_normal([3], 2.0)
rand_b = tf.random_uniform([3], 1.0, 4.0)
diff = tf.subtract(rand_a, rand_b)
# Vector multiplication
vec_a = tf.linspace(0.0, 3.0, 4)
vec_b = tf.fill([4, 1], 2.0)
prod = tf.multiply(vec_a, vec_b)
dot = tf.tensordot(vec_a, vec_b, 1)
# Matrix multiplication
mat_a = tf.constant([[2, 3], [1, 2], [4, 5]])
mat_b = tf.constant([[6, 4, 1], [3, 7, 2]])
mat_prod = tf.matmul(mat_a, mat_b)
# Execute the operations
with tf.Session() as sess:
print('Sum: %f' % sess.run(total))
print('Quotient: %f' % sess.run(quot))
print('Difference: ', sess.run(diff))
print('Element-wise product: ', sess.run(prod))
print('Dot product: ', sess.run(dot))
print('Matrix product: ', sess.run(mat_prod))
thank you
After running the following program on windows with latest tensorflow
installed, I receive the message underneath the python code below:
''' A simple TensorFlow application '''
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
# Create tensor
msg = tf.strings.join(['Hello ', 'TensorFlow!'])
# Launch session
with tf.Session() as sess:
print(sess.run(msg))
(venv) C:\Users\ME\TENSORFLOW\ch2>python hello_tensorflow.py
2020-04-29 00:28:30.676246: W
tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load
dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-04-29 00:28:30.684568: 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.
2020-04-29 00:28:32.573201: W
tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not
load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2020-04-29 00:28:32.580400: E
tensorflow/stream_executor/cuda/cuda_driver.cc:313] failed call to cuInit:
UNKNOWN ERROR (303)
2020-04-29 00:28:32.591791: I
tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA
diagnostic information for host: DESKTOP-C7DH370
2020-04-29 00:28:32.599756: I
tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname:
DESKTOP-
C7DH370
2020-04-29 00:28:32.615405: I
tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1e0678689e0
initialized for platform Host (this does not guarantee that XLA will be
used).
Devices:
2020-04-29 00:28:32.623598: I
tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device
(0):
Host, Default Version
Traceback (most recent call last):
File "hello_tensorflow.py", line 13, in <module>
with tf.Session() as sess:
AttributeError: module 'tensorflow' has no attribute 'Session'
--useroption or check the permissions.