OMP: System error #30: Read-only file system when using singularity container for PyTorch

Hi!

I am new to singularity containers. I have written a deep learning model by using pytorch to run on a GPU cluster. For that I needed a singularity image.

OS: Debian
Singularity version: 3.9.7

Definition file (singularity.def):

Bootstrap: docker
From: nvcr.io/nvidia/pytorch:21.10-py3

%post

	pip install --upgrade pip
	export PIP_DEFAULT_TIMEOUT=100
	/opt/conda/bin/pip install pytorch-lightning
	/opt/conda/bin/pip install torchmetrics
	/opt/conda/bin/pip install ujson
	/opt/conda/bin/pip install captum

I created singularity image by:
sudo singularity build singularity.sif singularity.def

To test if I can use PyTorch I created a simple python file (a.py):

print("Hello")

import numpy as np
print(np.ones(5))

import torch
print(torch.ones(2, 3))

For the convenience I put the singularity image and python file at the same folder at ~/projects/trial

When I execute the singularity by:
singularity exec --nv -B ~/projects/trial ~/projects/trial/singularity.sif python ~/projects/trial/a.py

I get the following error:

WARNING: Could not find any nv files on this host!
"uname": executable file not found in $PATH
Hello
[1. 1. 1. 1. 1.]
OMP: Error #178: Function Can't open SHM2 failed:
OMP: System error #30: Read-only file system
Aborted

The problem occurs when I import torch. I could not find a solution this problem.
I really appreciate your help.

It looks as if the binding is invalid as the destination directory is missing:

-B ~/projects/trial

Additionally, the --writable flag might be needed and I would recommend to check singularity-specific discussion boards for more information.

Thank you very much for the reply!

I will look at your suggestions and test it again.