[Python] tensorflow 프레임워크 GPU 인식 확인

overFlowoong·2023년 6월 28일

Tensorflow GPU

목록 보기
1/1
post-thumbnail

이 포스트를 작성하는 지금을 기준으로, 작성중이다가 임시 저장해놓은 포스트만 계속 쌓이는 중이다. 그래서 우선 빠르게 작성할만한 주제는 생각날때마다 뚝딱 올리기로 했다..


Tensorflow GPU 인식 확인하기

여러 방법이 있지만 그 중 내가 주로 사용하는 방법들이다.


1. tf.config.list_physical_devices

import tensorflow as tf

print(tf.config.list_physical_devices('GPU'))

또는

print(tf.config.experimental.list_physical_devices('GPU'))

GPU가 잘 인식이 된다면 사용 가능한 GPU 디바이스 목록이 리스트로 표시된다.

출력 예시)

out : [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]





2. device_lib.list_local_devices()

from tensorflow.python.client import device_lib

print(device_lib.list_local_devices())

정상 인식 시 출력 예시)

out :
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 8606362468862827186
xla_global_id: -1
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 13013876736
locality {
  bus_id: 2
  numa_node: 1
  links {
  }
}
incarnation: 3487203754861016666
physical_device_desc: "device: 0, name: CUDA GPU, pci bus id: 0000:86:00.0, compute capability: 7.5"
xla_global_id: 416903419
]





3.tf.test.is_built_with_cuda

import tensorflow as tf

print(tf.test.gpu_device_name())

정상 인식 출력 예시)

out : '/device:GPU:0'
profile
나도 할래 기술 블로그!

0개의 댓글