{"id":11406,"date":"2025-11-17T11:56:10","date_gmt":"2025-11-17T11:56:10","guid":{"rendered":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/?page_id=11406"},"modified":"2026-07-29T09:34:27","modified_gmt":"2026-07-29T08:34:27","slug":"conda","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/applications\/conda\/","title":{"rendered":"Conda &#8211; Miniforge3"},"content":{"rendered":"<h2>Overview<\/h2>\n<p><a href=\"https:\/\/conda.org\/\">Conda<\/a> is package and environment manager. It allows you to create separate environments, each containing their own files, packages (typically python packages), and package dependencies. The contents of each environment do not interact with each other.<\/p>\n<p>Hence it allows you to work on multiple python projects without package installs in one project breaking another project.<\/p>\n<p>New versions of Conda are regularly released, but environments created with older versions are generally usable with newer versions.<\/p>\n<p>On the CSF we recommend the Minforge3 implementation of Conda because it is aligned with the open <a href=\"https:\/\/conda-forge.org\/\">conda-forge community and repository<\/a>.<\/p>\n<p>The <a href=\"https:\/\/bioconda.github.io\/\">Bioconda channel<\/a> is already configured within our Miniforge modules.<\/p>\n<h2>Restrictions on use<\/h2>\n<p>Conda is open source but packages and repositories may not be entirely open or available under the same open source license.<\/p>\n<p>Miniforge installer code uses BSD-3-Clause license.<\/p>\n<h2>Set up procedure<\/h2>\n<p>We recommend loading modulefiles within your jobscripts so that you have a full record of how the job was run. See the example jobscript below for how to do this. Alternatively, you may load modulefiles on the login node and let the job inherit these settings.<\/p>\n<p>Load one of the following modulefiles:<\/p>\n<pre>\r\nmodule load apps\/binapps\/conda\/miniforge3\/26.3.2     # Provides python 3.13.13 unless specified\r\nmodule load apps\/binapps\/conda\/miniforge3\/25.9.1     # Provides python 3.12.12 unless specified\r\nmodule load apps\/binapps\/conda\/miniforge3\/25.3.0     # Provides python 3.12.9 unless specified\r\n<\/pre>\n<p>Loading the module will set all parameters to allow Conda to function, but will not activate the conda base environment. To use a Conda environment, you first need to create it.<\/p>\n<p>The information provided here is for quick reference, for more complete documentation please see the <a href=\"https:\/\/docs.conda.io\/projects\/conda\/en\/stable\/user-guide\/getting-started.html\">official Conda getting started guide.<\/a><\/p>\n<h3>Create a Conda environment<\/h3>\n<p>Create an environment called &#8220;myenv&#8221; with a specific Python version and the pandas package:<\/p>\n<pre>\r\nconda create -n myenv python==3.11 pandas\r\n                         #           #\r\n                         #           # Packages you wish to install inside your conda\r\n                         #           # env. This is optional, you can also do it later.\r\n                         #\r\n                         # Installing a version of python is optional\r\n                         # (see above for default python versions)\r\n<\/pre>\n<p>Conda will look up the requested packages and if they are available, will present you with package plan. You do not have to install python, Conda is used to manage a wide range of different software.<\/p>\n<p>Type &#8216;Y&#8217; to accept the plan and allow Conda to install the software.<\/p>\n<p>When the install is complete you will be prompted to activate the environment:<\/p>\n<pre>\r\nconda activate myenv\r\n<\/pre>\n<div class=\"note\">If you have previously used Conda, you might expect to run the &#8216;conda init&#8217; or &#8216;source activate&#8217; commands at this point. However, we have configured Miniforge such that you do not need to do this and Conda will not modify your .bashrc file or any other persistent configurations.<\/div>\n<p>Once your environment is active your shell will look something like:<\/p>\n<pre>\r\n(myenv) [a12345bc@login2[csf3] ~]$\r\n  #\r\n  # Name of active conda env you are now working in.\r\n  # For example, python package install will go into this env.\r\n<\/pre>\n<p>You can install\/uninstall any other available Conda packages with the following commands. The packages will be installed into the currently active conda env:<\/p>\n<pre>\r\nconda install <em>PACKAGE<\/em>\r\nconda remove <em>PACKAGE<\/em>\r\n<\/pre>\n<p>To deactivate an environment:<\/p>\n<pre>\r\nconda deactivate\r\n\r\n# Your prompt will return to the default, showing no active env\r\n[a12345bc@login2[csf3] ~]$\r\n<\/pre>\n<p>Remember, when you want to <em>use<\/em> a package that you&#8217;ve installed in a conda env, you must always first activate the conda env.<\/p>\n<h3>Mamba<\/h3>\n<p>If your packages are particularly complicated and have many dependencies, using <code>mamba<\/code> to install into an empty Conda environment may be faster. This tends to be the case with Bioinformatics pipeline environments. To use <code>mamba<\/code>:<\/p>\n<pre>\r\nconda create -n myenv\r\nconda activate myenv\r\nmamba install PACKAGE1 PACKAGE2\r\n<\/pre>\n<h2>Running jobs within a Conda environment<\/h2>\n<p>While you can set up your environment on the login nodes, jobs <strong>must<\/strong> be submitted to the compute nodes via batch.<\/p>\n<h3>Serial batch job submission<\/h3>\n<p>Create a batch submission script which loads the modulefile, checking that you are loading the version you want, for example:<\/p>\n<pre>\r\n#!\/bin\/bash --login\r\n#SBATCH -p serial     # (or --partition=) Run on the nodes dedicated to 1-core jobs\r\n#SBATCH -t 4-0        # Wallclock time limit. 4-0 is 4 days. Max permitted is 7-0.\r\n\r\n# Start with a clean environment - modules are inherited from the login node by default.\r\nmodule purge\r\nmodule load apps\/binapps\/conda\/miniforge3\/VERSION\r\n\r\nconda activate myenv\r\n\r\npython3 myscript.py\r\n\r\n<\/pre>\n<p>Submit the jobscript using: <\/p>\n<pre>sbatch <em>scriptname<\/em><\/pre>\n<p>where <em>scriptname<\/em> is the name of your jobscript.<\/p>\n<h3>Parallel batch job submission<\/h3>\n<p>If the app is multicore capable, the following parallel jobscript includes an example of how you might set the number of threads\/processes automatically from SLURM variables, whether this is necessary will depend on your code.<\/p>\n<pre>\r\n#!\/bin\/bash --login\r\n#SBATCH -p multicore  # (or --partition=) Run on the AMD 168-core nodes\r\n#SBATCH -n 16         # (or --ntasks=) Number of cores to use.\r\n#SBATCH -t 4-0        # Wallclock time limit. 4-0 is 4 days. Max permitted is 7-0.\r\n\r\n## Start with a clean environment - modules are inherited from the login node by default.\r\nmodule purge\r\nmodule load apps\/binapps\/conda\/miniforge3\/VERSION\r\n\r\nconda activate myenv\r\n\r\n## set any multi-tread parameters you may need from the slurm parameter\r\n## THREADS will be 16 in this example\r\nTHREADS=$SLURM_NTASKS_PER_NODE\r\n\r\n## run code, assuming that the -t option is number of threads\r\npython3 myscript.py -t $THREADS\r\n<\/pre>\n<p>Submit the jobscript using: <\/p>\n<pre>sbatch <em>scriptname<\/em><\/pre>\n<p>where <em>scriptname<\/em> is the name of your jobscript.<\/p>\n<h2>Hints and tips<\/h2>\n<p>Conda environments and packages can be large, which can lead to your home directory or other spaces getting full, the following actions can help you clean up:<\/p>\n<p>Review your environments and remove any you no longer need:<\/p>\n<pre>\r\nconda env list\r\n\r\nconda env remove -n NAME\r\n<\/pre>\n<p>Clean up cached downloads (will not delete environments):<\/p>\n<pre>\r\nconda clean -a\r\n<\/pre>\n<p>You can specify a different location when you create a new environment provided you have write access there:<\/p>\n<pre>\r\nconda create -p \/some\/path\/you\/have\/write\/access\/myenv\r\n<\/pre>\n<p>and activate with the full path:<\/p>\n<pre>\r\nconda activate \/some\/path\/you\/have\/write\/access\/myenv\r\n<\/pre>\n<h3>Reproducible environments<\/h3>\n<p>It is good practice to keep a record of exactly what packages and versions you used to produce your work. Conda supports this by allowing you to export the complete list of packages in an environment to a YAML file:<\/p>\n<pre>\r\nconda export -n NAME --no-builds --file environment.yaml \r\n<\/pre>\n<p>We suggest putting this environment.yaml into your source control alongside your code or scripts.<\/p>\n<p>You can subsequently re-create a deleted environment using the file:<\/p>\n<pre>\r\nconda env create --file=environment.yaml\r\n<\/pre>\n<h3>Share environment details with a collaborator via a specification file<\/h3>\n<p>With the environment active: <\/p>\n<pre>\r\nconda list --explicit > specification.txt\r\n<\/pre>\n<p>To make an environment from a specification:<\/p>\n<pre>\r\nconda create --prefix INSERT-FULL-PATH\/env-name --file specification.txt\r\n<\/pre>\n<p>Further details can be found in the <a href=\"https:\/\/docs.conda.io\/projects\/conda\/en\/stable\/commands\/export.html\">conda export documentation.<\/a><\/p>\n<h3 id=\"bashrc\">Migrating from Anaconda Python &#8211; check your ~\/.bashrc file<\/h3>\n<p>If you&#8217;ve previously used Anaconda Python on the CSF to create conda environments, you may wish to check that your login environment is not automatically setting things up for Anaconda, as follows:<\/p>\n<p>If when using Anaconda python, you may have run <code>conda init bash<\/code> at some point. This will have added something to your <code>~\/.bashrc<\/code> file, which will cause Anaconda settings to be applied every time you login to the CSF. You can now remove the following lines from your <code>~\/.bashrc<\/code> file (which is just a text file):<\/p>\n<pre>\r\ngedit ~\/.bashrc\r\n  #\r\n  # Remove everything bewteen the lines show below, including the two line!\r\n  # This occurs at the bottom of your ~\/.bashrc file.\r\n\r\n# &gt;&gt;&gt; conda initialize &gt;&gt;&gt;\r\n# !! Contents within this block are managed by 'conda init' !!\r\n\r\n... <em><strong>remove all of the script code and these surrounding lines<\/strong><\/em> ...\r\n\r\n# &lt;&lt;&lt; conda initialize &lt;&lt;&lt;\r\n<\/pre>\n<h2>Moving a conda environment<\/h2>\n<p>You may need to move a conda environment:<\/p>\n<ul>\n<li>To free up space in your home directory<\/li>\n<li>Because your home directory will change path due to an account status change on CSF3. <strong>You must act before your home directory changes<\/strong><\/li>\n<\/ul>\n<h3>Where are Conda environments stored?<\/h3>\n<p>Every conda environment is stored in its own directory, the default location is a hidden directory in your home:<\/p>\n<pre>\r\n~\/.conda\/envs\r\n<\/pre>\n<p>If you specified the <code>-p<\/code> or <code>--prefix<\/code> option when you created the environment, it will be in whatever path you provided.<\/p>\n<p>You can view where your conda environments are located with the command:<\/p>\n<pre>\r\nconda env list\r\n<\/pre>\n<p>Considerations before moving<\/p>\n<ul>\n<li>If you have your own installation of miniforge3\/miniconda3\/Anaconda3 in your home directory and your home directory will change, moving is slightly different. The conda <code>base<\/code> environment cannot be moved as it is tied to the conda software installation.<\/li>\n<li>If you have installed all your tools into a single conda <code>base<\/code> environment located in your home directory, then you will need to extract this into a new location before switching to the minforge3 module.<\/li>\n<li>You may also need to clean up your <code>~\/.bashrc<\/code> file if you have ever run <code>conda init<\/code> or hard-coded any conda paths.<\/li>\n<\/ul>\n<p>If all your environments apart from <code>base<\/code> are in a non-home location (created with <code>-p<\/code> or <code>--prefix<\/code>) and you don&#8217;t use <code>base<\/code>, you are very unlikely to have to move them for changes to your home location.<\/p>\n<h3>Moving with clone<\/h3>\n<p>The simplest way to move an environment within the same system is with the clone tool, which makes a copy of the whole environment in a new location.<\/p>\n<p>If you have your own conda installation in your home, have been adding packages to the base environment and your home will move, you must clone your base environment into a new location with a new name (not base), <strong>using your original installation of conda<\/strong> with:<\/p>\n<pre>\r\nconda create --prefix \/<em>INSERT-FULL-PATH<\/em>\/envs\/my-env --clone base\r\n<\/pre>\n<p>To clone a normal (non-base) environment, for example \u2018my-env\u2019:<\/p>\n<pre>\r\nconda create --prefix \/<em>INSERT-FULL-PATH<\/em>\/envs\/my-env --clone my-env\r\n<\/pre>\n<p>In both cases the new environment can be activated (from a clean session) with:<\/p>\n<pre>\r\nmodule load apps\/binapps\/conda\/miniforge3\r\n\r\nconda activate \/<em>INSERT-FULL-PATH<\/em>\/envs\/my-env\r\n<\/pre>\n<h3>Moving with conda-pack<\/h3>\n<p>This is yet another simple method. With <strong><code>conda-pack<\/code><\/strong> you can pack your existing environments in tarball archives before your account is moved. Then after the account has been moved, you can restore your environments using the tarball. You can use the tarball to restore the virtual environment even in any other computer. The biggest advantage is that it\u00a0will\u00a0rewrite\u00a0all\u00a0hard-coded\u00a0paths\u00a0in\u00a0the\u00a0environments\u00a0and\u00a0fix\u00a0the\u00a0activation\u00a0scripts.<\/p>\n<p>First of all, you will need to install the <strong><code>conda-pack<\/code><\/strong> package itself. You don&#8217;t need to install it inside any virtual environment, you install it within your home directory:<\/p>\n<pre>\r\nmodule purge\r\nmodule load apps\/binapps\/conda\/miniforge3\/25.9.1\r\npip install conda-pack --user\r\n<\/pre>\n<p>Next look up all your conda virtual environments using:<\/p>\n<pre>\r\nconda env list\r\n<\/pre>\n<p>This will show the list of the conda virtual environment that you have. Output will look like:<\/p>\n<pre>\r\n# conda environments:\r\n#\r\n# *  -> active\r\n# + -> frozen\r\nMyPytorchTensorboard     \/mnt\/iusers01\/somegroup01\/youruserid\/.conda\/envs\/MyPytorchTensorboard\r\nmypandas                 \/mnt\/iusers01\/somegroup01\/youruserid\/.conda\/envs\/mypandas\r\n<\/pre>\n<p>Pack your virtual environment into tarball:<\/p>\n<pre>\r\nconda pack -n MyPytorchTensorboard  -o MyPytorchTensorboard.tar.gz\r\nconda pack -n mypandas -o mypandas.tar.gz\r\n\r\n# TIP: You can create\/store the tarball in your scratch directory \r\n#      if home directory space is limited\r\n<\/pre>\n<p>The <code>conda-pack<\/code> additionally packs a <strong><code>conda-unpack<\/code><\/strong> utility inside the tarball it creates.<br \/>\nThe <strong><code>conda-unpack<\/code><\/strong> utility does everything needed for restoring the conda environment in a new environment.<br \/>\nThese tarballs can be used to restore the virtual environment after account has been moved to different group\/contrbution in CSF3.<br \/>\nThey can be also used to restore the virtual environment in any other server\/computer as well.<\/p>\n<p>Restoring your virtual environment using <strong><code>conda-unpack<\/code><\/strong> from the tarball that was created created using <code>conda-pack<\/code>:<br \/>\nAfter the account move, login to your CSF3 account and do this:<\/p>\n<pre>\r\n# Remove the old virtual environment directory with all their contents if still present:\r\nrm -rf ~\/.conda\/envs\/MyPytorchTensorboard\r\nrm -rf ~\/.conda\/envs\/mypandas\r\n\r\n# Create the virtual environment directory:\r\nmkdir ~\/.conda\/envs\/MyPytorchTensorboard\r\nmkdir ~\/.conda\/envs\/mypandas\r\n\r\n# Extract the tarballs to their respective directories under <code>~\/.conda\/envs<\/code>:\r\ntar -xzf MyPytorchTensorboard.tar.gz -C ~\/.conda\/envs\/MyPytorchTensorboard\/\r\ntar -xzf mypandas.tar.gz -C ~\/.conda\/envs\/mypandas\/\r\n\r\n# Run the conda-unpack utility\r\n~\/.conda\/envs\/MyPytorchTensorboard<mark>\/bin\/conda-unpack<\/mark>\r\n~\/.conda\/envs\/mypandas<mark>\/bin\/conda-unpack<\/mark>\r\n\r\n# Running conda-unpack utility rewrites all hard-coded paths in the environment\r\n# and fixes the activation scripts\r\n\r\n# Check if the environment is detected\r\nconda env list\r\n\r\n# The conda environment should get detected, if not, activate by using the path once:\r\nconda activate ~\/.conda\/envs\/MyPytorchTensorboard\r\n\r\n# Check again if the environment is detected\r\nconda env list\r\n<\/pre>\n<h3>Moving with environment.yaml<\/h3>\n<p>This is yet another method. You can export a <code>environment.yaml<\/code> file which can be used to create virtual environment again.<br \/>\nThis the environment.yaml file will contain list of packages that are present in the virtual environment, not the packages themselves.<br \/>\nOne caveat in this method is that if your existing virtual environment is very old, there are chances that some of the dependent packages are no longer available in their public repositories from where they can be downloaded and installed again later when you use the environment.yaml file to re-create the virtual environment. It is however better to create and save an environment.yaml file any way to fall back to something if some problem happens. The environment.yaml file can be tweaked to make it work in such circumstances.<\/p>\n<p>Export the environment to environment.yaml file:<\/p>\n<pre>\r\nmodule purge\r\nmodule load apps\/binapps\/conda\/miniforge3\/25.9.1\r\n\r\nconda env list\r\n\r\nconda export --name myenv --format=environment-yaml > environment.yaml\r\n<\/pre>\n<p>Use the generated environment.yaml file to create a virtual environment:<\/p>\n<pre>\r\nmodule purge\r\nmodule load apps\/binapps\/conda\/miniforge3\/25.9.1\r\n\r\n# Remove the virtual environment directory first if present\r\nrm -rf ~\/.conda\/envs\/myenv\r\n\r\n# Create the virtual environment\r\nconda create --name myenv --file environment.yaml\r\n<\/pre>\n<h3>Tidying moved environments<\/h3>\n<p>When an environment is stored in a <code>--prefix<\/code> location, by default the whole path will be shown on the command line when active, to just show the environment name:<\/p>\n<pre>\r\nconda config --set env_prompt '({name})'\r\n<\/pre>\n<p>To tell conda where to search and not have to provide the full path to a non default location every time add the location to your <code>.condarc<\/code> file without any environment name:<\/p>\n<pre>\r\nenvs_dirs:\r\n  - \/<em>INSERT-FULL-PATH<\/em>\/envs\r\npkgs_dirs:\r\n  - \/<em>INSERT-FULL-PATH<\/em>\/conda_pkgs\r\n<\/pre>\n<p>If you are moving conda environments and are uncertain about the best approach, please <a href=\"\/csf3\/overview\/help\/\">get in touch<\/a>.<\/p>\n<h2>Example App Installs<\/h2>\n<p>Here we provide some example application installs we&#8217;ve used (or suggested) in response to application install requests. Please note that you should check each app&#8217;s own documentation and install notes for full details.<\/p>\n<h3>FBPIC on GPUs<\/h3>\n<p>See the <a href=\"https:\/\/github.com\/fbpic\/fbpic\">FBPIC Github<\/a> page.<\/p>\n<pre>\r\nmodule load apps\/binapps\/conda\/miniforge3\/25.9.1\r\nconda create -n FBPIC_GPU_rit\r\nconda activate FBPIC_GPU_rit\r\nconda install -c conda-forge numba scipy pyfftw mpi4py openmpi cupy cuda-version=13.0 cuda-cudart cuda-nvcc cuda-nvrtc\r\npip install --no-cache-dir fbpic\r\n<\/pre>\n<p>Jobscripts should contain the commands:<\/p>\n<pre>\r\nmodule purge\r\nmodule load apps\/binapps\/conda\/miniforge3\/25.9.1\r\nconda activate FBPIC_GPU_rit\r\npython <em>ionization_script<\/em>.py\r\n<\/pre>\n<h3>SCENIC+<\/h3>\n<p>See the <a href=\"https:\/\/github.com\/aertslab\/scenicplus\/\">SCENIC+ Github<\/a> page.<\/p>\n<p>Whilst there are instructions on that page showing how to install from source inside a conda environment, we&#8217;ve done an installation from the <a href=\"https:\/\/bioconda.github.io\/\">BioConda<\/a> channel because the source installation failed on the CSF:<\/p>\n<pre>\r\nmodule load apps\/binapps\/conda\/miniforge3\/25.9.1\r\nconda create -n scenicplus -y\r\nconda activate scenicplus\r\nconda install -c bioconda scenicplus -y\r\n<\/pre>\n<p>To use the installation, add to your jobscripts:<\/p>\n<pre>\r\nmodule load apps\/binapps\/conda\/miniforge3\/25.9.1\r\nconda activate scenicplus\r\n<\/pre>\n<h2>Further information<\/h2>\n<p><a href=\"https:\/\/docs.conda.io\/en\/latest\/\">Conda Documentation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview Conda is package and environment manager. It allows you to create separate environments, each containing their own files, packages (typically python packages), and package dependencies. The contents of each environment do not interact with each other. Hence it allows you to work on multiple python projects without package installs in one project breaking another project. New versions of Conda are regularly released, but environments created with older versions are generally usable with newer versions&#8230; <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/applications\/conda\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":25,"featured_media":0,"parent":86,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-11406","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/11406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/comments?post=11406"}],"version-history":[{"count":20,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/11406\/revisions"}],"predecessor-version":[{"id":12527,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/11406\/revisions\/12527"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/86"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/media?parent=11406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}