Topaz on CryoSparc 4.0.2 and Python virtual environment

We are looking at using Topaz with CryoSparc 4.0.2 and have run into an issue.
I’m using the instructions here as a reference: Topaz (Bepler, et al) - CryoSPARC Guide

On our HPC clusters we don’t recommend Conda as we compile dependencies and libraries like PyTorch, CUDA, etc. as Python wheels for our systems so we recommend users use a Python virtual environment instead. This has typically worked for most use cases as an alternative to Conda.

So we successfully installed Topaz 0.2.4 in a Python virtual environment as follows and it works from the wrapper script on the command line:


// Install topaz
module load python
module load cuda/11.0
virtualenv --no-download ENV
source ENV/bin/activate
pip install topaz-em==0.2.4
 
// create a wrapper script ~/topaz.sh
#!/usr/bin/env bash
if command -v conda > /dev/null 2>&1; then
   conda deactivate > /dev/null 2>&1 || true  # ignore any errors
   conda deactivate > /dev/null 2>&1 || true  # ignore any errors
fi
unset _CE_CONDA
unset CONDA_DEFAULT_ENV
unset CONDA_EXE
unset CONDA_PREFIX
unset CONDA_PROMPT_MODIFIER
unset CONDA_PYTHON_EXE
unset CONDA_SHLVL
unset PYTHONPATH
unset LD_PRELOAD
unset LD_LIBRARY_PATH
source ENV/bin/activate
topaz $@

// test wrapper
chmod +x topaz.sh
~/topaz.sh --version
TOPAZ 0.2.4

// In the CryoSPARC interface, specify the full path to topaz.sh as the "Path to Topaz executable" parameter: /home/myuser/topaz.sh

However, when using Topaz in CryoSparc 4.0.2, we receive the following error:

Traceback (most recent call last): File "cryosparc_worker/cryosparc_compute/run.py", line 93, in cryosparc_compute.run.main File "/project/myuser/software/cryosparc/cryosparc_worker/cryosparc_compute/jobs/topaz/run_topaz.py", line 112, in run_topaz_wrapper_train topaz_version = utils.get_topaz_version(topaz_exec_path) File "/project/myuser/software/cryosparc/cryosparc_worker/cryosparc_compute/jobs/topaz/topaz_utils.py", line 136, in get_topaz_version f'Cannot determine topaz version, command "{topaz_exec_path} --version" did not produce valid output: "{topaz_version}"' AssertionError: Cannot determine topaz version, command "/home/myuser/topaz.sh --version" did not produce valid output: "/home/myuser/topaz.sh: line 18: topaz: command not found"

Is there any possibility to run Topaz with CryoSparc without using Anaconda/Miniconda e.g. a source code compile of the Topaz command, Python virtualenv, container, etc.?
Any advice is most appreciated. Thank you.

cheers,

VM

Is this line literally included in the script, might

source /full/path/to/ENV/bin/activate

be needed?

Have you also tested

exec topaz $@

(as recommended in the guide) and that test failed for some reason?

1 Like

Thanks for the suggestions – we tried both exec topaz $@ and just topaz $@ but I suspect the lack of an absolute path may be the issue – thanks for pointing that out! Will test again and update the thread.

Looks like adding the absolute path solved the issue, that was a simple fix, sorry for missing that. Thank you for your assistance!

1 Like