연구실 서버 한 대에서의 gpu를 나눠써야하는 상황이 발생하여, 각각 사용가능한 gpu의 최대 메모리를 제한하여 사용하는 방식을 사용하였다.
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus: # gpu가 존재한다면 MB단위로 제한 (5GB로 제한)
tf.config.experimental.set_virtual_device_configuration(gpus[0],
[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=5*1024)])
위의 코드를 추가하면 메모리가 제한되는 것을 볼 수 있다.
'Tensorflow' 카테고리의 다른 글
Jeson Nano 에서의 Illegal instruction(core dumped) error (0) | 2022.02.23 |
---|---|
Tensorflow Gpu 확인 및 Gpu 지정하기 (0) | 2022.02.21 |
머신러닝 모델의 분기점 생성 및 병합 (0) | 2022.02.19 |