[plaidml] 사용 intel iris(GPU) vs i5(CPU)

2020. 7. 14. 12:05DL

728x90
반응형

결론 맥북이 라데온 이상 아니면 설치하지말자.

 

설치

 

[plaidml] 딥러닝 위해 맥북에서 GPU 사용하기(Deep Learning using GPU on your MacBook) -[1 .설치]

가상 환경에 설치했다. 가상 환경이 없다면 python3 -m venv plaidml-venv # plaidml-venv 이름의 가상환경 만들기 source plaidml-venv/bin/activate # plaidml-venv 들어가기 plaidml-keras 설치 pip install -..

uwgdqo.tistory.com

 

plaidbench로 비교 벤치마크 해볼 수 있다.

pip install plaidml-keras plaidbench
plaidbench keras mobilenet

파이썬 파일에서는 아래 거 작성하고 실행하면 된다 한다.

import plaidml.keras
import os

os.environ["KERAS_BACKEND"] = "plaidml.keras.backend"

공식예제

 

#!/usr/bin/env python

import numpy as np
import os
import time

os.environ["KERAS_BACKEND"] = "plaidml.keras.backend"

import keras
import keras.applications as kapp
from keras.datasets import cifar10

(x_train, y_train_cats), (x_test, y_test_cats) = cifar10.load_data()
batch_size = 8
x_train = x_train[:batch_size]
x_train = np.repeat(np.repeat(x_train, 7, axis=1), 7, axis=2)
model = kapp.VGG19()
model.compile(optimizer='sgd', loss='categorical_crossentropy',
              metrics=['accuracy'])

print("Running initial batch (compiling tile program)")
y = model.predict(x=x_train, batch_size=batch_size)

# Now start the clock and run 10 batches
print("Timing inference...")
start = time.time()
for i in range(10):
    y = model.predict(x=x_train, batch_size=batch_size)
print("Ran in {} seconds".format(time.time() - start))

gpu 사용 (keras backend)

cpu사용 (tensorflow)

다른예제 

1 epoch - gpu

 

1 epoch - cpu

 

tensorflow 이용한 cpu가 더 빠르다 2배나 더 알아봐야겠다.

반응형