- 증상
Tensorflow 실행 시
1) CUDA_OUT_OF_MEMORY
2) CUBLAS_STATUS_ALLOC_FAILED
3) Blas GEMM launch failed 등의 에러 발생
- 원인
- Tensorflow는 실행 시 기본적으로 프로세서에 GPU의 메모리 전부를 미리 할당
- 해결
import tensorflow as tf
'''
1) tf.__version__ <= 2.0.0
'''
config = tf.ConfigProto()
# 1-1) 메모리 수동 할당 (ex] 0.4 = 40% )
config.gpu_options.per_process_gpu_memory_fraction = 0.4
# 1-2) 메모리 자동 할당 (사전 메모리 할당 비활성화 > 사용량에 따라 점차적 증가)
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
'''
2) tf.__version__ >= 2.0.0
'''
gpu_devices = tf.config.experimental.list_physical_devices('GPU')
for device in gpu_devices:
tf.config.experimental.set_memory_growth(device, True)
'프로그래밍 관련 > [Python] 간단 해결' 카테고리의 다른 글
[Python] json.dumps() 한글 > 유니코드로 저장될 때 (0) | 2020.04.22 |
---|---|
[Python] OSError: mysql_config not found (Ubuntu 16.04) (0) | 2020.04.20 |
[CUDA] Windows10에서 간단하게 CUDA 사용률 확인하는 방법 (0) | 2020.02.14 |
[Python] 판다스(Pandas) DataFrame / Print 출력 수 설정 (0) | 2020.02.07 |
[Python] 넘파이(Numpy) / 배열 전체 Print하기 (0) | 2020.02.06 |