9566 2022. 3. 23. 21:26
728x90

 

tf

config = tf.ConfigProto()

# 1. GPU 설정
config.gpu_options.visible_device_list = device
# GPU가 2개면, 첫 번째 GPU -> "0", 두번째 GPU -> "1" 로 설정

# 2. GPU 사용량 조절
config.gpu_options.per_process_gpu_memory_fraction = memory_fraction # memory_fraction=1 : 100% 사용
# config.gpu_options.allow_growth = False 
# True : 필요할 때마다 GPU 사용률 조절, False : GPU의 모든 메모리를 점유

# 3. GPU 대비/검사
config.allow_soft_placement = True # 선택한 장치가 없으면 다른 장치로 대체
# config.log_device_placement = True # 어떤 장치로 계산되는지 검사가능

 

*args(arguments) : 

**kwargs(keyword arguments) : (key, value)인 딕셔너리 형태

이 둘은 여러개의 인수 혹은 키워드 인수를 받기 위해 사용된다.

# ex) def abc(*args): <- abc('a', 'b', 'c', 'd') # 여러개의 인수
# ex) def abc(*kwargs): <- abc(name='smile') # 키-벨류 형태

728x90