deep learning with R installed on macOS with PlaidML (AMD GPU)

Published by onesixx on

R 언어를 이용해 Deep Learning을 macbook의 GPU를 사용해서 분석하기 위한 환경설정.

reticulate 설치 (R interface to Python)

https://rstudio.github.io/reticulate/
https://github.com/rstudio/reticulate
https://blog.rstudio.com/tags/reticulate
R

‘reticulate’, ‘tensorflow’ (‘tfruns’) 등의 패키지들과 함께 keras 설치

Keras 설치

high-level neural networks API written in Python for using TensorFlow, CNTK, or Theano

R

miniconda 설치

miniconda는 ~/Library/r-miniconda에 설치되었고,

No non-system installation of Python could be found.
Would you like to download and install Miniconda?
Miniconda is an open source environment management system for Python.
See https://docs.conda.io/en/latest/miniconda.html for more details.

Would you like to install Miniconda? [Y/n]: Y
* Downloading 'https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh' ...
trying URL 'https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh'
Content type 'application/x-sh' length 52755183 bytes (50.3 MB)
==================================================
downloaded 50.3 MB

* Installing Miniconda -- please wait a moment ...
PREFIX=/Users/onesixx/Library/r-miniconda
Unpacking payload ...
Collecting package metadata (current_repodata.json): ...working... done                                       
Solving environment: ...working... done
## Package Plan ##

  environment location: /Users/onesixx/Library/r-miniconda

  added / updated specs:
    - asn1crypto==1.3.0=py37_0
    - ca-certificates==2020.1.1=0
    - certifi==2019.11.28=py37_0
    - cffi==1.14.0=py37hb5b8e2f_0
    - chardet==3.0.4=py37_1003
    - conda-package-handling==1.6.0=py37h1de35cc_0
    - conda==4.8.2=py37_0
    - cryptography==2.8=py37ha12b0ac_0
    - idna==2.8=py37_0
    - libcxx==4.0.1=hcfea43d_1
    - libcxxabi==4.0.1=hcfea43d_1
    - libedit==3.1.20181209=hb402a30_0
    - libffi==3.2.1=h475c297_4
    - ncurses==6.2=h0a44026_0
    - openssl==1.1.1d=h1de35cc_4
    - pip==20.0.2=py37_1
    - pycosat==0.6.3=py37h1de35cc_0
    - pycparser==2.19=py37_0
    - pyopenssl==19.1.0=py37_0
    - pysocks==1.7.1=py37_0
    - python.app==2=py37_10
    - python==3.7.6=h359304d_2
    - readline==7.0=h1de35cc_5
    - requests==2.22.0=py37_1
    - ruamel_yaml==0.15.87=py37h1de35cc_0
    - setuptools==45.2.0=py37_0
    - six==1.14.0=py37_0
    - sqlite==3.31.1=ha441bb4_0
    - tk==8.6.8=ha441bb4_0
    - tqdm==4.42.1=py_0
    - urllib3==1.25.8=py37_0
    - wheel==0.34.2=py37_0
    - xz==5.2.4=h1de35cc_4
    - yaml==0.1.7=hc338f04_2
    - zlib==1.2.11=h1de35cc_3


