{"id":1588,"date":"2022-03-19T11:55:21","date_gmt":"2022-03-19T15:55:21","guid":{"rendered":"https:\/\/www.unliterate.net\/?p=1588"},"modified":"2022-03-19T12:01:36","modified_gmt":"2022-03-19T16:01:36","slug":"xmrig-with-cuda-for-rocky-linux-8-5","status":"publish","type":"post","link":"https:\/\/www.unliterate.net\/index.php\/2022\/03\/19\/xmrig-with-cuda-for-rocky-linux-8-5\/","title":{"rendered":"xmrig with cuda for Rocky Linux 8.5"},"content":{"rendered":"\n<p>The wife wants to get into Cryptocurrency, so we get into Crypto.<\/p>\n\n\n\n<p>She picked out a couple: <a rel=\"noreferrer noopener\" href=\"https:\/\/www.vechain.org\" target=\"_blank\">VeChain<\/a>(<a rel=\"noreferrer noopener\" href=\"https:\/\/www.coinbase.com\/price\/vechain\" target=\"_blank\">c<\/a>), <a rel=\"noreferrer noopener\" href=\"https:\/\/www.stellar.org\" target=\"_blank\">Stellar<\/a>(<a rel=\"noreferrer noopener\" href=\"https:\/\/www.coinbase.com\/price\/stellar\" target=\"_blank\">c<\/a>), and <a rel=\"noreferrer noopener\" href=\"https:\/\/bitcoin.org\/en\/\" target=\"_blank\">Bitcoin<\/a>(<a rel=\"noreferrer noopener\" href=\"https:\/\/www.coinbase.com\/price\/bitcoin\" target=\"_blank\">c<\/a>)<\/p>\n\n\n\n<p>I picked out a couple: <a rel=\"noreferrer noopener\" href=\"https:\/\/ethereum.org\/en\/\" target=\"_blank\">Ethereum<\/a>(<a rel=\"noreferrer noopener\" href=\"https:\/\/www.coinbase.com\/price\/ethereum\" target=\"_blank\">c<\/a>), <a rel=\"noreferrer noopener\" href=\"https:\/\/www.getmonero.org\/\" target=\"_blank\">Monero<\/a>(<a rel=\"noreferrer noopener\" href=\"https:\/\/www.coinbase.com\/price\/monero\" target=\"_blank\">c<\/a>), and <a rel=\"noreferrer noopener\" href=\"https:\/\/dogecoin.com\/\" target=\"_blank\">Dogecoin<\/a>(<a href=\"https:\/\/www.coinbase.com\/price\/dogecoin\" target=\"_blank\" rel=\"noreferrer noopener\">c<\/a>)<\/p>\n\n\n\n<p>None of them intersect, so I&#8217;ll start with my list first \ud83d\ude42<\/p>\n\n\n\n<p>First thing is to build a miner, and we&#8217;ll use an old <a href=\"https:\/\/www.intel.com\/content\/www\/us\/en\/products\/sku\/35428\/intel-core2-quad-processor-q9650-12m-cache-3-00-ghz-1333-mhz-fsb\/specifications.html\" target=\"_blank\" rel=\"noreferrer noopener\">Intel Core2 Quad Q9650<\/a> with 8GB RAM and an nVidia GeForce GT710 that I scrounged together from old parts.<\/p>\n\n\n\n<p>Second thing is to choose a cryptocurrency to see how we can optimize it. Monero looks ezpz.<\/p>\n\n\n\n<p>Third thing is to get familiar with xmrig and xmrig-cuda built and running. We&#8217;ll plan and build this in a Virtual Machine to make sure we have all our dependencies ironed out before committing this to an actual machine. We&#8217;ll steal some guidance from <a rel=\"noreferrer noopener\" href=\"https:\/\/www.linkedin.com\/pulse\/monero-mining-raspberry-pi-3-b-litaiem-mootaz\/\" target=\"_blank\">Litaiem Moatez and their first linkedin article<\/a> to help us out.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Setup and Building xmrig<\/h2>\n\n\n\n<p>Our Hypervisor will be <a rel=\"noreferrer noopener\" href=\"https:\/\/www.virtualbox.org\/\" target=\"_blank\">Oracle VirtualBox 6.1<\/a>, and we&#8217;ll set up a VM with 4 vCPUs and 4GB RAM and a 20GB hard drive. We&#8217;ll install <a rel=\"noreferrer noopener\" href=\"https:\/\/rockylinux.org\/download\/\" target=\"_blank\">Rocky Linux 8.5 minimal<\/a> and do the standard online yum updates. I&#8217;ll also set selinux=permissive in \/etc\/selinux\/config and disable firewalld.<\/p>\n\n\n\n<p>Next up is to install epel-release and enable powertools. For Rocky we need <a href=\"https:\/\/www.how2shout.com\/linux\/how-to-enable-powertools-repository-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">powertools enabled<\/a> so we can build applications with source code (mainly installing -devel packages)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum update\nsudo yum install epel-release\nsudo dnf config-manager --set-enabled powertools<\/code><\/pre>\n\n\n\n<p>Next is to install build dependencies for xmrig and xmrig-cuda<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install wget git cmake gcc gcc-c++ hwloc-devel libuv-devel openssl-devel libstdc++-static<\/code><\/pre>\n\n\n\n<p>Clone and build xmrig<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/xmrig\/xmrig.git\ncd xmrig\nmkdir build\ncmake ..\nmake\n<\/code><\/pre>\n\n\n\n<p>And then run<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/xmrig --stress --cuda --opencl\n * ABOUT        XMRig\/6.16.4 gcc\/8.5.0\n * LIBS         libuv\/1.41.1 OpenSSL\/1.1.1k hwloc\/2.2.0\n * HUGE PAGES   supported\n * 1GB PAGES    unavailable\n * CPU          AMD Ryzen 5 5600X 6-Core Processor (1) 64-bit AES VM\n                L2:2.0 MB L3:32.0 MB 4C\/4T NUMA:1\n * MEMORY       1.0\/3.8 GB (26%)\n * DONATE       1%\n * ASSEMBLY     auto:ryzen\n * POOL #1      stratum+ssl:\/\/randomx.xmrig.com:443 algo auto\n * COMMANDS     hashrate, pause, resume, results, connection\n * OPENCL       disabled (failed to load OpenCL runtime)\n * CUDA         disabled (\/home\/user\/xmrig\/build\/libxmrig-cuda.so: cannot open shared object file: No such file or directory)<\/code><\/pre>\n\n\n\n<p>Since we&#8217;re using an nVidia GeForce graphics card and we want to use GPU mining we&#8217;re going to be getting CUDA set up and kicking off, and xmrig has the resources to make the libxmrig-cuda.so file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Building xmrig-cuda<\/h2>\n\n\n\n<p>We&#8217;ll need the <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.nvidia.com\/cuda-toolkit\" target=\"_blank\">nVidia CUDA kit<\/a>, which has a fancy <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.nvidia.com\/cuda-downloads\" target=\"_blank\">download process<\/a>. In their menus we&#8217;ll select: Linux \/ x86_64 \/ Centos \/ 8 \/ rpm (local). The results is a series of commands that they provide us to download and build up their kit:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/developer.download.nvidia.com\/compute\/cuda\/11.6.1\/local_installers\/cuda-repo-rhel8-11-6-local-11.6.1_510.47.03-1.x86_64.rpm\nsudo rpm -i cuda-repo-rhel8-11-6-local-11.6.1_510.47.03-1.x86_64.rpm\nsudo dnf clean all\nsudo dnf -y module install nvidia-driver:latest-dkms\nsudo dnf -y install cuda<\/code><\/pre>\n\n\n\n<p>After this we clone and build xmrig-cuda to make libxmrig-cuda.so<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/xmrig\/xmrig-cuda\nmkdir build\ncmake ..\nmake<\/code><\/pre>\n\n\n\n<p>And finally (and fancifully) we&#8217;ll just symlink to the libxmrig-cuda.so from our xmrig executable:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\/xmrig\/build\/\nln -s ..\/..\/xmrig-cuda\/build\/libxmrig-cuda.so<\/code><\/pre>\n\n\n\n<p>Executing to verify that the file doesn&#8217;t crap out our system:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/xmrig --stress --cuda --opencl\n&#91;user@xmrig-cuda build]$ .\/xmrig --stress --cuda --opencl\n&#91;2022-03-19 10:37:37.160] Error UNKNOWN_ERROR when calling clGetPlatformIDs for number of platforms.\n&#91;2022-03-19 10:37:37.160] No OpenCL platform found.\n * ABOUT        XMRig\/6.16.4 gcc\/8.5.0\n * LIBS         libuv\/1.41.1 OpenSSL\/1.1.1k hwloc\/2.2.0\n * HUGE PAGES   supported\n * 1GB PAGES    unavailable\n * CPU          AMD Ryzen 5 5600X 6-Core Processor (1) 64-bit AES VM\n                L2:2.0 MB L3:32.0 MB 4C\/4T NUMA:1\n * MEMORY       3.6\/3.8 GB (93%)\n * DONATE       1%\n * ASSEMBLY     auto:ryzen\n * POOL #1      stratum+ssl:\/\/randomx.xmrig.com:443 algo auto\n * COMMANDS     hashrate, pause, resume, results, connection\n&#91;2022-03-19 10:37:37.358] Error UNKNOWN_ERROR when calling clGetPlatformIDs for number of platforms.\n&#91;2022-03-19 10:37:37.358] No OpenCL platform found.\n * OPENCL       disabled (selected OpenCL platform NOT found)\n * CUDA         disabled (no devices)<\/code><\/pre>\n\n\n\n<p>Of course, since we&#8217;re in a VM this is not going to find our device, but we&#8217;ve planned enough to get this up and running!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The wife wants to get into Cryptocurrency, so we get into Crypto. She picked out a couple: VeChain(c), Stellar(c), and Bitcoin(c) I picked out a couple: Ethereum(c), Monero(c), and Dogecoin(c) None of them intersect, so I&#8217;ll start with my list first \ud83d\ude42 First thing is to build a miner, and we&#8217;ll use an old Intel [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,17,40],"tags":[],"class_list":["post-1588","post","type-post","status-publish","format-standard","hentry","category-geek-instructions","category-linux","category-rocky"],"_links":{"self":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/1588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/comments?post=1588"}],"version-history":[{"count":3,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/1588\/revisions"}],"predecessor-version":[{"id":1592,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/1588\/revisions\/1592"}],"wp:attachment":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/media?parent=1588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/categories?post=1588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/tags?post=1588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}