{"id":1518,"date":"2019-11-06T14:47:11","date_gmt":"2019-11-06T21:47:11","guid":{"rendered":"https:\/\/in.nau.edu\/hpc\/?page_id=1518"},"modified":"2020-02-12T14:32:05","modified_gmt":"2020-02-12T21:32:05","slug":"managing-r-threading","status":"publish","type":"page","link":"https:\/\/in.nau.edu\/arc\/managing-r-threading\/","title":{"rendered":"Managing R Threading"},"content":{"rendered":"<h2>Managing R Threading<\/h2>\n<div>When running R code that contains multi-threaded libraries, by default, R detects the systems core count and will attempt to start an equal number of threads. Because of this, the job will perform badly as there is likely a mismatch between the cores requested in the slurm job compared to the number of threads that were started by R per the detected cores on the compute node. In addition to being bad for your job&#8217;s performance, the jobs create a high load on our compute nodes and cause some undesirable behavior. To prevent this issue from occurring, the following code segments should be added to your R script:<\/div>\n<p><code><strong># specifies that you will be manually setting the cores<\/strong><br \/>\noptions(future.availablecores.methods = \"mc.cores\")<br \/>\n<strong># SLURM_CPUS_PER_TASK is the amount of cores specified in the job environment<\/strong><br \/>\noptions(mc.cores = Sys.getenv(\"SLURM_CPUS_PER_TASK\")<\/code><\/p>\n<div>In general, the options above should be used at minimum.\u00a0However; there is usually additional changes to be made to your script for each parallel library loaded. These options are usually something like ncores,cores, or num.threads.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Managing R Threading When running R code that contains multi-threaded libraries, by default, R detects the systems core count and will attempt to start an equal number of threads. Because of this, the job will perform badly as there is likely a mismatch between the cores requested in the slurm job compared to the number [&hellip;]<\/p>\n","protected":false},"author":469,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","ring_central_script_selection":"","footnotes":""},"class_list":["post-1518","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/1518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/users\/469"}],"replies":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/comments?post=1518"}],"version-history":[{"count":25,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/1518\/revisions"}],"predecessor-version":[{"id":1661,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/1518\/revisions\/1661"}],"wp:attachment":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/media?parent=1518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}