๐Ÿ’ฉ ์—๋Ÿฌ ํ•ด๊ฒฐ

[Tensorflow/์—๋Ÿฌ ํ•ด๊ฒฐ] Memory growth cannot differ between GPU devices

๋ณต๋งŒ 2021. 12. 3. 19:01

์ถœ์ฒ˜ : https://fixexception.com/tensorflow/memory-growth-cannot-differ-between-gpu-devices/

 

๋ฉ”๋ชจ๋ฆฌ ์ฆ๊ฐ€๋ฅผ ํ—ˆ์šฉ์„ ๊ฒฐ์ •ํ•˜๋Š” ํ•จ์ˆ˜์ธ tf.config.experimental.set_memory_growth๋ฅผ ์ด์šฉํ•  ๋•Œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.

 

ValueError: Memory growth cannot differ between GPU devices

 

์ด๋Š” gpu๊ฐ€ ์—ฌ๋Ÿฌ ๊ฐœ ์žˆ์„ ๋•Œ, ๋ชจ๋“  gpu์— ๋Œ€ํ•ด memory growth๋ฅผ ๋™์ผํ•˜๊ฒŒ ์„ธํŒ…ํ•ด์ฃผ์ง€ ์•Š์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ์ด๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด gpu๊ฐ€ ๋‘ ๋Œ€ ์žˆ๋Š”๋ฐ ํ•˜๋‚˜์˜ gpu์—๋งŒ set_memory_growth๋ฅผ True๋กœ ์„ค์ •ํ•ด์ฃผ์—ˆ์„ ๊ฒฝ์šฐ์ด๋‹ค.

์ด ๊ฒฝ์šฐ์—๋Š” ๋ชจ๋“  gpu์— ๋Œ€ํ•ด set_memory_growth๋ฅผ ๋™์ผํ•˜๊ฒŒ ์„ค์ •ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

 

์˜ˆ์‹œ)

gpus = tf.config.list_physical_devices('GPU')
for i in range(len(gpus)):
	tf.config.experimental.set_memory_growth(gpu[i], True)
๋ฐ˜์‘ํ˜•