安装:建议用conda安
看自己的tensorflow是GPU还是CPU版:
>>> from tensorflow.python.client import device_lib
>>> print(device_lib.list_local_devices())
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 14648057245001138740
]
GPU版得服务器/电脑有显卡,需要安驱动。因为我这服务器的显卡不是伟英达。查看是啥显卡:
yum install nvidia-detect
nvidia-detect -v
Probing for supported NVIDIA devices...
[102b:0536] Matrox Electronics Systems Ltd. Integrated Matrox G200eW3 Graphics Controller
No NVIDIA devices were found.
所以这个啥玩意显卡?没找到驱动。CUBA只能是伟英达的才可以。所以放弃GPU的tensorflow!
tensorflow2和1不兼容
>>> hello = tf.constant('hello,tensorflow')
>>> sess= tf.compat.v1.Session() #加上这句
>>> print(sess.run(hello))
b'hello,tensorflow'
>>> print(sess.run(hello).decode()) #去掉前面的b
hello,tensorflow
网友评论