The following NEW packages will be INSTALLED:

  asn1crypto         pkgs/main/osx-64::asn1crypto-1.3.0-py37_0
  ca-certificates    pkgs/main/osx-64::ca-certificates-2020.1.1-0
  certifi            pkgs/main/osx-64::certifi-2019.11.28-py37_0
  cffi               pkgs/main/osx-64::cffi-1.14.0-py37hb5b8e2f_0
  chardet            pkgs/main/osx-64::chardet-3.0.4-py37_1003
  conda              pkgs/main/osx-64::conda-4.8.2-py37_0
  conda-package-han~ pkgs/main/osx-64::conda-package-handling-1.6.0-py37h1de35cc_0
  cryptography       pkgs/main/osx-64::cryptography-2.8-py37ha12b0ac_0
  idna               pkgs/main/osx-64::idna-2.8-py37_0
  libcxx             pkgs/main/osx-64::libcxx-4.0.1-hcfea43d_1
  libcxxabi          pkgs/main/osx-64::libcxxabi-4.0.1-hcfea43d_1
  libedit            pkgs/main/osx-64::libedit-3.1.20181209-hb402a30_0
  libffi             pkgs/main/osx-64::libffi-3.2.1-h475c297_4
  ncurses            pkgs/main/osx-64::ncurses-6.2-h0a44026_0
  openssl            pkgs/main/osx-64::openssl-1.1.1d-h1de35cc_4
  pip                pkgs/main/osx-64::pip-20.0.2-py37_1
  pycosat            pkgs/main/osx-64::pycosat-0.6.3-py37h1de35cc_0
  pycparser          pkgs/main/osx-64::pycparser-2.19-py37_0
  pyopenssl          pkgs/main/osx-64::pyopenssl-19.1.0-py37_0
  pysocks            pkgs/main/osx-64::pysocks-1.7.1-py37_0
  python             pkgs/main/osx-64::python-3.7.6-h359304d_2
  python.app         pkgs/main/osx-64::python.app-2-py37_10
  readline           pkgs/main/osx-64::readline-7.0-h1de35cc_5
  requests           pkgs/main/osx-64::requests-2.22.0-py37_1
  ruamel_yaml        pkgs/main/osx-64::ruamel_yaml-0.15.87-py37h1de35cc_0
  setuptools         pkgs/main/osx-64::setuptools-45.2.0-py37_0
  six                pkgs/main/osx-64::six-1.14.0-py37_0
  sqlite             pkgs/main/osx-64::sqlite-3.31.1-ha441bb4_0
  tk                 pkgs/main/osx-64::tk-8.6.8-ha441bb4_0
  tqdm               pkgs/main/noarch::tqdm-4.42.1-py_0
  urllib3            pkgs/main/osx-64::urllib3-1.25.8-py37_0
  wheel              pkgs/main/osx-64::wheel-0.34.2-py37_0
  xz                 pkgs/main/osx-64::xz-5.2.4-h1de35cc_4
  yaml               pkgs/main/osx-64::yaml-0.1.7-hc338f04_2
  zlib               pkgs/main/osx-64::zlib-1.2.11-h1de35cc_3


Preparing transaction: ...working... done
Executing transaction: ...working... done
installation finished.
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
## Package Plan ##

  environment location: /Users/onesixx/Library/r-miniconda/envs/r-reticulate

  added / updated specs:
    - numpy
    - python=3.6


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    blas-1.0                   |              mkl           6 KB
    certifi-2020.4.5.1         |           py36_0         155 KB
    intel-openmp-2019.4        |              233         887 KB
    libgfortran-3.0.1          |       h93005f0_2         426 KB
    mkl-2019.4                 |              233       101.9 MB
    mkl-service-2.3.0          |   py36hfbe908c_0         202 KB
    mkl_fft-1.0.15             |   py36h5e564d8_0         139 KB
    mkl_random-1.1.0           |   py36ha771720_0         287 KB
    numpy-1.18.1               |   py36h7241aed_0           5 KB
    numpy-base-1.18.1          |   py36h6575580_1         3.9 MB
    pip-20.0.2                 |           py36_1         1.7 MB
    python-3.6.10              |       hc70fcce_1        17.1 MB
    readline-8.0               |       h1de35cc_0         326 KB
    setuptools-46.1.3          |           py36_0         511 KB
    six-1.14.0                 |           py36_0          26 KB
    wheel-0.34.2               |           py36_0          50 KB
    ------------------------------------------------------------
                                           Total:       127.7 MB

