{"id":2411,"date":"2021-03-24T11:11:38","date_gmt":"2021-03-24T02:11:38","guid":{"rendered":"http:\/\/int-info.com\/?page_id=2411"},"modified":"2021-03-24T18:58:59","modified_gmt":"2021-03-24T09:58:59","slug":"kerasmac_init","status":"publish","type":"page","link":"http:\/\/int-info.com\/index.php\/kerasmac_init\/","title":{"rendered":"KerasMac_init"},"content":{"rendered":"<h4 style=\"padding: 0.1em 0.3em; border-left: 10px solid #1E88E5; border-bottom: 3px solid #B0BEC5;\"> \u306f\u3058\u3081\u306b <\/h4>\n<p>\u3053\u3053\u3067\u306f\u3001Macbook\u306b\u642d\u8f09\u3055\u308c\u3066\u3044\u308bNVIDIA\u88fd\u4ee5\u5916\u306eGPU\u3067Keras\u3092\u52d5\u304b\u3059\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a00\u53ca\u3057\u307e\u3059\u3002\u5468\u77e5\u306e\u901a\u308a\u30012020\u5e743\u670824\u65e5\u73fe\u5728\u3001Keras\u306e\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306b\u3042\u308bTensorFlow\u306fNVIDIA\u88fd\u306eGPU\u306b\u3057\u304b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u901a\u5e38\u306e\u65b9\u6cd5\u3067\u306fKeras\u3092\u52d5\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002\u666e\u901a\u306fNVIDIA\u88fd\u306eGPU\u304c\u5165\u3063\u305fLinux OS\uff08Ubuntsu\u306a\u3069\uff09\u306e\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3092\u7528\u610f\u3059\u308c\u3070\u3044\u3044\u3067\u3059\u304c\u3001Macbook\u3092\u6a19\u6e96\u306b\u4f7f\u7528\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u306e\u5834\u5408\u3001\u7c21\u5358\u306a\u691c\u8a3c\u3092\u3057\u305f\u3044\u305f\u3073\u306b\u6bce\u56de\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3092\u5909\u66f4\u3059\u308b\u306e\u306f\u3081\u3093\u3069\u304f\u3055\u3044\u3067\u3059\u3002<\/p>\n<p>\u3057\u305f\u304c\u3063\u3066\u3053\u3053\u3067\u306f\u3001Macbook\u3001\u3068\u3044\u3046\u304b\u3001<b>NVIDIA\u4ee5\u5916\u306eGPU<\/b>\u304c\u642d\u8f09\u3055\u308c\u305f\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3067Keras\u3092\u52d5\u304b\u3059\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a00\u53ca\u3057\u307e\u3059\u3002<\/p>\n<h4 style=\"padding: 0.1em 0.3em; border-left: 10px solid #1E88E5; border-bottom: 3px solid #B0BEC5;\"> \u74b0\u5883\u8a2d\u5b9a <\/h4>\n<p>\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u30b7\u30a7\u30eb\u306f\u3001zsh\u3067\u306f\u306a\u304f\u3001bash\u306b\u3057\u3066\u304a\u304f\u65b9\u304c\u7121\u96e3\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u6700\u8fd1\u306emacbook\u306f\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u521d\u671f\u8a2d\u5b9a\u304czsh\u304c\u521d\u671f\u8a2d\u5b9a\u306b\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002env\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3061\u3001SHELL=\/bin\/bash\u3068\u306a\u3063\u3066\u3044\u308c\u3070bash\u3001SHELL=\/bin\/zsh\u3068\u306a\u3063\u3066\u3044\u308c\u3070zsh\u3067\u3059\u3002\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u74b0\u5883\u8a2d\u5b9a\u3067\u30b7\u30a7\u30eb\u306e\u5909\u66f4\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u7d9a\u3044\u3066\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u4ee5\u4e0b\u3092\u5165\u529b\u3057\u307e\u3059\u3002pip3\u306f\u4e00\u5ea6\u306e\u307f\u3067ok\u3067\u3059\u3002<\/p>\n<pre>\r\npip3 install plaidml-keras plaidbench\r\n<\/pre>\n<p>plaidml\u3068\u306f\u3001NVIDIA\u4ee5\u5916\u306eGPU\u304c\u6271\u3048\u308b\u6df1\u5c64\u5b66\u7fd2\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002Keras\u306e\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306b\u306a\u308a\u307e\u3059\u3002\u7d9a\u3044\u3066\u3001export\u30b3\u30de\u30f3\u30c9\u3067\u74b0\u5883\u5909\u6570\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nexport PLAIDML_NATIVE_PATH=\/usr\/local\/lib\/libplaidml.dylib\r\nexport RUNFILES_DIR=\/usr\/local\/share\/plaidml\r\n<\/pre>\n<p>PLAIDML_NATIVE_PATH\u306f\u3001libplaidml.dylib\u3092\u30d5\u30eb\u30d1\u30b9\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002\u901a\u5e38\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306e\u5834\u5408\u306f\u4e0a\u306e\u30d1\u30b9\u3067\u3044\u3044\u306f\u305a\u3067\u3059\u304c\u3001\u3053\u308c\u3067\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u5834\u5408\u306f\u3001libplaidml.dylib\u304c\u3069\u3053\u306b\u3042\u308b\u304b\u63a2\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u6253\u3061\u8fbc\u3093\u3060\u3089\u3001<\/p>\n<pre>\r\nexport\r\n<\/pre>\n<p>\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3061\u3001\u304d\u3061\u3093\u3068\u53cd\u6620\u3055\u308c\u3066\u3044\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002\u7d9a\u3044\u3066\u3001\u3069\u306eCPU\/GPU\u3092\u4f7f\u7528\u3059\u308b\u304b\u3001\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u3053\u306e\u305f\u3081\u306b\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3061\u307e\u3059\u3002<\/p>\n<pre>\r\nplaidml-setup\r\n<\/pre>\n<p>\u3053\u3053\u3067yes\u3092\u9078\u629e\u3059\u308b\u3068\u3001CPU\/GPU\u3069\u308c\u3092\u4f7f\u3046\u304b\u805e\u304b\u308c\u308b\u306e\u3067\u3001\u6570\u5b57\u3067\u4f7f\u7528\u3059\u308b\u3082\u306e\u3092\u9078\u3073\u307e\u3059\u3002\u901a\u5e38\u306f1\u3092\u9078\u629e\u3059\u308b\u3068CPU\u306b\u306a\u308a\u3001\u305d\u308c\u3088\u308a\u5927\u304d\u3044\u6570\u5b57\u3060\u3068GPU\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>\r\n- 1: llvm_cpu.0\r\n- 2: opencl_intel(r) hd graphics_615.0\r\n- 3: metal_intel(r) hd graphics_615.0\r\n<\/pre>\n<p>\u5927\u524d\u306e\u74b0\u5883\u3060\u3068\u3001\u3053\u3093\u306a\u611f\u3058\u306e\u9078\u629e\u80a2\u304c\u51fa\u3066\u304d\u307e\u3059\u30022, 3\u304c\u30ce\u30fc\u30c8\u30d1\u30bd\u30b3\u30f3\u306e\u76f8\u5f53\u3057\u3087\u307c\u3044GPU\u3067\u3059\u3002\u5916\u4ed8\u3051GPU\u3092\u63a5\u7d9a\u3059\u308b\u3068\u3001\u3053\u3053\u306b\u305d\u308c\u304c\u51fa\u3066\u304f\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff08\u624b\u6301\u3061\u304c\u306a\u3044\u306e\u3067\u672a\u691c\u8a3c\uff09\u3002\u9078\u629e\u3059\u308b\u3068\u3001\u4fdd\u5b58\u3059\u308b\u304b\u3069\u3046\u304b\u51fa\u308b\u306e\u3067\u3001\u4fdd\u5b58\u3057\u307e\u3059\u3002\u7d9a\u3044\u3066\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u6253\u3064\u3068\u3001\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u304c\u51fa\u3066\u304d\u307e\u3059\u3002<\/p>\n<pre>\r\nplaidbench keras mobilenet\r\n<\/pre>\n<p>\u5b89\u4fa1\u306aGPU\u3060\u306820\u301c30\u79d2\u3001CPU\u3060\u30682\u301c3\u5206\u3068\u3044\u3046\u611f\u3058\u3067\u3057\u3087\u3046\u304b\u3002\u5b89\u4fa1\u306aGPU\u3067\u3082\u3001\u4e26\u5217\u51e6\u7406\u304c\u3067\u304d\u308b\u306e\u3067\u304b\u306a\u308a\u901f\u304f\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u3067\u8a2d\u5b9a\u304c\u7d42\u308f\u308a\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u5f8c\u3001python\u4e0a\u3067Keras\u306e\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3092plaidml\u306b\u3059\u308b\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nexport KERAS_BACKEND=plaidml.keras.backend\r\n<\/pre>\n<p>\u3053\u308c\u3067ok\u3067\u3059\u3002\u3053\u306e\u72b6\u614b\u3067jupyter notebook\u3092\u958b\u304f\u3068\u3001Keras\u304cGPU\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><\/br><\/p>\n<h4 style=\"padding: 0.1em 0.3em; border-left: 10px solid #1E88E5; border-bottom: 3px solid #B0BEC5;\"> \u6c38\u7d9a\u5316 <\/h4>\n<p>\u3055\u3066\u3001\u304a\u305d\u3089\u304f\u3054\u5b58\u77e5\u306e\u65b9\u3082\u591a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001export\u30b3\u30de\u30f3\u30c9\u306b\u3088\u308b\u74b0\u5883\u8a2d\u5b9a\u306f\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u9589\u3058\u308b\u3068\u6d88\u3048\u53bb\u308a\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066Keras\u3092\u4f7f\u3046\u305f\u3073\u306b\u6bce\u56deexport\u3067\u74b0\u5883\u8a2d\u5b9a\u3092\u884c\u308f\u306a\u304f\u3066\u306f\u306a\u308a\u307e\u305b\u3093\u3002\u3053\u308c\u306f\u5927\u5909\u306a\u306e\u3067\u3001export\u30b3\u30de\u30f3\u30c9\u3092\u306e\u6c38\u7d9a\u5316\u3092\u884c\u3044\u307e\u3059\u3002\u307e\u305a\u3001<\/p>\n<pre>\r\ncd ~\/\r\n<\/pre>\n<p>\u3067\u3001\u30db\u30fc\u30e0\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002\u305d\u3057\u3066\u3001<\/p>\n<pre>\r\nls -a\r\n<\/pre>\n<p>\u3067\u96a0\u3057\u30d5\u30a1\u30a4\u30eb\u3092\u542b\u3081\u3001\u8868\u793a\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u3001\u300c.bash_profile\u300d\u304c\u3042\u308b\u304b\u306a\u3044\u304b\u3001\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3057\u3087\u3046\u3002\u3053\u308c\u306f\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u8d77\u52d5\u6642\u3001\u81ea\u52d5\u7684\u306b\u8aad\u307f\u8fbc\u3080\u30b3\u30de\u30f3\u30c9\u3092\u5b9a\u7fa9\u3059\u308b\u7b87\u6240\u3067\u3059\u3002\u3057\u305f\u304c\u3044\u307e\u3057\u3066\u3001\u3053\u3053\u306bexport\u30b3\u30de\u30f3\u30c9\u3092\u66f8\u304d\u8fbc\u3081\u3070\u3001\u305d\u306e\u5f8c\u3001Keras\u3092\u5b9f\u65bd\u3059\u308b\u305f\u3073\u306b\u6bce\u56deexport\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3064\u5fc5\u8981\u304c\u306a\u304f\u306a\u308a\u307e\u3059\u3002\u305d\u3046\u3044\u3046\u308f\u3051\u3067\u3001\u30db\u30fc\u30e0\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u304d\u3061\u3093\u3068\u79fb\u52d5\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304b\u3089\u3001<\/p>\n<pre>\r\nvi .bash_profile\r\n<\/pre>\n<p>\u3068\u6253\u3061\u8fbc\u307f\u3001\u7de8\u96c6\u753b\u9762\u3092\u958b\u304d\u307e\u3059\uff08<b><font color=\"red\">zsh\u4f7f\u3044\u306e\u5834\u5408\u306f\u3001\u300c.zprofile\u300d\u3089\u3057\u3044<\/font><\/b>\uff09\u3002\u3053\u3053\u3067\u3001<\/p>\n<pre>\r\nexport PLAIDML_NATIVE_PATH=\/usr\/local\/lib\/libplaidml.dylib\r\nexport RUNFILES_DIR=\/usr\/local\/share\/plaidml\r\nexport KERAS_BACKEND=plaidml.keras.backend\r\n<\/pre>\n<p>\u3068\u66f8\u304d\u8fbc\u3081\u3070ok\u3067\u3059\u3002vim\u306e\u7de8\u96c6\u306b\u3064\u3044\u3066\u306f\u3001\u3053\u3053\u3067\u306f\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u305b\u3093\u304c\u3001<\/p>\n<pre>\r\n\u300ci\u300d\u304c\u66f8\u304d\u8fbc\u307f\u30e2\u30fc\u30c9\r\n\u300cesc\u300d\u304c\u95b2\u89a7\u30e2\u30fc\u30c9\r\n\u300c:wq\u300d\u304c\u4e0a\u66f8\u304d\u4fdd\u5b58\r\n<\/pre>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002\u66f8\u304d\u8fbc\u307f\u30e2\u30fc\u30c9\u306b\u3057\u3066\u304b\u3089\u3001\u30b3\u30de\u30f3\u30c9\u3092\u66f8\u304d\u8fbc\u307f\u3001\u95b2\u89a7\u30e2\u30fc\u30c9\u306b\u3057\u3066\u3001\u4e0a\u66f8\u304d\u4fdd\u5b58\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u6700\u5f8c\u306b\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u4e00\u5ea6\u9589\u3058\u3066\u3001<\/p>\n<pre>\r\nexport\r\n<\/pre>\n<p>\u3068\u53e9\u304d\u3001\u5148\u307b\u3069\u6307\u5b9a\u3057\u305f3\u3064\u306e\u74b0\u5883\u5909\u6570\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308c\u3070\u3001\u6c38\u7d9a\u5316\u306b\u6210\u529f\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><\/br><\/p>\n<h4 style=\"padding: 0.1em 0.3em; border-left: 10px solid #1E88E5; border-bottom: 3px solid #B0BEC5;\"> \u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u304c\u5909\u308f\u3089\u306a\u3044\u554f\u984c <\/h4>\n<pre>\r\nexport KERAS_BACKEND=plaidml.keras.backend\r\n<\/pre>\n<p>\u3092\u5b9f\u65bd\u3057\u3066\u3082\u3001\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u304c\u5909\u308f\u3089\u306a\u3044\u3068\u3044\u3046\u554f\u984c\u304c\u8d77\u3053\u308b\u3088\u3046\u3067\u3059\u3002\u7d30\u304b\u304f\u691c\u8a3c\u3057\u305f\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001<\/p>\n<pre>\r\npip3 install tensorflow\r\n<\/pre>\n<p>\u3092\u5b9f\u65bd\u3059\u308b\u3068\u3001\u3069\u3053\u304b\u3067\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3092tensorflow\u306b\u56fa\u5b9a\u3055\u308c\u308b\u3088\u3046\u3067\u3059\u3002\u3053\u308c\u3092\u89e3\u9664\u3059\u308b\u5834\u5408\u306f\u3001<\/p>\n<pre>\r\npip3 uninstall plaidml-keras\r\n<\/pre>\n<p>\u3068\u3057\u3066\u3001\u4e00\u5ea6plaidml-keras\u3092\u6d88\u3057\u307e\u3059\u3002\u305d\u306e\u5f8c\u3082\u3046\u4e00\u5ea6\u3001<\/p>\n<pre>\r\npip3 install plaidml-keras\r\n<\/pre>\n<p>\u3068\u66f8\u3051\u3070\u3001\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u304c\u7121\u4e8b\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u691c\u8a3c\u3057\u305f\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u3001<\/p>\n<pre>\r\ntensorflow: 2.3.0\r\nplaidml-keras: 0.7.0 \r\n<\/pre>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002\u3042\u3068\u539f\u56e0\u306b\u306a\u308a\u305d\u3046\u306a\u306e\u306f\u3001\u30db\u30fc\u30e0\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u76f4\u4e0b\u306e.keras\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3042\u308bjson\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<\/p>\n<pre>\r\ncd ~\/.keras\r\n<\/pre>\n<p>\u306b\u3042\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u3001vi keras.json\u3092\u3059\u308b\u3068\u3001\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306e\u6307\u5b9a\u304c\u3042\u308a\u307e\u3059\u3001\u304c\u3001\u3053\u308c\u306f\u3069\u3046\u3084\u3089\u539f\u56e0\u306b\u306f\u306a\u3089\u306a\u3044\u304b\u3082\uff1f\u3057\u308c\u307e\u305b\u3093\u3002\u30e1\u30e2\u304c\u308f\u308a\u306b\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b \u3053\u3053\u3067\u306f\u3001Macbook\u306b\u642d\u8f09\u3055\u308c\u3066\u3044\u308bNVIDIA\u88fd\u4ee5\u5916\u306eGPU\u3067Keras\u3092\u52d5\u304b\u3059\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a00\u53ca\u3057\u307e\u3059\u3002\u5468\u77e5\u306e\u901a\u308a\u30012020\u5e743\u670824\u65e5\u73fe\u5728\u3001Keras\u306e\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306b\u3042\u308bTensorFlow\u306fNVIDI<\/p><\/div>\n<div class=\"blog-btn\"><a href=\"http:\/\/int-info.com\/index.php\/kerasmac_init\/\" class=\"home-blog-btn\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2411","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages\/2411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/comments?post=2411"}],"version-history":[{"count":7,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages\/2411\/revisions"}],"predecessor-version":[{"id":2426,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages\/2411\/revisions\/2426"}],"wp:attachment":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/media?parent=2411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}