Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
technical:recipes:mpi4py-in-virtualenv [2024-03-05 17:02] – [MPI and Conda Variants] anita | technical:recipes:mpi4py-in-virtualenv [2024-03-07 15:04] – [MPI and Conda Variants] anita | ||
---|---|---|---|
Line 15: | Line 15: | ||
<WRAP center round info 60%> | <WRAP center round info 60%> | ||
- | On Caviness and DARWIN we would likely choose the Intel Python | + | On Caviness and DARWIN we would likely choose the Intel distribution |
As of November 2020, the majority of packages populating the Intel channel require baseline operating system libraries (like '' | As of November 2020, the majority of packages populating the Intel channel require baseline operating system libraries (like '' | ||
Line 292: | Line 292: | ||
$ which mpirun | $ which mpirun | ||
/ | / | ||
+ | </ | ||
+ | |||
+ | ===== DARWIN ===== | ||
+ | |||
+ | The steps for completing this work on DARWIN are similar to those presented for Caviness and of course following the first part of the directory structure setup presented for Farber. | ||
+ | |||
+ | <code bash> | ||
+ | $ vpkg_require intel-oneapi/ | ||
+ | Adding dependency `gcc/ | ||
+ | Adding package `intel-oneapi/ | ||
+ | </ | ||
+ | |||
+ | ==== Create the Virtual Environment ==== | ||
+ | |||
+ | The virtual environment is first populated with all packages that **do not** require mpi4py. | ||
+ | |||
+ | <code bash> | ||
+ | $ conda create --prefix ${HOME}/ | ||
+ | Collecting package metadata (current_repodata.json): | ||
+ | Solving environment: | ||
+ | : | ||
+ | Proceed ([y]/n)? y | ||
+ | : | ||
+ | # | ||
+ | # To activate this environment, | ||
+ | # | ||
+ | # $ conda activate / | ||
+ | # | ||
+ | # To deactivate an active environment, | ||
+ | # | ||
+ | # $ conda deactivate | ||
+ | |||
+ | </ | ||
+ | |||
+ | Before building and installing mpi4py the environment needs to be activated: | ||
+ | |||
+ | <code bash> | ||
+ | $ conda activate / | ||
+ | (/ | ||
+ | </ | ||
+ | |||
+ | ==== Building mpi4py ==== | ||
+ | |||
+ | With the new virtual environment activated, we can now build mpi4py against the local Open MPI library we added to the shell environment. | ||
+ | |||
+ | <code base> | ||
+ | (/ | ||
+ | Collecting mpi4py | ||
+ | Downloading mpi4py-3.1.5.tar.gz (2.5 MB) | ||
+ | | ||
+ | Installing build dependencies ... done | ||
+ | Getting requirements to build wheel ... done | ||
+ | Preparing metadata (pyproject.toml) ... done | ||
+ | Building wheels for collected packages: mpi4py | ||
+ | Building wheel for mpi4py (pyproject.toml) ... done | ||
+ | Created wheel for mpi4py: filename=mpi4py-3.1.5-cp310-cp310-linux_x86_64.whl size=634821 sha256=78a58c10acd22b3cf2ebf9e73b445d6775ac29f3f59c37e63bd16e27b7467ba2 | ||
+ | Stored in directory: / | ||
+ | Successfully built mpi4py | ||
+ | Installing collected packages: mpi4py | ||
+ | Successfully installed mpi4py-3.1.5 | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | <code bash> | ||
+ | (/ | ||
+ | mpi4py | ||
+ | </ | ||
+ | |||
+ | Additional packages that require mpi4py can now be installed into the environment. | ||
+ | |||
+ | ==== VALET Package Definition ==== | ||
+ | |||
+ | The new virtual environment can easily be added to your login shell and job runtime environments using VALET. | ||
+ | |||
+ | <code bash> | ||
+ | $ mkdir -p ${HOME}/ | ||
+ | $ echo ${HOME}/ | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Take note of the path echoed, then create a new file named '' | ||
+ | |||
+ | <code yaml> | ||
+ | my-sci-app: | ||
+ | prefix: / | ||
+ | description: | ||
+ | flags: | ||
+ | - no-standard-paths | ||
+ | actions: | ||
+ | - action: source | ||
+ | script: | ||
+ | sh: anaconda-activate.sh | ||
+ | order: failure-first | ||
+ | success: 0 | ||
+ | versions: | ||
+ | " | ||
+ | description: | ||
+ | dependencies: | ||
+ | - intel-oneapi/ | ||
+ | </ | ||
+ | |||
+ | === Using the Virtual Environment === | ||
+ | |||
+ | The versions of the virtual environment declared in the VALET package are listed using the '' | ||
+ | |||
+ | <code bash> | ||
+ | $ vpkg_versions my-sci-app | ||
+ | |||
+ | Available versions in package (* = default version): | ||
+ | |||
+ | [/ | ||
+ | my-sci-app | ||
+ | * 20240307 | ||
+ | </ | ||
+ | |||
+ | Activating the virtual environment is accomplished using the '' | ||
+ | |||
+ | <code bash> | ||
+ | $ vpkg_require my-sci-app/ | ||
+ | Adding dependency `gcc/ | ||
+ | Adding dependency `intel-oneapi/ | ||
+ | Adding package `my-sci-app/ | ||
+ | (/ | ||
+ | ~/ | ||
+ | (/ | ||
+ | mpi4py | ||
+ | (/ | ||
+ | / | ||
</ | </ | ||