当前位置:网站首页>Installation and testing of open source deep learning framework plaidml

Installation and testing of open source deep learning framework plaidml

2022-06-12 19:43:00 Ouchen Eli

Open source links :

GitHub - plaidml/plaidml: PlaidML is a framework for making deep learning work everywhere.icon-default.png?t=M4ADhttps://github.com/plaidml/plaidml

PlaidML Open source high performance dedicated to cross platform development and deployment Deep learning frame , at present PlaidML Support Keras,OpenCL,Linux,macOS and Windows Support for . most important of all PlaidML have access to AMD Your graphics card is windows Deep learning on the platform , Because the notebook on hand is only A card , So I decided to try to use A Card GPU Let's try , Although it is based on Opencl The acceleration of , Try and CUDA Comparison of .

1 install PlaidML

1.1 install python

stay windows On the platform PlaidML It's a little bit easier , According to the example on the official website , There's no need to install Chocolatey This software , Just install python and vcredist2015 That's all right. , And the driver of the graphics card needs to be installed , Support OpenCL 1.2 Above version .
 Official website installation instructions

1.2 install PlaidML-keras

This requires installation PlaidML Version of keras,PlaidML-keras The latest version is 0.7, But there was a problem installing the latest version , Specific reference to GitHub Upper issue, So it's best to specify the version to install
pip install plaidml-keras==0.6.4

1.3 function PlaidML-setup

 function Plaid-setup

2 test run

GitHub Upper Hello VGG Example

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.VGG16()
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))

What we use here is keras Standard interface for , Direct import keras The model and predict The function of , The following is the result of the run
 Running results
GPU Usage situation
GPU usage

3 test result

load Opencl The speed of is still very fast , Than tensorflow load CUDA It's faster , Maybe my laptop has less video memory , Only 2G, The results of the operation can be seen batch_size by 8, function 10 Time , The standard VGG16 The size entered is 224x224X3,predictde1 The time is about 0.26 second .

4 Items to be tested

  1. PlaidML Of CPU Speed up
  2. and Tensorflow Comparison of
  3. and OpenCV Of DNN Module acceleration effect comparison
原网站

版权声明
本文为[Ouchen Eli]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206121936498035.html