机器学习/tensorflow:修订间差异
来自康健生活
| (未显示同一用户的6个中间版本) | |||
| 第6行: | 第6行: | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
# cpu | # cpu | ||
pip3 install --user --upgrade tensorflow | |||
# gpu | # gpu | ||
pip3 install --user --upgrade tensorflow-gpu</syntaxhighlight>|$|/home/kangkk}} | |||
== 验证 == | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
python3 -c "import tensorflow as tf; print(tf.__version__)"</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
2.7.0 | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
记录设备指派,查看安装的是 CPU 版本还是 GPU 版本。 | |||
{{Hc|checkCPUorGPU.py|<syntaxhighlight lang="python"> | |||
from tensorflow.python.client import device_lib | |||
print(device_lib.list_local_devices())</syntaxhighlight>}} | |||
运行。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
python3</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
2022-01-11 10:24:24.961021: 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. | |||
2022-01-11 10:24:25.008910: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:939] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero | |||
2022-01-11 10:24:25.039715: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:939] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero | |||
2022-01-11 10:24:25.040046: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:939] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero | |||
2022-01-11 10:24:25.443047: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:939] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero | |||
2022-01-11 10:24:25.443223: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:939] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero | |||
2022-01-11 10:24:25.443359: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:939] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero | |||
2022-01-11 10:24:25.443480: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /device:GPU:0 with 4334 MB memory: -> device: 0, name: NVIDIA GeForce RTX 2060, pci bus id: 0000:01:00.0, compute capability: 7.5 | |||
[name: "/device:CPU:0" | |||
device_type: "CPU" | |||
memory_limit: 268435456 | |||
locality { | |||
} | |||
incarnation: 15345514099449454557 | |||
xla_global_id: -1 | |||
, name: "/device:GPU:0" | |||
device_type: "GPU" | |||
memory_limit: 4544790528 | |||
locality { | |||
bus_id: 1 | |||
links { | |||
} | |||
} | |||
incarnation: 13290349683484369395 | |||
physical_device_desc: "device: 0, name: NVIDIA GeForce RTX 2060, pci bus id: 0000:01:00.0, compute capability: 7.5" | |||
xla_global_id: 416903419 | |||
] | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
或者使用 | |||
{{Hc|checkCPUorGPU_2.py|<syntaxhighlight lang="python"> | |||
import tensorflow as tf | |||
tf.compat.v1.disable_eager_execution() | |||
hello = tf.constant('hello,tensorflow') | |||
sess= tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True)) | |||
print(sess.run(hello))</syntaxhighlight>}} | |||
== error == | |||
* successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero | |||
: [https://stackoverflow.com/questions/44232898/memoryerror-in-tensorflow-and-successful-numa-node-read-from-sysfs-had-negativ MemoryError in TensorFlow; and "successful NUMA node read from SysFS had negative value (-1)" with xen] | |||