Run Singularity on a shared GitLab runner

Run Singularity on a shared GitLab runner

Hello,

My main goal is to implement some tests that use OpenMPI and parallel computing but on a shared GitLab runner. I have been unsuccessful in doing so using Docker because of the limitation of being in an unprivileged environment.
Since I also had to work on a Singularity image, I’ve been recently trying to implement it in GitLab CI without much success as there isn’t a lot of documentation.

I have been able to retrieve an image from Sylabs Cloud but I am not able to use the run/shell/exec commands.
The picture below shows what I get.

From what I understand it has to do with some privileged issue again.
I have tried using the –userns flag and changing the setting to an unprivileged installation as indicated here User Namespaces & Fakeroot — Singularity Admin Guide 3.5 documentation but apparently the issue wasn’t linked to this.

Here is my .gitlab-ci.yml file:

If there is anything else I could provide that could help solve this issue please let me know.
If there are other solutions to be able to run tests with parallel computing using OpenMPI on a shared runner I am open to hear about them as well.

Thank you for reading.

Hi Leo,

Just wondering if you found a solution to this yet? I’m doing something similar with a GitLab specific runner set up on my local machine, and ran into the exact same problem as you.

If this method doesn’t work out, I’m thinking about converting the singularity image to a docker image, and run GitLab CI with the docker image? Have you tried this?

Your comments are greatly appreciated.

Regards,
Yan

Hi yanliusp,

Sorry for the delayed answer.
I have sadly not found a solution to this.
For the Docker solution, as you can see at the beginning of my post, it was my first attempt and the reason why I attempted to make it work with Singularity. I really doubt converting the image from Singularity will change much but it’s worth a try. Have you tried it yet?

For now, I am running the runners on my local machine.

Sincerely,
Leo

Hi Leo,

Thanks for your reply!

Ah yes, I have root access of the specific runner so converting it to docker image worked for me.

On the topic of using singularity images, I think the best (only?) way is to write/find a custom executor (The Custom executor | GitLab) as a ‘singularity’ executor that can load the singularity image directly (instead of pulling the singularity image as in your script) like the docker executor&image. I don’t know if such shared runner exists (I couldn’t find it), or one would need to configure his/her own specific runner. Is this what you did?

Hi yanliusp,

I ended up using a local runner to make things run smoothly as I was running out of time.
I was not able to find a way to make it work with a shared runner.

Sincerely,
Leo

Hi Leo,

Did you convert the singularity image to a docker image and use it; or you set up a custom executor to use the singularity image? If the latter, would be very interested to see how you did it! Thanks~

Regards,
Yan