{"id":1729,"date":"2013-09-30T15:24:49","date_gmt":"2013-09-30T06:24:49","guid":{"rendered":"http:\/\/daily.belltail.jp\/?p=1729"},"modified":"2013-09-30T15:44:41","modified_gmt":"2013-09-30T06:44:41","slug":"cmake%e3%81%a7cuda%e3%81%ae-ccbin%e3%81%ae%e6%ad%a3%e3%81%97%e3%81%84%e6%8c%87%e5%ae%9a%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/daily.belltail.jp\/?p=1729","title":{"rendered":"CMake\u3067CUDA\u306e-ccbin\u306e\u6b63\u3057\u3044\u6307\u5b9a\u65b9\u6cd5"},"content":{"rendered":"<p>\u534a\u5e74\u3076\u308a\u306e\u66f4\u65b0\u3067\u3059\uff0e<br \/>\n\u534a\u5e74\u306e\u9593\u306b\uff0c\u3057\u3089\u3059\u306e\u6625\u306e\u65ec\u3068\u79cb\u306e\u65ec\u3092\u307e\u305f\u3050\u3053\u3068\u306b\u306a\u308a\u307e\u3057\u305f\uff0e<br \/>\n\u3063\u3066\u3044\u3046\u304b\uff0c\u5bd2\u3044\u3088\uff01\u590f\u304c\u3044\u3044\u3088\uff01\uff01\uff1e\uff1c<\/p>\n<p>\u3055\u3066\uff0cLinux\u4e0a\u306eCMake\u3067CUDA\u3092\u4f7f\u3063\u3066\u3044\u308b\u3093\u3067\u3059\u304c\uff0c<font color=\"red\">CUDA\u3067\u306f\u305f\u3044\u3066\u3044\u6700\u65b0\u306eGCC\u306f\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u307e\u305b\u3093\uff0e<\/font><br \/>\n\u3068\u3044\u3046\u3053\u3068\u3067\uff0cnvcc\u306e-ccbin\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u3088\u3063\u3066CUDA\u95a2\u9023\u306e\u30b3\u30f3\u30d1\u30a4\u30eb\u306e\u307f\u3092\u53e4\u3044GCC\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff0e<br \/>\n\u666e\u6bb5\u306eC++\u30b3\u30fc\u30c9\u306f\u6700\u65b0\u306eGCC\u3067\uff0cCUDA\u95a2\u9023\u306e\u307f\u306f\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u305fGCC\u3067\u3054\u5229\u7528\u3044\u305f\u3060\u3051\u307e\u3059\uff0e<\/p>\n<p>CMake\u306b\u304a\u3044\u3066\u3053\u308c\u3092\u884c\u3046\u3068\u304d\u306f\u5c11\u3057\u30af\u30bb\u304c\u3042\u308a\uff0c\u3060\u3044\u3076\u683c\u95d8\u3057\u305f\u306e\u3067\u30e1\u30e2\uff0e<\/p>\n<p>*-ccbin\u306e\u4f8b<\/p>\n<p>\u4f8b\u3048\u3070\u6b21\u306e\u30bd\u30fc\u30b9\u3092\u7528\u610f\u3057\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/\/ prog.cu\r\nint main()\r\n{\r\n}\r\n<\/pre>\n<p>GCC\u306e4.8.1\u3092\u4f7f\u3063\u3066nvcc\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u307f\u308b\u3068\uff0e<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ g++ --version\r\ng++ (GCC) 4.8.1\r\nCopyright (C) 2013 Free Software Foundation, Inc.\r\nThis is free software; see the source for copying conditions.  There is NO\r\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n$ nvcc prog.cu\r\nIn file included from \/usr\/local\/cuda\/bin\/..\/include\/cuda_runtime.h:59:0,\r\n                 from &lt;command-line&gt;:0:\r\n\/usr\/local\/cuda\/bin\/..\/include\/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.7 and up are not supported!\r\n #error -- unsupported GNU version! gcc 4.7 and up are not supported!\r\n  ^\r\n\r\n$ nvcc prog.cu -ccbin g++-4.4\r\n$ .\/a.out\r\n(\u3046\u3054\u3044\u305f)\r\n<\/pre>\n<p>\u3053\u3046\u306a\u308a\u307e\u3059\uff0e<br \/>\n\u3061\u306a\u307f\u306b\u4eca\u56de\u306fCUDA 4.2\u306e\u74b0\u5883\uff0e<\/p>\n<p>*CUDA\u30bd\u30fc\u30b9\u306b\u3088\u308b\u5c0f\u3055\u3044\u30b5\u30f3\u30d7\u30eb<\/p>\n<p>\u672c\u984c\uff0e<\/p>\n<p>CMake\u3060\u3068nvcc\u306f\u81ea\u52d5\u7684\u306b\u5b9f\u884c\u3055\u308c\u308b\u306e\u3067\uff0cnvcc\u306b\u4e0e\u3048\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u3061\u3083\u3093\u3068\u4e0e\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\uff0e<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\uff0cCMakeLists.txt\u306e\u6700\u5c0f\u306e\u4f8b\uff0e<br \/>\n\u4e0a\u306eprog.cu\u3068\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u7f6e\u304d\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#A tiny example of CMakeLists.txt\r\n\r\ncmake_minimum_required(VERSION 2.8)                     # \u304a\u307e\u3058\u306a\u3044\r\nproject(osakanacuda)                                    # \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\r\n\r\nset(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -ccbin g++-4.4)  # GCC\u3078\u306e\u30d1\u30b9\uff0ePATH\u304c\u901a\u3063\u3066\u3044\u308c\u3070\u3053\u306e\u3088\u3046\u306b\u540d\u524d\u306e\u307f\u306e\u6307\u5b9a\u3067\u3082OK\r\n#list(APPEND CUDA_NVCC_FLAGS -ccbin g++-4.4)            # \u3053\u308c\u3067\u3082OK\r\n\r\n#\u4ee5\u4e0b\u306f\u3069\u3061\u3089\u3082\u30c0\u30e1\uff0e\u9055\u3044\u304c\u308f\u304b\u308a\u307e\u3059\u304b\uff1f\r\n#set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -ccbin=g++-4.4)\r\n#list(APPEND CUDA_NVCC_FLAGS=-ccbin g++-4.4)\r\n\r\nfind_package(CUDA)                                      # CUDA\u74b0\u5883\u3092\u898b\u3064\u3051\u3066\u304f\u308c\u308b\uff0e\u3084\u3089\u306a\u3044\u3068\u30c0\u30e1\r\ncuda_add_executable(prog prog.cu)                       # prog\u3063\u3066\u3044\u3046\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u3092\u30d3\u30eb\u30c9\u3057\u3066\u304f\u308c\u308b\u8a2d\u5b9a\u306b\u306a\u308b\r\n<\/pre>\n<p>\u3053\u3093\u306a\u914d\u7f6e\u3060\u3068\u3059\u308b\u3068\uff0c<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n.\r\n\u251c\u2500\u2500 CMakeLists.txt\r\n\u251c\u2500\u2500 prog.cu\r\n\u2514\u2500\u2500 build\/\r\n<\/pre>\n<p>\u6b21\u306e\u3088\u3046\u306b\u3057\u3066\u30d3\u30eb\u30c9\u3057\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ ls\r\nCMakeLists.txt prog.cu build\/\r\n\r\n$ cd build\r\n$ cmake ..\r\n$ make\r\n<\/pre>\n<p>\u30c0\u30e1\u3063\u3066\u66f8\u3044\u3066\u3042\u308b\u65b9\u306e\u6307\u5b9a\u3092\u3059\u308b\u3068\uff0c<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nnvcc fatal   : redefinition of argument 'compiler-bindir'\r\nCMake Error at prog_generated_prog.cu.o.cmake:206 (message):\r\n  Error generating\r\n  \/hogehogehogehogheohgoehgoehoge\/build\/CMakeFiles\/prog.dir\/\/.\/prog_generated_prog.cu.o\r\n<\/pre>\n<p>\u3063\u3066\u3044\u3046\u5185\u5bb9\u3092\u542b\u3093\u3060\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3059\uff0e<\/p>\n<p>*\u7406\u7531<\/p>\n<p>\u6b63\u3057\u3044\u6307\u5b9a\u3068\u8aa4\u3063\u305f\u6307\u5b9a\u306e\u9055\u3044\u306f\u898b\u3066\u306e\u901a\u308a\uff0c&#8221;-ccbin=hogehoge&#8221;\u304b&#8221;-ccbin hogehoge&#8221;\u306e\u9055\u3044\u306a\u3093\u3067\u3059\u304c\uff0cCMake\u306eFindCUDA\u306b\u3042\u308brun_nvcc.cmake\u3092\u8aad\u3093\u3067\u307f\u308b\u3068\uff0c<br \/>\n&#8220;-ccbin&#8221;\u3068\u3044\u3046<font color=\"red\">\u6587\u7bc0<\/font>\u304c\u3042\u3063\u305f\u5834\u5408\u306b\u305d\u306e\u6307\u5b9a\u3092\u512a\u5148\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u304a\u308a\uff0c<br \/>\n\u306a\u3044\u5834\u5408\u306fCMake\u306e\u4e2d\u3067\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u6307\u5b9a\u3092\u3059\u308b\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u307e\u3059\uff0e<\/p>\n<p>\u306a\u306e\u3067\uff0c&#8221;-ccbin=hogehoge&#8221;\u3092CUDA_NVCC_FLAGS\u306b\u6307\u5b9a\u3059\u308b\u3068\uff0cnvcc\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u3068\u304d\u306f<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nnvcc ... -ccbin=hogehoge -ccbin fugafuga ...\r\n<\/pre>\n<p>\u3068\u306a\u308a\uff0c\u300c\u591a\u91cd\u6307\u5b9a\u306f\u30c0\u30e1\u3060\u3063\u3061\u3083\u300d\u3068\u6012\u3089\u308c\u307e\u3059\uff0e<\/p>\n<p>\u306a\u3093\u3061\u3085\u30fc\u4ed5\u69d8\uff0e\u8ab0\u304b\u4fee\u6b63\u3057\u3066\u304f\u3060\u3055\u30fb\u30fb\u30fb<\/p>\n<p>\u306a\u304a\u4eca\u56de\u306e\u74b0\u5883\u306f\uff0c<br \/>\n-Debian 6.0<br \/>\n-CMake version 2.8.11.1<br \/>\n-CUDA 4.2<br \/>\n-GCC 4.8.1\/4.4.5<br \/>\n\u3067\u3059\uff0e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u534a\u5e74\u3076\u308a\u306e\u66f4\u65b0\u3067\u3059\uff0e \u534a\u5e74\u306e\u9593\u306b\uff0c\u3057\u3089\u3059\u306e\u6625\u306e\u65ec\u3068\u79cb\u306e\u65ec\u3092\u307e\u305f\u3050\u3053\u3068\u306b\u306a\u308a\u307e\u3057\u305f\uff0e \u3063\u3066\u3044\u3046\u304b\uff0c\u5bd2\u3044\u3088\uff01\u590f\u304c\u3044\u3044\u3088\uff01\uff01\uff1e\uff1c \u3055\u3066\uff0cLinux\u4e0a\u306eCMake\u3067CUDA\u3092\u4f7f\u3063\u3066\u3044\u308b\u3093\u3067\u3059\u304c\uff0cCUDA\u3067\u306f\u305f\u3044\u3066\u3044\u6700\u65b0\u306eGCC\u306f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[42,13,7],"class_list":["post-1729","post","type-post","status-publish","format-standard","hentry","category-1","tag-cmake","tag-cuda","tag-linux"],"_links":{"self":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts\/1729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1729"}],"version-history":[{"count":0,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts\/1729\/revisions"}],"wp:attachment":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}