TensorFlowのGPUが利用可能かどうかを確認
5654 ワード
TensorFlowでGPUが利用可能かどうかをテストする方法は以下の通りです.
結果情報は次のとおりです.
Python 3.6.10 |Anaconda, Inc.| (default, May 8 2020, 02:54:21) [GCC 7.3.0] on linux Type "help", "copyright", "credits"or "license"for more information. >>> import tensorflow as tf >>> print(tf.test.is_gpu_available()) 2020-09-14 11:09:34.695211: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA 2020-09-14 11:09:34.712743: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2299995000 Hz 2020-09-14 11:09:34.718083: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55e762b39f80 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2020-09-14 11:09:34.718134: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version 2020-09-14 11:09:34.723355: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1 2020-09-14 11:09:35.328848: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55e762b3c360 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices: 2020-09-14 11:09:35.328909: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Tesla T4, Compute Capability 7.5 2020-09-14 11:09:35.328927: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (1): Tesla T4, Compute Capability 7.5 2020-09-14 11:09:35.328941: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (2): Tesla T4, Compute Capability 7.5 2020-09-14 11:09:35.328955: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (3): Tesla T4, Compute Capability 7.5 2020-09-14 11:09:35.341708: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties: name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59 pciBusID: 0000:3d:00.0 2020-09-14 11:09:35.342782: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 1 with properties: name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59 pciBusID: 0000:41:00.0 2020-09-14 11:09:35.343280: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 2 with properties: name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59 pciBusID: 0000:b2:00.0 2020-09-14 11:09:35.344143: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 3 with properties: name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59 pciBusID: 0000:b4:00.0 2020-09-14 11:09:35.344512: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.0 2020-09-14 11:09:35.345907: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10.0 2020-09-14 11:09:35.347267: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10.0 2020-09-14 11:09:35.347571: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10.0 2020-09-14 11:09:35.349150: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10.0 2020-09-14 11:09:35.350462: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10.0 2020-09-14 11:09:35.369273: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7 2020-09-14 11:09:35.375792: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0, 1, 2, 3 2020-09-14 11:09:35.375845: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.0 2020-09-14 11:09:35.379653: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect StreamExecutor with strength 1 edge matrix: 2020-09-14 11:09:35.379672: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0 1 2 3 2020-09-14 11:09:35.379679: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N Y Y Y 2020-09-14 11:09:35.379685: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 1: Y N Y Y 2020-09-14 11:09:35.379691: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 2: Y Y N Y 2020-09-14 11:09:35.379697: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 3: Y Y Y N 2020-09-14 11:09:35.384008: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/device:GPU:0 with 12160 MB memory) -> physical GPU (device: 0, name: Tesla T4, pci bus id: 0000:3d:00.0, compute capability: 7.5) 2020-09-14 11:09:35.385873: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/device:GPU:1 with 14249 MB memory) -> physical GPU (device: 1, name: Tesla T4, pci bus id: 0000:41:00.0, compute capability: 7.5) 2020-09-14 11:09:35.386768: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/device:GPU:2 with 154 MB memory) -> physical GPU (device: 2, name: Tesla T4, pci bus id: 0000:b2:00.0, compute capability: 7.5) 2020-09-14 11:09:35.390115: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/device:GPU:3 with 9941 MB memory) -> physical GPU (device: 3, name: Tesla T4, pci bus id: 0000:b4:00.0, compute capability: 7.5) True
import tensorflow as tf
print(tf.test.is_gpu_available())
結果情報は次のとおりです.
Python 3.6.10 |Anaconda, Inc.| (default, May 8 2020, 02:54:21) [GCC 7.3.0] on linux Type "help", "copyright", "credits"or "license"for more information. >>> import tensorflow as tf >>> print(tf.test.is_gpu_available()) 2020-09-14 11:09:34.695211: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA 2020-09-14 11:09:34.712743: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2299995000 Hz 2020-09-14 11:09:34.718083: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55e762b39f80 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2020-09-14 11:09:34.718134: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version 2020-09-14 11:09:34.723355: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1 2020-09-14 11:09:35.328848: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55e762b3c360 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices: 2020-09-14 11:09:35.328909: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Tesla T4, Compute Capability 7.5 2020-09-14 11:09:35.328927: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (1): Tesla T4, Compute Capability 7.5 2020-09-14 11:09:35.328941: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (2): Tesla T4, Compute Capability 7.5 2020-09-14 11:09:35.328955: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (3): Tesla T4, Compute Capability 7.5 2020-09-14 11:09:35.341708: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties: name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59 pciBusID: 0000:3d:00.0 2020-09-14 11:09:35.342782: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 1 with properties: name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59 pciBusID: 0000:41:00.0 2020-09-14 11:09:35.343280: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 2 with properties: name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59 pciBusID: 0000:b2:00.0 2020-09-14 11:09:35.344143: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 3 with properties: name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59 pciBusID: 0000:b4:00.0 2020-09-14 11:09:35.344512: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.0 2020-09-14 11:09:35.345907: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10.0 2020-09-14 11:09:35.347267: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10.0 2020-09-14 11:09:35.347571: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10.0 2020-09-14 11:09:35.349150: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10.0 2020-09-14 11:09:35.350462: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10.0 2020-09-14 11:09:35.369273: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7 2020-09-14 11:09:35.375792: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0, 1, 2, 3 2020-09-14 11:09:35.375845: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.0 2020-09-14 11:09:35.379653: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect StreamExecutor with strength 1 edge matrix: 2020-09-14 11:09:35.379672: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0 1 2 3 2020-09-14 11:09:35.379679: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N Y Y Y 2020-09-14 11:09:35.379685: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 1: Y N Y Y 2020-09-14 11:09:35.379691: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 2: Y Y N Y 2020-09-14 11:09:35.379697: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 3: Y Y Y N 2020-09-14 11:09:35.384008: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/device:GPU:0 with 12160 MB memory) -> physical GPU (device: 0, name: Tesla T4, pci bus id: 0000:3d:00.0, compute capability: 7.5) 2020-09-14 11:09:35.385873: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/device:GPU:1 with 14249 MB memory) -> physical GPU (device: 1, name: Tesla T4, pci bus id: 0000:41:00.0, compute capability: 7.5) 2020-09-14 11:09:35.386768: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/device:GPU:2 with 154 MB memory) -> physical GPU (device: 2, name: Tesla T4, pci bus id: 0000:b2:00.0, compute capability: 7.5) 2020-09-14 11:09:35.390115: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/device:GPU:3 with 9941 MB memory) -> physical GPU (device: 3, name: Tesla T4, pci bus id: 0000:b4:00.0, compute capability: 7.5) True