The following NEW packages will be INSTALLED:

  blas               pkgs/main/osx-64::blas-1.0-mkl
  ca-certificates    pkgs/main/osx-64::ca-certificates-2020.1.1-0
  certifi            pkgs/main/osx-64::certifi-2020.4.5.1-py36_0
  intel-openmp       pkgs/main/osx-64::intel-openmp-2019.4-233
  libcxx             pkgs/main/osx-64::libcxx-4.0.1-hcfea43d_1
  libcxxabi          pkgs/main/osx-64::libcxxabi-4.0.1-hcfea43d_1
  libedit            pkgs/main/osx-64::libedit-3.1.20181209-hb402a30_0
  libffi             pkgs/main/osx-64::libffi-3.2.1-h475c297_4
  libgfortran        pkgs/main/osx-64::libgfortran-3.0.1-h93005f0_2
  mkl                pkgs/main/osx-64::mkl-2019.4-233
  mkl-service        pkgs/main/osx-64::mkl-service-2.3.0-py36hfbe908c_0
  mkl_fft            pkgs/main/osx-64::mkl_fft-1.0.15-py36h5e564d8_0
  mkl_random         pkgs/main/osx-64::mkl_random-1.1.0-py36ha771720_0
  ncurses            pkgs/main/osx-64::ncurses-6.2-h0a44026_0
  numpy              pkgs/main/osx-64::numpy-1.18.1-py36h7241aed_0
  numpy-base         pkgs/main/osx-64::numpy-base-1.18.1-py36h6575580_1
  openssl            pkgs/main/osx-64::openssl-1.1.1g-h1de35cc_0
  pip                pkgs/main/osx-64::pip-20.0.2-py36_1
  python             pkgs/main/osx-64::python-3.6.10-hc70fcce_1
  readline           pkgs/main/osx-64::readline-8.0-h1de35cc_0
  setuptools         pkgs/main/osx-64::setuptools-46.1.3-py36_0
  six                pkgs/main/osx-64::six-1.14.0-py36_0
  sqlite             pkgs/main/osx-64::sqlite-3.31.1-h5c1f38d_1
  tk                 pkgs/main/osx-64::tk-8.6.8-ha441bb4_0
  wheel              pkgs/main/osx-64::wheel-0.34.2-py36_0
  xz                 pkgs/main/osx-64::xz-5.2.5-h1de35cc_0
  zlib               pkgs/main/osx-64::zlib-1.2.11-h1de35cc_3



Downloading and Extracting Packages
mkl_random-1.1.0     | 287 KB    | ########## | 100% 
numpy-base-1.18.1    | 3.9 MB    | ########## | 100% 
readline-8.0         | 326 KB    | ########## | 100% 
six-1.14.0           | 26 KB     | ########## | 100% 
wheel-0.34.2         | 50 KB     | ########## | 100% 
pip-20.0.2           | 1.7 MB    | ########## | 100% 
blas-1.0             | 6 KB      | ########## | 100% 
python-3.6.10        | 17.1 MB   | ########## | 100% 
setuptools-46.1.3    | 511 KB    | ########## | 100% 
mkl-service-2.3.0    | 202 KB    | ########## | 100% 
certifi-2020.4.5.1   | 155 KB    | ########## | 100% 
numpy-1.18.1         | 5 KB      | ########## | 100% 
mkl_fft-1.0.15       | 139 KB    | ########## | 100% 
mkl-2019.4           | 101.9 MB  | ########## | 100% 
libgfortran-3.0.1    | 426 KB    | ########## | 100% 
intel-openmp-2019.4  | 887 KB    | ########## | 100% 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
#
# To activate this environment, use
#
#     $ conda activate r-reticulate
#
# To deactivate an active environment, use
#
#     $ conda deactivate

* Miniconda has been successfully installed at '/Users/onesixx/Library/r-miniconda'.
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

keras CPU버전 설치

Collecting tensorflow==2.0.0
  Using cached tensorflow-2.0.0-cp36-cp36m-macosx_10_11_x86_64.whl (102.7 MB)
Collecting keras
  Using cached Keras-2.3.1-py2.py3-none-any.whl (377 kB)
Collecting tensorflow-hub
  Using cached tensorflow_hub-0.8.0-py2.py3-none-any.whl (101 kB)
Collecting h5py
  Using cached h5py-2.10.0-cp36-cp36m-macosx_10_6_intel.whl (3.0 MB)
Processing /Users/onesixx/Library/Caches/pip/wheels/e5/9d/ad/2ee53cf262cba1ffd8afe1487eef788ea3f260b7e6232a80fc/PyYAML-5.3.1-cp36-cp36m-macosx_10_9_x86_64.whl
Collecting requests
  Using cached requests-2.23.0-py2.py3-none-any.whl (58 kB)
Collecting Pillow
  Using cached Pillow-7.1.1-cp36-cp36m-macosx_10_10_x86_64.whl (2.2 MB)
Collecting scipy
  Using cached scipy-1.4.1-cp36-cp36m-macosx_10_6_intel.whl (28.5 MB)
Requirement already satisfied, skipping upgrade: six>=1.10.0 in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from tensorflow==2.0.0) (1.14.0)
Processing /Users/onesixx/Library/Caches/pip/wheels/c3/af/84/3962a6af7b4ab336e951b7877dcfb758cf94548bb1771e0679/absl_py-0.9.0-py3-none-any.whl
Collecting keras-preprocessing>=1.0.5
  Using cached Keras_Preprocessing-1.1.0-py2.py3-none-any.whl (41 kB)
