Random spack errors/tips/fixes

Yeah esmf@8.3.1 worked as well. Hrm. Might have to look into this in person @aekiss

$ spack install esmf@8.3.1  %intel@2021.6.0 ^openmpi@4.1.4
[+] /usr (external libxml2-2.9.7-4z3rhzq6kupydi7arpas3tj63weosukw)
==> cmake@3.24.2 : has external module in ['cmake/3.24.2']
[+] /apps/cmake/3.24.2 (external cmake-3.24.2-tr5446kifdb2z2ygjannnsdf5st2hqvl)
==> openmpi@4.1.4 : has external module in ['openmpi/4.1.4']
[+] /apps/openmpi/4.1.4 (external openmpi-4.1.4-yvq3ppqr2udizcor23x7j2x6qmd6xuxs)
[+] /usr (external pkgconf-1.4.2-vqr4piq7hjmtknwkpijthk2c6iehgcfq)
[+] /scratch/tm70/aph502/opt/spack/linux-rocky8-cascadelake/intel-2021.6.0/zlib-1.2.13-qbwlozg4cobphkvyaizqmi47xw3ara5o
[+] /usr (external m4-1.4.18-6lm7an562pgot5yidv7coxy2hp5yrknh)
[+] /scratch/tm70/aph502/opt/spack/linux-rocky8-cascadelake/intel-2021.6.0/zstd-1.5.2-hvjxleot65gcc6xeciefjgeimov4i72l
[+] /usr (external perl-5.26.3-4lnqmockddbrrcesq3m2d6ikkkwsod5l)
[+] /scratch/tm70/aph502/opt/spack/linux-rocky8-cascadelake/intel-2021.6.0/libiconv-1.16-nsqdn3qff5udwynki2uizoukrxxhgkmm
[+] /scratch/tm70/aph502/opt/spack/linux-rocky8-cascadelake/intel-2021.6.0/hdf5-1.12.2-xmsywdnkwqsjl5t3qqcngqeztbeybznn
[+] /scratch/tm70/aph502/opt/spack/linux-rocky8-cascadelake/intel-2021.6.0/parallel-netcdf-1.12.3-xty6sc5nvkq6i4geyjlxzlai4enmeqmw
[+] /scratch/tm70/aph502/opt/spack/linux-rocky8-cascadelake/intel-2021.6.0/xerces-c-3.2.3-hsf7je75hznzdp5b66f32u4b7cvbjasv
[+] /scratch/tm70/aph502/opt/spack/linux-rocky8-cascadelake/intel-2021.6.0/netcdf-c-4.9.0-t5vmcraajgpax4rnsuceljayogf5zmdb
[+] /scratch/tm70/aph502/opt/spack/linux-rocky8-cascadelake/intel-2021.6.0/netcdf-fortran-4.6.0-l6jywjuwrnqdfheafvxrnslkvrafhpr7
==> Installing esmf-8.3.1-fdatj3fq6vud74da66hhs3m4hbkdpeym
==> No binary for esmf-8.3.1-fdatj3fq6vud74da66hhs3m4hbkdpeym found: installing from source
==> Fetching https://mirror.spack.io/_source-cache/archive/6c/6c39261e55dcdf9781cdfa344417b9606f7f961889d5ec626150f992f04f146d.tar.gz
==> No patches needed for esmf
==> esmf: Executing phase: 'edit'
==> esmf: Executing phase: 'build'
==> esmf: Executing phase: 'install'
==> esmf: Successfully installed esmf-8.3.1-fdatj3fq6vud74da66hhs3m4hbkdpeym
  Fetch: 0.20s.  Build: 32m 51.05s.  Total: 32m 51.25s.
[+] /scratch/tm70/aph502/opt/spack/linux-rocky8-cascadelake/intel-2021.6.0/esmf-8.3.1-fdatj3fq6vud74da66hhs3m4hbkdpeym

Hm, interesting - thanks for looking into this. When are you next in the office?

