pypulseq
pypulseq copied to clipboard
PyPulseq requires GPU compute (cuPy) on Google Colab
This was brought to my attention during the Pulseq workshop. I tested it and confirmed it. Without GPU support, we can't import PyPulseq, because it requires SigPy, which requires cuPy and GPU compute.
================================================================
Failed to import CuPy.
If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.
On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
Original error:
ImportError: libcuda.so.1: cannot open shared object file: No such file or directory
================================================================
We should not really require GPU for sequence creation. SigPy lists cupy as optional. Is there a way to circumvent this error?
Someone in the lab mentioned this the other day. It's because this line in config.py of sigpy evaluates as True even in a completely unmodified, new Collabs notebook.
I.e. If you run
from importlib import util
cupy_enabled = util.find_spec("cupy") is not None
print(cupy_enabled)
In a new collab notebook it will print True.
This is beacuse you get cupy in google collabs notebooks by default, even when only running on CPU runtimes. If you switch to a GPU runtime (Runtime-->Change Runtime Type-->Select "T4 GPU") cupy, sigpy and pypulseq import correctly. Unfortunately you don't seem to be able to !pip uninstall cupy it claims it isn't installed.
I think the actual solution to this is submitting a PR to sigpy to change the logic in the config.py so that instead of throwing an error, an ImportError is used as an additional way to set cupy_enabled=False.
#188 Should help with this
I tested this, it looks like #188 solved it. Closing.