Collecting google-pasta>=0.1.6
  Using cached google_pasta-0.2.0-py3-none-any.whl (57 kB)
Processing /Users/onesixx/Library/Caches/pip/wheels/93/2a/eb/e58dbcbc963549ee4f065ff80a59f274cc7210b6eab962acdc/termcolor-1.1.0-py3-none-any.whl
Processing /Users/onesixx/Library/Caches/pip/wheels/32/42/7f/23cae9ff6ef66798d00dc5d659088e57dbba01566f6c60db63/wrapt-1.12.1-cp36-cp36m-macosx_10_9_x86_64.whl
Requirement already satisfied, skipping upgrade: wheel>=0.26 in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from tensorflow==2.0.0) (0.34.2)
Processing /Users/onesixx/Library/Caches/pip/wheels/19/a7/b9/0740c7a3a7d1d348f04823339274b90de25fbcd217b2ee1fbe/gast-0.2.2-py3-none-any.whl
Collecting protobuf>=3.6.1
  Using cached protobuf-3.11.3-cp36-cp36m-macosx_10_9_x86_64.whl (1.3 MB)
Collecting tensorboard<2.1.0,>=2.0.0
  Using cached tensorboard-2.0.2-py3-none-any.whl (3.8 MB)
Collecting grpcio>=1.8.6
  Using cached grpcio-1.28.1-cp36-cp36m-macosx_10_9_x86_64.whl (2.6 MB)
Requirement already satisfied, skipping upgrade: numpy<2.0,>=1.16.0 in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from tensorflow==2.0.0) (1.18.1)
Collecting opt-einsum>=2.3.2
  Using cached opt_einsum-3.2.1-py3-none-any.whl (63 kB)
Collecting keras-applications>=1.0.8
  Using cached Keras_Applications-1.0.8-py3-none-any.whl (50 kB)
Collecting tensorflow-estimator<2.1.0,>=2.0.0
  Using cached tensorflow_estimator-2.0.1-py2.py3-none-any.whl (449 kB)
Collecting astor>=0.6.0
  Using cached astor-0.8.1-py2.py3-none-any.whl (27 kB)
Collecting idna<3,>=2.5
  Using cached idna-2.9-py2.py3-none-any.whl (58 kB)
Collecting chardet<4,>=3.0.2
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from requests) (2020.4.5.1)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Using cached urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
Requirement already satisfied, skipping upgrade: setuptools in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from protobuf>=3.6.1->tensorflow==2.0.0) (46.1.3.post20200330)
Collecting google-auth<2,>=1.6.3
  Using cached google_auth-1.14.1-py2.py3-none-any.whl (89 kB)
Collecting google-auth-oauthlib<0.5,>=0.4.1
  Using cached google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)
Collecting werkzeug>=0.11.15
  Using cached Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
Collecting markdown>=2.6.8
  Using cached Markdown-3.2.1-py2.py3-none-any.whl (88 kB)
Collecting rsa<4.1,>=3.1.4
  Using cached rsa-4.0-py2.py3-none-any.whl (38 kB)
Collecting cachetools<5.0,>=2.0.0
  Using cached cachetools-4.1.0-py3-none-any.whl (10 kB)
Collecting pyasn1-modules>=0.2.1
  Using cached pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
Collecting requests-oauthlib>=0.7.0
  Using cached requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting pyasn1>=0.1.3
  Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Collecting oauthlib>=3.0.0
  Using cached oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
Installing collected packages: absl-py, keras-preprocessing, google-pasta, termcolor, wrapt, gast, protobuf, pyasn1, rsa, cachetools, pyasn1-modules, google-auth, idna, chardet, urllib3, requests, oauthlib, requests-oauthlib, google-auth-oauthlib, werkzeug, grpcio, markdown, tensorboard, opt-einsum, h5py, keras-applications, tensorflow-estimator, astor, tensorflow, scipy, pyyaml, keras, tensorflow-hub, Pillow
Successfully installed Pillow-7.1.1 absl-py-0.9.0 astor-0.8.1 cachetools-4.1.0 chardet-3.0.4 gast-0.2.2 google-auth-1.14.1 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.28.1 h5py-2.10.0 idna-2.9 keras-2.3.1 keras-applications-1.0.8 keras-preprocessing-1.1.0 markdown-3.2.1 oauthlib-3.1.0 opt-einsum-3.2.1 protobuf-3.11.3 pyasn1-0.4.8 pyasn1-modules-0.2.8 pyyaml-5.3.1 requests-2.23.0 requests-oauthlib-1.3.0 rsa-4.0 scipy-1.4.1 tensorboard-2.0.2 tensorflow-2.0.0 tensorflow-estimator-2.0.1 tensorflow-hub-0.8.0 termcolor-1.1.0 urllib3-1.25.9 werkzeug-1.0.1 wrapt-1.12.1