It worked for me this morning. Weird.

For anyone who is writing a package and wants to restrict it to only work with a specific compiler, e.g. gcc

for name in spack.compilers.supported_compilers():
    if name != "gcc":
        conflicts(f"%{name}")

Note that there are plans afoot to have compilers as dependencies, which would mean this would work instead:

depends_on("gcc", type="compiler")

but currently does not.

(this info was sourced from the spack slack)

Apparently build parallelism is possible by generating dependency Makefiles and using make level parallelism

https://spack.readthedocs.io/en/latest/environments.html#generating-depfiles-from-environments

Note:

just to clarify: the Makefile does smth like touch .install/<hash> after a successful installation, so that if you interrupt make and restart it, it immediately continues from where it stopped. But if the database state changes in the meantime, then things error

fix:

make clean && make -j8

This is an example of it being used in production

https://github.com/BlueBrain/spack/blob/up-the-stream/bluebrain/deployment/gitlab-ci.yml#L213-L221

If you want to update a spack package with the latest versions spack checksum is your friend

From:

https://spack.readthedocs.io/en/latest/packaging_guide.html#spack-checksum

If you want to add new versions to a package you’ve already created, this is automated with the spack checksum command. Here’s an example for libelf:

$ spack checksum libelf 
==> Found 16 versions of libelf. 
0.8.13 http://www.mr511.de/software/libelf-0.8.13.tar.gz 
0.8.12 http://www.mr511.de/software/libelf-0.8.12.tar.gz 
0.8.11 http://www.mr511.de/software/libelf-0.8.11.tar.gz 
0.8.10 http://www.mr511.de/software/libelf-0.8.10.tar.gz
 0.8.9 http://www.mr511.de/software/libelf-0.8.9.tar.gz 
0.8.8 http://www.mr511.de/software/libelf-0.8.8.tar.gz 
0.8.7 http://www.mr511.de/software/libelf-0.8.7.tar.gz 
0.8.6 http://www.mr511.de/software/libelf-0.8.6.tar.gz 
0.8.5 http://www.mr511.de/software/libelf-0.8.5.tar.gz 
... 
0.5.2 http://www.mr511.de/software/libelf-0.5.2.tar.gz 

How many would you like to checksum? (default is 1, q to abort)

This does the same thing that spack create does, but it allows you to go back and add new versions easily as you need them (e.g., as they’re released). It fetches the tarballs you ask for and prints out a list of version commands ready to copy/paste into your package file:

==> Checksummed new versions of libelf: 
    version("0.8.13", "4136d7b4c04df68b686570afa26988ac") 
    version("0.8.12", "e21f8273d9f5f6d43a59878dc274fec7") 
    version("0.8.11", "e931910b6d100f6caa32239849947fbf") 
    version("0.8.10", "9db4d36c283d9790d8fa7df1f4d7b4d9")

By default, Spack will search for new tarball downloads by scraping the parent directory of the tarball you gave it. So, if your tarball is at http://example.com/downloads/foo-1.0.tar.gz, Spack will look in http://example.com/downloads/ for links to additional versions. If you need to search another path for download links, you can supply some extra attributes that control how your package finds new versions. See the documentation on list_url and list_depth.

Want to find out what packages depend on an installed package?

spack dependents --installed packagename/hash

(from Slack)

Installing Perl package in Spack with an old Intel compiler (2019.5.281)

  1. You may need:
--- a/var/spack/repos/builtin/packages/perl/package.py
+++ b/var/spack/repos/builtin/packages/perl/package.py
@@ -179,6 +179,10 @@ def patch(self):
         os.chmod("lib/perlbug.t", 0o644)
         filter_file("!/$B/", "! (/(?:$B|PATH)/)", "lib/perlbug.t")
 
+        with when("intel@2019.5.281"):
+            os.chmod("hints/linux.sh", 0o644)
+            filter_file("-we147 -mp -no-gcc", "", "hints/linux.sh")
+
     @classmethod
     def determine_version(cls, exe):
         perl = spack.util.executable.Executable(exe)
  1. The build may still fail at:
