机器学习/tensorflow:修订间差异
来自康健生活
< 机器学习
| 第53行: | 第53行: | ||
] | ] | ||
</syntaxhighlight>|$|/home/kangkk}} | </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 == | == 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 | * 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] | : [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] | ||
2022年1月11日 (二) 03:42的最新版本
引言
tensorflow 分为 CPU 版本和 GPU 版本。
卸载
安装
/home/kangkk
# cpu
pip3 install --user --upgrade tensorflow
# gpu
pip3 install --user --upgrade tensorflow-gpu
验证
[jian@kang /home/kangkk]$
python3 -c "import tensorflow as tf; print(tf.__version__)"
2.7.0
记录设备指派,查看安装的是 CPU 版本还是 GPU 版本。
checkCPUorGPU.py
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
运行。
[jian@kang /home/kangkk]$
python3
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
]
或者使用
checkCPUorGPU_2.py
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))
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
No categories