{"id":2288,"date":"2015-08-25T16:38:29","date_gmt":"2015-08-25T08:38:29","guid":{"rendered":"http:\/\/www.chenlianfu.com\/?p=2288"},"modified":"2015-08-25T16:38:29","modified_gmt":"2015-08-25T08:38:29","slug":"gpu-blast-%e7%9a%84%e5%ae%89%e8%a3%85%e4%b8%8e%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"http:\/\/www.chenlianfu.com\/?p=2288","title":{"rendered":"GPU blast \u7684\u5b89\u88c5\u4e0e\u4f7f\u7528"},"content":{"rendered":"<h1>1. \u5b89\u88c5 Nvidia \u663e\u5361\u9a71\u52a8<\/h1>\n<p>\u5b89\u88c5 Nvidia \u663e\u5361\u9a71\u52a8\uff0c\u5f97\u8981\u7981\u7528 CentOS \u9ed8\u8ba4\u7684 nouveau \u9a71\u52a8\uff0c\u7136\u540e\u5b89\u88c5 Nvidia \u9a71\u52a8<\/p>\n<pre>\r\n\u4e0b\u8f7d\u663e\u5361\u9a71\u52a8\r\n# wget  http:\/\/cn.download.nvidia.com\/XFree86\/Linux-x86_64\/340.65\/NVIDIA-Linux-x86_64-340.65.run\r\n\r\n\u7981\u7528 Nvidia \u663e\u5361\u9a71\u52a8\r\n# echo \"blacklist nouveau\" >> \/etc\/modprobe.d\/blacklist.conf\r\n\r\n\u5907\u4efd\u5e76\u91cd\u5efa\u7cfb\u7edf\u5f15\u5bfc\u7684 image \u6587\u4ef6\r\n# mv \/boot\/initramfs-$(uname -r).img \/boot\/initramfs-$(uname -r).img.bak\r\n# dracut -v \/boot\/initramfs-$(uname -r).img $(uname -r)\r\n\r\n\u91cd\u542f\u540e\u5728 init3 \u6a21\u5f0f\u4e0b\u5b89\u88c5\u663e\u5361\u9a71\u52a8\r\n# init 3\r\n# sh NVIDIA-Linux-x86_64-340.65.run\r\n<\/pre>\n<h1>2. \u68c0\u6d4b\u663e\u5361\u6027\u80fd\u53c2\u6570<\/h1>\n<p>\u63a8\u8350\u4f7f\u7528 <a href=\"http:\/\/cuda-z.sourceforge.net\/\" target=\"_blank\">CUDA-Z <\/a>\u6765\u68c0\u6d4b\u663e\u5361\u6027\u80fd\u53c2\u6570\u3002\u6b63\u5e38\u4f7f\u7528 CUDA-Z \u9700\u8981\u4f9d\u8d56\u4e00\u4e9b\u5e93\u6587\u4ef6\u548c GCC \u3002<\/p>\n<pre>\r\n$ wget http:\/\/downloads.sourceforge.net\/project\/cuda-z\/cuda-z\/0.9\/CUDA-Z-0.9.231.run\r\n$ mv CUDA-Z-0.9.231.run ~\/bin\/CUDA-Z\r\n\r\n\u8fd0\u884c CUDA-Z \u524d\u5b89\u88c5\u5982\u4e0b\u4e00\u4e9b\u7cfb\u7edf\u8f6f\u4ef6\r\n$ sudo yum install libXrender*\r\n$ sudo yum install libXrender*i686*\r\n$ sudo yum install libXext*\r\n$ sudo yum install libXext*i686*\r\n$ sudo yum install libz*\r\n$ sudo yum install libz*i686*\r\n\u5c06 GCC \u7684\u5e93\u6587\u4ef6\u8def\u5f84\u8bbe\u7f6e\u6b63\u786e\r\n$ export C_INCLUDE_PATH=\/opt\/gcc-4.7.2\/include\r\n$ export LD_LIBRARY_PATH=\/opt\/gcc-4.7.2\/lib64:\/opt\/gcc-4.7.2\/lib\r\n\r\n\u8fd0\u884c CUDA-Z \u56fe\u5f62\u5316\u754c\u9762\uff0c\u754c\u9762\u548c windows \u4e0b\u7684 CPU-Z \u4e00\u81f4\u3002\r\n$ CUDA-Z\r\n<\/pre>\n<p>\u663e\u5361\u4e00\u4e9b<a href=\"http:\/\/blog.csdn.net\/zhuxianjianqi\/article\/details\/8905678\" target=\"_blank\">\u9ad8\u7ea7\u5e38\u8bc6<\/a>\uff0c\u4f8b\u5982\uff1a<br \/>\n\u6211\u7684\u7b14\u8bb0\u672c\u7535\u8111 GTX570M \u663e\u5361\uff1a \u8be5 GPU \u6709 7\u4e2a SM\uff0c\u6bcf\u4e2a SM \u6709 48 \u4e2a SP\uff0c\u6bcf\u4e2a SP \u6709 32 \u4e2a warp\uff1b SP \u79f0\u4e3a\u6d41\u5904\u7406\u5668\uff0c\u8be5\u503c\u8d8a\u5927\uff0c\u5219\u663e\u5361\u6027\u80fd\u8d8a\u597d\uff1b warp \u662f\u6700\u5c0f\u7684\u786c\u4ef6\u6267\u884c\u5355\u4f4d\uff0c\u5219\u8be5\u663e\u5361\u6700\u5927\u7684\u7ebf\u7a0b\u6570\u662f 7*48*32=10752\u3002<br \/>\nSM \u4e4b\u95f4\u53ef\u4ee5\u7406\u89e3\u662f\u7269\u7406\u9694\u7edd\u7684\uff0c\u4e0d\u540c\u7684 SM \u7684\u8ba1\u7b97\u662f\u72ec\u7acb\u7684\u3002\u5c06\u6570\u636e\u7528\u663e\u5361\u8fdb\u884c\u8ba1\u7b97\u65f6\uff0c\u8fdb\u884c\u5e76\u884c\u8ba1\u7b97\u65f6\uff0c\u6211\u4e2a\u4eba\u7406\u89e3\u6210\u8fd9\u6837\uff1a \u628a\u8fd0\u884c\u7684\u7a0b\u5e8f\u505a\u6210\u5f88\u591a\u5c0f\u4efd\u8fdb\u884c\u5e76\u884c\u8ba1\u7b97\uff1b\u6240\u6709\u7684\u5e76\u884c\u8ba1\u7b97\u7684\u603b\u4f53\u79f0\u4e3a Grid\uff0c\u5e76\u884c\u8fd0\u7b97\u7684\u6700\u5c0f\u5355\u5143\u4e3a thread\uff1bgpu-blast\u5728\u9ed8\u8ba4\u8bbe\u7f6e\u4e2d\uff0c\u5c06 64 \u4e2a threads \u5408\u5e76\u4e3a 1 \u4e2a block\uff0c\u56e0\u6b64 1 \u4e2a block \u7684\u8fd0\u884c\u9700\u8981 2 \u4e2a SP \u8fdb\u884c\u8fd0\u7b97\uff1bgpu-blast\u5728\u9ed8\u8ba4\u8bbe\u7f6e\u4e2d\uff0c\u8fd0\u884c\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u5c06\u4e4b\u5206\u5272\u6210 521 \u4e2a blocks\uff0c \u8fd9 512 \u4e2a blocks \u5219\u9700\u8981 1024 \u4e2a SP \u8fdb\u884c\u8fd0\u7b97\uff0c\u53ef\u4ee5\u8fbe\u5230\u6700\u5feb\u7684\u8fd0\u7b97\u901f\u5ea6\u3002\u6240\u4ee5\uff0c\u5982\u679c GPU \u7684 SP \u603b\u6570\u8d85\u8fc7 1024\uff0c \u5219\u4e0d\u80fd\u5b8c\u5168\u53d1\u6325\u663e\u5361\u7684\u6027\u80fd\u3002<br \/>\n\u5bf9\u4e8e GTX570M \u663e\u5361\uff0c\u6211\u8bbe\u7f6e gpu-blast \u7684\u53c2\u6570  -gpu_threads 32 -gpu_blocks 336 \u6211\u89c9\u5f97\u662f\u6bd4\u8f83\u597d\u7684\u3002\u8fd9\u6837\uff0c\u5c06 blast \u7a0b\u5e8f\u5206\u5272\u4e3a 336 \u4e2a blocks \u8fdb\u884c\u5e76\u884c\u8ba1\u7b97\uff1b\u5c06\u6240\u6709\u7684 block \u5206\u914d\u7ed9\u6240\u6709\u7684 SP \uff0c\u521a\u597d\u6bcf\u4e2a SP \u90fd\u8fd0\u884c 32 \u7ebf\u7a0b\u3002\u4f46\u5b9e\u9645\u4e0a\uff0c\u4f7f\u7528 gpu-blast \u9ed8\u8ba4\u7684\u53c2\u6570\u4e5f\u66f4\u597d\u5730\u53d1\u6325\u663e\u5361\u6027\u80fd\uff0c\u6211\u4e2a\u4eba\u5b9e\u9a8c\u7ed3\u679c\u662f\uff0c-gpu_threads 128 -gpu_blocks 512 \u7684\u7ed3\u679c\u66f4\u52a0\u4e0d\u9519\u3002<\/p>\n<h1>3. \u5b89\u88c5 CUDA Toolkits<\/h1>\n<p>CUDA \u7684\u4e0b\u8f7d\u7f51\u5740\uff1a <a href=\"https:\/\/developer.nvidia.com\/cuda-downloads\" target=\"_blank\">https:\/\/developer.nvidia.com\/cuda-downloads<\/a><\/p>\n<pre>\r\n$ wget http:\/\/developer.download.nvidia.com\/compute\/cuda\/6_5\/rel\/installers\/cuda_6.5.14_linux_64.run\r\n$ sudo init 3\r\n# sh cuda_6.5.14_linux_64.run\r\n<\/pre>\n<h1>4. \u5b89\u88c5 GPU-Blast<\/h1>\n<p>GPU-Blast\u5b98\u7f51\uff1a <a href=\"http:\/\/archimedes.cheme.cmu.edu\/?q=gpublast\" target=\"_blank\">http:\/\/archimedes.cheme.cmu.edu\/?q=gpublast<\/a><br \/>\nGPU-Blast \u63d0\u4f9b\u7684\u6700\u9ad8 blast \u7248\u672c\u662f 2.2.28 \u7248\u672c\uff0c\u9700\u8981 ncbi-blast \u540c\u7248\u672c\u6e90\u7801\u6587\u4ef6\u652f\u6301\u3002<\/p>\n<pre>\r\n$ mkdir \/opt\/biosoft\/gpu_blast\r\n$ cd \/opt\/biosoft\/gpu_blast\r\n\r\n\u4ece\u6e90\u7801\u5305\u5b89\u88c5 ncbi-blast 2.2.28 \u7248\u672c\uff08\u6b64\u6b65\u9aa4\u53ef\u9009\uff09\r\n$ wget ftp:\/\/ftp.ncbi.nih.gov\/blast\/executables\/blast+\/2.2.28\/ncbi-blast-2.2.28+-src.tar.gz\r\n$ tar zxf ncbi-blast-2.2.28+-src.tar.gz\r\n$ cd ncbi-blast-2.2.28+-src\/c++\r\n$ .\/configure && make -j 8 \r\n\r\n\u5b89\u88c5 GPU-Blast \u524d\u9700\u8981\u5c06 CUDA Toolkits \u7684\u5e93\u6587\u4ef6\u4e0e\u5934\u6587\u4ef6\u52a0\u5165\u5230\u80fd\u8bc6\u522b\u7684\u8def\u5f84\r\n$ echo 'export LD_LIBRARY_PATH=\/usr\/local\/cuda\/lib:\/usr\/local\/cuda\/lib64:$LD_LIBRARY_PATH' >> ~\/.bashrc\r\n$ echo 'export C_INCLUDE_PATH=\/usr\/local\/cuda\/include\/:$C_INCLUDE_PATH' >> ~\/.bashrc\r\n$ source ~\/.bashrc\r\n\r\n\u4e0b\u8f7d\u5e76\u5b89\u88c5 GPU-Blast\r\n$ wget http:\/\/eudoxus.cheme.cmu.edu\/gpublast\/gpu-blast-1.1_ncbi-blast-2.2.28.tar.gz \r\n$ tar zxf gpu-blast-1.1_ncbi-blast-2.2.28.tar.gz\r\n$ perl -p -i -e 's\/LATEST\/2.2.28\/' install\r\n$ perl -p -i -e 's\/make \/make -j \/' install\r\n$ .\/install\r\nDo you want to install GPU-BLAST on an existing installation of \"blastp\" [yes\/no]\r\n\u5982\u679c\u8f93\u5165 no \u5219\u4f1a\u81ea\u52a8\u4e0b\u8f7d ncbi-blast-2.2.28+-src.tar.gz\uff0c\u5e76\u8fdb\u884c\u5b89\u88c5\uff0c\u9700\u8981\u505a\u4e0a\u8ff0\u4fee\u6539\uff0c\u5426\u5219\u4e0b\u8f7d\u5730\u5740\u4e0d\u6b63\u786e\u3002\u540c\u65f6\uff0c\u9ed8\u8ba4\u4e0b make \u7f16\u8bd1\u662f\u5355\u7ebf\u7a0b\u8fd0\u884c\uff0c\u52a0\u5165 -j \u53c2\u6570\u6765\u5e76\u884c\u8fd0\u7b97\uff0c\u4ece\u800c\u52a0\u5feb\u7f16\u8bd1\u901f\u5ea6\u3002\r\n\u5982\u679c\u9009\u62e9 yes\uff0c\u5219\u9700\u8981\u8f93\u5165 blastp \u7684\u8def\u5f84\uff0c\u8be5\u8def\u5f84\u662f blastp \u7684\u7f16\u8bd1\u540e\u6240\u5728\u7684\u8def\u5f84\uff0c\u800c\u4e0d\u662f\u5b89\u88c5\u8def\u5f84\u3002\u8f93\u5165 \/opt\/biosoft\/gpu_blast\/ncbi-blast-2.2.28+-src\/c++\/GCC447-Debug64\/bin\/ \uff0c \u6309 Enter \u8fdb\u884c\u5b89\u88c5\u3002\r\n\r\n\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u5c06\u7a0b\u5e8f\u6587\u4ef6\u6240\u5728\u8def\u5f84\u52a0\u5165\u73af\u5883\u53d8\u91cf PATH\r\n$ ln -s ncbi-blast-2.2.28+-src\/c++\/GCC447-ReleaseMT64\/bin\/ bin\r\n$ echo 'PATH=$PATH:\/opt\/biosoft\/gpu_blast\/bin' >> ~\/.bashrc\r\n$ source ~\/.bashrc\r\n<\/pre>\n<p>\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u7a0b\u5e8f\u6587\u4ef6\u4f4d\u4e8e <\/p>\n<h1>4. \u8fd0\u884c GPU-Blast<\/h1>\n<p>\u4ee5 Swissprot \u6570\u636e\u5e93\u4e3a\u4f8b\uff1a<\/p>\n<pre>\r\n\u9996\u5148\uff0c\u4ee5 fasta \u6587\u4ef6\u6784\u5efa blast \u6570\u636e\u5e93\uff0c\u9700\u8981\u52a0\u5165 -sort_volumes \u53c2\u6570\r\n$ makeblastdb -dbtype prot -in uniprot_sprot.fasta -out uniprot_sprot -sort_volumes -max_file_sz 500MB\r\n\r\n\u7136\u540e\uff0c\u5728\u666e\u901a blast \u6570\u636e\u5e93\u57fa\u7840\u4e0a\u6784\u5efa gpu \u6570\u636e\u5e93\u3002\u4f7f\u7528 -method 2 \u53c2\u6570\u751f\u6210 gpu \u6570\u636e\u5e93\u6587\u4ef6\r\n$ blastp -db uniprot_sprot -query test.fa -gpu t -method 2\r\n\r\n\u518d\u4f7f\u7528 -gpu t \u8fd0\u7528 gpu_blast\uff0c\u5426\u5219\u662f\u5355\u7eaf\u7528 CPU \u8fdb\u884c\u8ba1\u7b97\r\n$ blastp -db uniprot_sprot -query test.fa -gpu t\r\n<\/pre>\n<p>\u4f7f\u7528 gpu_blast \u786e\u5b9e\u80fd\u52a0\u5feb\u901f\u5ea6\uff0c\u5728\u8f6f\u4ef6\u7684\u793a\u4f8b\u4e2d\uff0c\u5728 -num_threads 2 \u4e0b\uff0cGPU \u6709 2.5 \u500d\u7684\u52a0\u901f\u3002<br \/>\n\u6211\u7684\u4f7f\u7528\u7ecf\u9a8c\uff1a \u5bf9 40 \u6761\u86cb\u767d\u5e8f\u5217\u4f7f\u7528 blastp \u6bd4\u5bf9\u5230 Swissprot \u6570\u636e\u5e93\uff0c \u8bbe\u7f6e -num_threads 8\uff0c gpu_blast \u8017\u65f6 1m41.053s\uff0c cpu_blast \u8017\u65f6 0m52.264s\uff1b \u5bf9 8 \u6761\u86cb\u767d\u8d28\u5e8f\u5217\u4f7f\u7528 blastp \u6bd4\u5bf9\u5230 Swissprot \u6570\u636e\u5e93\uff0c \u8bbe\u7f6e -num_threads 2\uff0cgpu_blast \u8017\u65f6 0m7.892s\uff0c cpu_blast \u8017\u65f6 0m12.717s\uff1b\u5bf9\u540c\u6837 8 \u6761\u86cb\u767d\u8d28\u5e8f\u5217\u4f7f\u7528 blastp \u6bd4\u5bf9\u5230 Swissprot \u6570\u636e\u5e93\uff0c \u8bbe\u7f6e -num_threads 8\uff0cgpu_blast \u8017\u65f6 0m5.288s\uff0c cpu_blast \u8017\u65f6 0m5.836s\uff1b<br \/>\n\u4e2a\u4eba\u4f7f\u7528\u611f\u89c9\uff1a \u867d\u7136\u6709 GPU \u52a0\u901f\uff0c\u4f46\u662f\u4f9d\u7136\u9700\u8981\u8017\u8d39\u5927\u91cf CPU\uff0c\u800c\u4e0d\u662f\u53ea\u8fd0\u7528\u4e86 GPU \u8fdb\u884c\u8ba1\u7b97\uff1b \u5982\u679c CPU \u672c\u8eab\u8fd0\u884c\u901f\u5ea6\u8f83\u5feb\u7684\u65f6\u5019\uff0c\u4f7f\u7528 GPU \u52a0\u901f\u7684\u6bd4\u7387\u5219\u8f83\u4f4e\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5b89\u88c5 Nvidia \u663e\u5361\u9a71\u52a8 \u5b89\u88c5 Nvidia \u663e\u5361\u9a71\u52a8\uff0c\u5f97\u8981\u7981\u7528 Ce &hellip; <a href=\"http:\/\/www.chenlianfu.com\/?p=2288\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[8,71],"_links":{"self":[{"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=\/wp\/v2\/posts\/2288"}],"collection":[{"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2288"}],"version-history":[{"count":1,"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=\/wp\/v2\/posts\/2288\/revisions"}],"predecessor-version":[{"id":2289,"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=\/wp\/v2\/posts\/2288\/revisions\/2289"}],"wp:attachment":[{"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2288"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.chenlianfu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}