Installation complete.


Restarting R session...

miniconda 설정

https://dowtech.tistory.com/14 – conda명령어

conda init 은 ~/.zshrc (또는 ~/bash_profile)에 아래 내용을 추가해 주고,
Terminal을 restart하고, 가상환경을 활성화해서 잘 적용됐는지 확인

Shell
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/onesixx/Library/r-miniconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/onesixx/Library/r-miniconda/etc/profile.d/conda.sh" ]; then
        . "/Users/onesixx/Library/r-miniconda/etc/profile.d/conda.sh"
    else
        export PATH="/Users/onesixx/Library/r-miniconda/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
Shell
R

자동으로 만들어진 r-reticulate (virtual environment)를 activate한다.

Shell
Shell

plaidML (an OpenCL compatible backend)

https://github.com/plaidml/plaidml/
https://plaidml.github.io/plaidml/docs/install.html
https://rpubs.com/siero5335/399690 – Install Keras and PlaidML
https://towardsdatascience.com/deep-learning-using-gpu-on-your-macbook-c9becba7c43
https://tree.rocks/python/mac-amd-gpu-keras-accelerate/
https://keras.rstudio.com/articles/faq.html#how-can-i-use-the-plaidml-backend
https://community.rstudio.com/t/reticulate-1-14-together-with-miniconda3-and-tensorflow-not-working/49180/3

macos 설정 확인

https://onesixx.com/opencl/
https://support.apple.com/ko-kr/HT202823

PlaidML 설치

Shell

PlaidML 설정

PlaidML라이브러리가 Metal(OpenCL)을 통해 Keras의 backend를 책임질 수 있게 설정

Shell
PlaidML Setup (0.7.0)

Thanks for using PlaidML!

The feedback we have received from our users indicates an ever-increasing need
for performance, programmability, and portability. During the past few months,
we have been restructuring PlaidML to address those needs.  To make all the
changes we need to make while supporting our current user base, all development
of PlaidML has moved to a branch — plaidml-v1. We will continue to maintain and
support the master branch of PlaidML and the stable 0.7.0 release.

Read more here: https://github.com/plaidml/plaidml

Some Notes:
  * Bugs and other issues: https://github.com/plaidml/plaidml/issues
  * Questions: https://stackoverflow.com/questions/tagged/plaidml
  * Say hello: https://groups.google.com/forum/#!forum/plaidml-dev
  * PlaidML is licensed under the Apache License 2.0

experimental device는 굳이 enable하지 않고,
3 : metal_amd_radeon_pro_560.0 으로 default device 설정 후
해당 설정은 ~/.plaidml 에 저장

Default Config Devices:
   llvm_cpu.0 : CPU (via LLVM)
   metal_intel(r)_hd_graphics_630.0 : Intel(R) HD Graphics 630 (Metal)
   metal_amd_radeon_pro_560.0 : AMD Radeon Pro 560 (Metal)

Experimental Config Devices:
   llvm_cpu.0 : CPU (via LLVM)
   opencl_amd_radeon_pro_560_compute_engine.0 : AMD AMD Radeon Pro 560 Compute Engine (OpenCL)
   opencl_intel_hd_graphics_630.0 : Intel Inc. Intel(R) HD Graphics 630 (OpenCL)
   metal_intel(r)_hd_graphics_630.0 : Intel(R) HD Graphics 630 (Metal)
   metal_amd_radeon_pro_560.0 : AMD Radeon Pro 560 (Metal)

Using experimental devices can cause poor performance, crashes, and other nastiness.

Enable experimental device support? (y,n)[n]:n

Multiple devices detected (You can override by setting PLAIDML_DEVICE_IDS).
Please choose a default device:

   1 : llvm_cpu.0
   2 : metal_intel(r)_hd_graphics_630.0
   3 : metal_amd_radeon_pro_560.0

