CryoSPARC is not supported on login nodes and must be installed and run on a GPU node. Running CryoSPARC on a login node can overload shared system resources and may lead to port conflicts when multiple instances are started at the same time.
Currently, only Fir and Nibi support CryoSPARC installation and execution on GPU nodes, as these systems provide outbound HTTPS access from GPU nodes to the CryoSPARC download site.
This tutorial describes how to build a standalone CryoSPARC instance in an Apptainer container image on a GPU node, allowing users to run CryoSPARC through GPU batch jobs while reducing filesystem load.
Create the directory where you would like to install CryoSPARC.
exportHOST_PATH=/path/to/cryosparc
Set up the LICENSE_ID by replacing 1a23b4d5-67ef-89g0-hi1j-kl2m3n4o5p6q with the licence key you obtained from https://cryosparc.com/download in Step 1.
Bootstrap:docker
From:ubuntu
Stage:build
%environment
exportLC_ALL=C
%post
HOST_PATH=/path/to/cryosparc# Change the path to the same you set in Step 2.INSTALL_PATH=/usr/local/cryosparc
mkdir-p$HOST_PATH/
mkdir-p/localscratch
mkdir-p$INSTALL_PATH%labels
%help
Build the first container image using the prepared definition file.
Bootstrap:localimage
From:ubuntu.sif
Stage:build
%environment
exportLC_ALL=C
exportPATH="/usr/local/cryosparc/cryosparc_master/bin:$PATH"%post
exportHOST_PATH="/path/to/cryosparc"# Change this path to match the one specified in Step 2 and in ubuntu.def.exportLICENSE_ID="1a23b4d5-67ef-89g0-hi1j-kl2m3n4o5p6q"# Replace this with your license ID.exportMY_EMAIL="user@email.com"# Replace this with your email address. This email is what you used to obtain the licence, and will be used as the login email for CryoSPARC.exportCRYOSPARC_PASSWD="Password123"# Replace this with your password. This will be used to log in to CryoSPARC.exportFIRSTNAME="FirstName"# Replace this with your first name.exportLASTNAME="LastName"# Replace this with your last name.exportUSER="username"# Important: replace this with your CCDB username.exportINSTALL_PATH="/usr/local/cryosparc"exportCRYOSPARC_DB_PATH="${HOST_PATH}/database"exportWORKER_PATH="${INSTALL_PATH}/cryosparc_worker"exportSSD_PATH="/tmp"exportPATH="$INSTALL_PATH/cryosparc_master/bin:$PATH"aptupdate&&aptinstallvimwgetcurl-y
apt-getupdate&&apt-getinstall-yiproute2
mkdir-p${INSTALL_PATH}&&cd${INSTALL_PATH}tar-xf${HOST_PATH}/cryosparc2_master.tar.gz-C${INSTALL_PATH}tar-xf${HOST_PATH}/cryosparc2_worker.tar.gz-C${INSTALL_PATH}mkdir-p/etc/pki/tls/certs/
cp-r/etc/ssl/certs/ca-certificates.crt/etc/pki/tls/certs/ca-bundle.crt
cd${INSTALL_PATH}/cryosparc_master
./install.sh--standalone\--license${LICENSE_ID}\--worker_path${WORKER_PATH}\--ssdpath${SSD_PATH}\--dbpath${CRYOSPARC_DB_PATH}\--initial_email${MY_EMAIL}\--initial_username"${USER}"\--initial_firstname"${FIRSTNAME}"\--initial_lastname"${LASTNAME}"\--port61000\--initial_password"${CRYOSPARC_PASSWD}"\--yes
mv${INSTALL_PATH}/cryosparc_master/config.sh$HOST_PATH/cryosparc_master/config.sh
ln-s$HOST_PATH/cryosparc_master/config.sh${INSTALL_PATH}/cryosparc_master/config.sh
mv${INSTALL_PATH}/cryosparc_master/run$HOST_PATH/cryosparc_master/run
ln-s$HOST_PATH/cryosparc_master/run${INSTALL_PATH}/cryosparc_master/run
mv${INSTALL_PATH}/cryosparc_worker/registry$HOST_PATH/cryosparc_worker/registry
ln-s$HOST_PATH/cryosparc_worker/registry${INSTALL_PATH}/cryosparc_worker/registry
%labels
%help
#!/bin/bash#SBATCH --account=def-account#SBATCH --time=3:00:00#SBATCH --nodes=1#SBATCH --ntasks=1#SBATCH --cpus-per-task=8#SBATCH --mem=64000M#SBATCH --gpus=h100:1#SBATCH --mail-user=user@email.com#SBATCH --mail-type=ALLmkdir$SLURM_TMPDIR/cryosparc_cache
moduleloadapptainer
exportHOST_PATH=/path/to/cryosparc# replace this path to the one specified in Step 2.cd${HOST_PATH}sed-i"s/^export CRYOSPARC_MASTER_HOSTNAME=.*/export CRYOSPARC_MASTER_HOSTNAME=\"$(hostname-f)\"/"cryosparc_master/config.sh
apptainerinstancestart--nv-B${HOST_PATH}-B$SLURM_TMPDIR:/tmp\${HOST_PATH}/cryosparc.sifcryosparc-master
apptainerexecinstance://cryosparc-master/usr/local/cryosparc/cryosparc_master/bin/cryosparcmstart
echo"To start Cryosparc, please run the following in your PC terminal:"echo"ssh -N -L 61000:$HOSTNAME:61000 ${USER}@fir.alliancecan.ca"echoecho"User the email and password you set up in cryosparc.def to log in:"echoecho"Don't forget to cancel the job when the analysis is finished"echo"scancel ${SLURM_JOB_ID}"while((!stop_now));doecho"[$(date)] starting one chunk"# do one bounded unit of work here# keep each chunk short enough that it can finish before the buffer expiressleep60echo"[$(date)] chunk done"done
Submit the job:
sbatchrun_cryosparc.sh
Note
After the job starts, follow the instructions in the job log file (for example, slurm-123456.out) to open the CryoSPARC graphical interface in your local browser. Use the interface to set up your CryoSPARC job and launch the worker. Once the CryoSPARC job is complete, check the output files and cancel the Slurm job with scancel; otherwise, the job will continue running until it reaches the walltime limit.