LD_LIBRARY_PATH=$TMPDIR/spack-stage/spack-stage-perl-5.36.0-afam6a742eef5t7bjezfue2kl7tmnwiy/spack-src:/apps/intel-ct/2019.5.281/compiler/lib  ./perl -Ilib -I. -f pod/buildtoc -q
Cwd.c: loadable library and perl binaries are mismatched (got handshake key 0xeb80080, needed 0xde00080)
make: *** [makefile:417: pod/perltoc.pod] Error 1
  1. You can use an external precompiled perl binary instead:
--- a/etc/spack/defaults/packages.yaml
+++ b/etc/spack/defaults/packages.yaml
@@ -62,3 +62,8 @@ packages:
     permissions:
       read: world
       write: user
+  perl:
+    externals:
+    - spec: perl@5.26.3~cpanm+shared+threads
+      prefix: /usr
+    buildable: false

If you get this non-obvious error:

$ spack install openmpi@4.0.2 target=x86_64
==> Error: Cannot find valid provider for virtual pkgconfig

Updating the compilers solved it:

$ spack compiler find
==> Added 2 new compilers to /home/harshula/.spack/linux/compilers.yaml
    gcc@12.2.0  gcc@11.3.0

Useful way to uninstall all packages for a particular platform:

$ spack uninstall --all arch=linux-debianbookworm-x86_64

You may need to make the following change to use target=x86_64:

--- a/etc/spack/defaults/concretizer.yaml
+++ b/etc/spack/defaults/concretizer.yaml
@@ -25,7 +25,7 @@ concretizer:
     # microarchitectures. Valid values are: "microarchitectures" or "generic".
     # An example of "microarchitectures" would be "skylake" or "bulldozer",
     # while an example of "generic" would be "aarch64" or "x86_64_v4".
-    granularity: microarchitectures
+    granularity: generic
     # If "false" allow targets that are incompatible with the current host (for
     # instance concretize with target "icelake" while running on "haswell").
     # If "true" only allow targets that are compatible with the host.

I just saw Spack convert compiler version 2019.5.281 to 19.0.5.281:

$ module load intel-compiler/2019.5.281
$ spack compilers
==> Available compilers
-- clang rocky8-x86_64 ------------------------------------------
clang@14.0.6

-- gcc rocky8-x86_64 --------------------------------------------
gcc@8.5.0
$ spack compiler find
==> Added 1 new compiler to $DOTSPACKDIR/linux/compilers.yaml
    intel@19.0.5.281
==> Compilers are defined in the following files:
    $DOTSPACKDIR/linux/compilers.yaml
$ spack compilers
==> Available compilers
-- clang rocky8-x86_64 ------------------------------------------
clang@14.0.6

-- gcc rocky8-x86_64 --------------------------------------------
gcc@8.5.0

-- intel rocky8-x86_64 ------------------------------------------
intel@19.0.5.281

Before I forget, I contacted someone who’d used spack on gadi and he said

A shared spack installation will not​ work correctly on the /g/data filesystem, since POSIX file locking is disabled for lustre mounts on gadi (see the Spack documentation here on why this is needed: https://spack.readthedocs.io/en/latest/basic_usage.html#filesystem-requirements). This decision was made by the NCI staff because they think it has a negative performance impact. So this means you will either have to make a shared Spack installation read-only, or convince the NCI staff to enable flock​ on the Lustre mounts.

@Aidan Thanks for the info. I think this is fine for the COSIMA spack instance on /g/data/ik11, as few people have write access and we don’t install things very often. At least I’ve not encountered any problem up to now.

Random spack question, but it seems mom5@master is a synonym/short-cut for mom5@git.master.

Do I have that right?

@Aidan Yes, in this case it is, because in the SPD one explicitly says that version master corresponds to git branch master (see this line)

For more information on the connection between the package version and the git version, see here.

1 Like