{"id":5680,"date":"2015-02-26T13:13:24","date_gmt":"2015-02-26T12:13:24","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=5680"},"modified":"2015-02-26T13:13:24","modified_gmt":"2015-02-26T12:13:24","slug":"compiling-environment-modules-on-ubuntu-linux","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=5680","title":{"rendered":"Compiling environment-modules on Ubuntu Linux"},"content":{"rendered":"<p><a href=\"http:\/\/modules.sourceforge.net\/\">Environment modules<\/a> are widely used in the High Performance Computing (HPC) world where sysadmins need to install dozens, or maybe hundreds of potentially conflicting applications, libraries and compilers on multi-user machines.\u00a0The University of Manchester&#8217;s <a href=\"http:\/\/ri.itservices.manchester.ac.uk\/csf\/\">Computational Shared Facility (CSF)<\/a>, for example, makes extensive use of environment modules and would be extremely difficult to run without them.<\/p>\n<p>Once the sysadmin has correctly installed an application (MATLAB 2014a say) and set up the corresponding module file, making it available to your shell is as easy as doing<\/p>\n<pre>module load apps\/binapps\/matlab\/R2014a<\/pre>\n<p>Unloading the module is just as easy<\/p>\n<pre>module unload apps\/binapps\/matlab\/R2014a<\/pre>\n<p>On a heavily used, multi-user system environment modules are invaluable! Every user can have whatever compilers, libraries and applications they like &#8212; they just load and unload whatever they need from the huge selection supported by their ever-friendly sysadmins.<\/p>\n<p><strong>Environment modules on Ubuntu<\/strong><\/p>\n<p>I needed to install environment modules on a VM running Ubuntu 14.04 for my own use. I found a very nice setup guide at\u00a0<a href=\"http:\/\/www.setuptips.com\/unix\/setup-environment-modules-on-ubuntu\/\">http:\/\/www.setuptips.com\/unix\/setup-environment-modules-on-ubuntu\/<\/a>\u00a0but it didn&#8217;t work. On attempting to compile, I got the error message<\/p>\n<pre>cmdModule.c:644:15: error: 'Tcl_Interp' has no member named 'errorLine'<\/pre>\n<p>This is a\u00a0<a href=\"http:\/\/sourceforge.net\/p\/modules\/bugs\/62\/\">known bug<\/a>\u00a0in version 3.2.9c of environment modules and has a work-around.<\/p>\n<p>I also found a set up guide at\u00a0<a href=\"http:\/\/nickgeoghegan.net\/linux\/installing-environment-modules\">http:\/\/nickgeoghegan.net\/linux\/installing-environment-modules<\/a> which had some useful advice on configuration..<\/p>\n<p>Combining information from these sources, I managed to get a working install. Here are the steps I did in full for a clean Ubuntu 14.04 image<\/p>\n<pre>\r\n#Install the tcl development package\r\nsudo apt-get install tcl-dev\r\n\r\n#Make the directories where my modules and packages are going to live\r\nsudo mkdir \/opt\/modules\r\nsudo mkdir \/opt\/packages\r\n\r\n#Get the source code. This was the most up to date version as of 25th Feb 2015\r\nwget http:\/\/downloads.sourceforge.net\/project\/modules\/Modules\/modules-3.2.9\/modules-3.2.9c.tar.gz\r\n\r\n#unpack and enter source directory\r\ntar xvzf modules-3.2.9c.tar.gz\r\ncd modules-3.2.9\r\n\r\n#Configure using the workaround and selecting my module folder \r\nCPPFLAGS=\"-DUSE_INTERP_ERRORLINE\" .\/configure --with-module-path=\/opt\/modules\/\r\n\r\n#make and install\r\nmake\r\nsudo make install\r\n\r\n#Edit the modulefiles path. Comment out all lines starting \/usr so that only \/opt\/modules is used\r\nsudo sed -i 's~^\/usr~#\/usr~' \/usr\/local\/Modules\/3.2.9\/init\/.modulespath\r\n\r\n#Configure the shell to use modules\r\nsudo tee \/etc\/profile.d\/modules.sh > \/dev\/null << 'EOF'\r\n#----------------------------------------------------------------------#\r\n# system-wide profile.modules #\r\n# Initialize modules for all sh-derivative shells #\r\n#----------------------------------------------------------------------#\r\ntrap \"\" 1 2 3\r\n\r\nMODULES=\/usr\/local\/Modules\/3.2.9\r\n\r\ncase \"$0\" in\r\n-bash|bash|*\/bash) . $MODULES\/init\/bash ;;\r\n-ksh|ksh|*\/ksh) . $MODULES\/init\/ksh ;;\r\n-sh|sh|*\/sh) . $MODULES\/init\/sh ;;\r\n*) . $MODULES\/init\/sh ;; # default for scripts\r\nesac\r\n\r\ntrap - 1 2 3\r\nEOF\r\n\r\n#Add modules to your .bashrc file\r\necho '#For modules' >> ~\/.bashrc\r\necho '. \/etc\/profile.d\/modules.sh' >> ~\/.bashrc\r\n<\/pre>\n<p>That takes care of the basic setup but modules is pretty useless at this stage. To make it useful, you need to install some extra software and the corresponding module file. <\/p>\n<p><b>Installing a module file for Anaconda Python 2.1<\/b><br \/>\nThis is a really simple example of how to set up a basic module file<\/p>\n<p>I downloaded and installed Anaconda Python 2.1 to \/opt\/packages and created a file called anaconda2.1 in \/opt\/modules containing the following<\/p>\n<pre>\r\n#%Module1.0\r\nproc ModulesHelp { } {\r\nglobal dotversion\r\n \r\nputs stderr \"\\tAnaconda Python 2.1 providing Python 2.7.8\"\r\n}\r\n \r\nmodule-whatis \"Anaconda Python 2.1\"\r\nprepend-path PATH \/opt\/packages\/anaconda\/bin\r\n<\/pre>\n<p>Now, when I do the command <\/p>\n<pre>\r\nmodule avail\r\n<\/pre>\n<p>I get <\/p>\n<pre>\r\n-------------------------- \/opt\/modules\/ ---------------------------\r\nanaconda2.1\r\n<\/pre>\n<p>I can load my anaconda2.1 module with the command<\/p>\n<pre>\r\nmodule load anaconda2.1\r\n<\/pre>\n<p>Now, when I type <b>python<\/b> at the command prompt, I&#8217;ll be using Anaconda&#8217;s python rather than the system python. Once I&#8217;m done, I can unload with<\/p>\n<pre>\r\nmodule unload anaconda2.1\r\n<\/pre>\n<p>This example is so trivial it&#8217;s almost not worth it &#8212; modules really come into their own when you need to support loads of compilers and corresponding libraries. There&#8217;s an example using gcc at <a href=\"http:\/\/nickgeoghegan.net\/linux\/installing-environment-modules\">http:\/\/nickgeoghegan.net\/linux\/installing-environment-modules<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Environment modules are widely used in the High Performance Computing (HPC) world where sysadmins need to install dozens, or maybe hundreds of potentially conflicting applications, libraries and compilers on multi-user machines.\u00a0The University of Manchester&#8217;s Computational Shared Facility (CSF), for example, makes extensive use of environment modules and would be extremely difficult to run without them. [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[68,5],"tags":[],"class_list":["post-5680","post","type-post","status-publish","format-standard","hentry","category-hpc","category-linux"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-1tC","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/5680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5680"}],"version-history":[{"count":6,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/5680\/revisions"}],"predecessor-version":[{"id":5690,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/5680\/revisions\/5690"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}