Default device? (1,2,3)[1]:3

Selected device:
    metal_amd_radeon_pro_560.0

Almost done. Multiplying some matrices...
Tile code:
  function (B[X,Z], C[Z,Y]) -> (A) { A[x,y : X,Y] = +(B[x,z] * C[z,y]); }
Whew. That worked.

Save settings to /Users/onesixx/.plaidml? (y,n)[y]:y
Success!

테스트

MobileNet in plaidbench를 설치하고, 이를 활용하여 TEST한다.

Shell
Requirement already satisfied: plaidml-keras in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (0.7.0)
Collecting plaidbench
  Using cached plaidbench-0.7.0-py2.py3-none-any.whl (10.1 MB)
Requirement already satisfied: six           in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from plaidml-keras) (1.14.0)
Requirement already satisfied: keras==2.2.4  in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from plaidml-keras) (2.2.4)
Requirement already satisfied: plaidml       in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from plaidml-keras) (0.7.0)
Requirement already satisfied: enum34>=1.1.6 in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from plaidbench) (1.1.10)
Collecting click>=6.0.0
  Using cached click-7.1.1-py2.py3-none-any.whl (82 kB)
Collecting colorama
  Using cached colorama-0.4.3-py2.py3-none-any.whl (15 kB)
Requirement already satisfied: numpy         in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from plaidbench)(1.18.1)
Requirement already satisfied: h5py>=2.7.0   in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from plaidbench) (2.10.0)
Requirement already satisfied: keras-preprocessing>=1.0.5 in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from keras==2.2.4->plaidml-keras) (1.1.0)
Requirement already satisfied: scipy>=0.14   in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from keras==2.2.4->plaidml-keras) (1.4.1)
Requirement already satisfied: pyyaml        in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from keras==2.2.4->plaidml-keras) (5.3.1)
Requirement already satisfied: keras-applications>=1.0.6 in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from keras==2.2.4->plaidml-keras) (1.0.8)
Requirement already satisfied: cffi          in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from plaidml->plaidml-keras) (1.14.0)
Requirement already satisfied: pycparser     in /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages (from cffi->plaidml->plaidml-keras) (2.20)
Installing collected packages: click, colorama, plaidbench
Successfully installed click-7.1.1 colorama-0.4.3 plaidbench-0.7.0
Shell
Running 1024 examples with mobilenet, batch size 1, on backend plaid
INFO:plaidml:Opening device "metal_amd_radeon_pro_560.0"
Compiling network... Warming up... Running...
Example finished, elapsed: 0.494s (compile), 8.796s (execution)

-----------------------------------------------------------------------------------------
Network Name         Inference Latency         Time / FPS
-----------------------------------------------------------------------------------------
mobilenet            8.59 ms                   0.00 ms / 1000000000.00 fps
Correctness: PASS, max_error: 1.675534622336272e-05, max_abs_error: 7.674098014831543e-07, fail_ratio: 0.0

Activity Monitor로 GPU사용 확인

Windows – GPU history ( cmd+4 )
(Mac용 활성 상태 보기 앱> 윈도우 > GPU 기록)

GPU사용 환경 확인 in R

R
> py_config()
python:         /Users/onesixx/Library/r-miniconda/envs/r-reticulate/bin/python
libpython:      /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/libpython3.6m.dylib
pythonhome:     /Users/onesixx/Library/r-miniconda/envs/r-reticulate:/Users/onesixx/Library/r-miniconda/envs/r-reticulate
version:        3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 18:53:43)  [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
numpy:          /Users/onesixx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/numpy
numpy_version:  1.18.1

> conda_list()
          name                                                          python
1  r-miniconda                   /Users/onesixx/Library/r-miniconda/bin/python
2 r-reticulate /Users/onesixx/Library/r-miniconda/envs/r-reticulate/bin/python
R
> tf_config()
TensorFlow v2.0.0 ()
Python v3.6 (~/Library/r-miniconda/envs/r-reticulate/bin/python)

> is_keras_available()
[1] TRUE

TEST using mnist_cnn

https://rpubs.com/siero5335/399690
https://onesixx.com/tutorial-started-with-keras/
R
R

Categories: DL

onesixx

Blog Owner

guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
matt_unt
matt_unt
20-06-29 17:52

thank you very much. It worked for me!
감사합니다

1
0
Would love your thoughts, please comment.x
()
x