apptainer / singularity

Singularity has been renamed to Apptainer as part of us moving the project to the Linux Foundation. This repo has been persisted as a snapshot right before the changes.
https://github.com/apptainer/apptainer
Other
2.53k stars 424 forks source link

Unable to run Docker container using Singularity #5895

Closed samuelkyobe closed 3 years ago

samuelkyobe commented 3 years ago

Version of Singularity:

What version of Singularity are you using? Run:

$ singularity version

3.4.2-5.1.ohpc.2.0

Expected behavior

What did you expect to see when you do...?

I have pulled a docker container based on a pure python program with python dinc_job.py script to run the program on all folders in the $HOME or USER directory when the container is run. Running the container works as expected using Docker (https://hub.docker.com/r/kavrakilab/dinc-bin). However, I want to run the container on my institution's high-performance cluster. The cluster machines use Singularity, which I am using to pull my docker image hosted on Dockerhub. However, when I try to run the Singularity container, I get an error.

I expected Singularity to execute the dinc executable in the container and produce an output similar to running the container as Docker.

Actual behavior

What actually happend? Why was it incorrect?

I got this error

Traceback (most recent call last):
  File "dinc.py", line 20, in <module>
  File "/tmp/pip-install-HBcc7g/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
  File "pybel.py", line 89, in <module>
  File "pybel.py", line 68, in _formatstodict
ValueError: need more than 1 value to unpack
[3396150] Failed to execute script dinc

Steps to reproduce this behavior

How can others reproduce this issue/problem?

# get the example files from the docker container
docker pull kavrakilab/dinc-bin
mkdir ~/test-dinc
cd ~/test-dinc
docker run --rm -v $(pwd):/home/data -it kavrakilab/dinc-bin
cd data/
cp /dinc/example/1ohr_* .
cp /dinc/example/defaults.yml .
exit

# use singularity 
singularity pull docker://kavrakilab/dinc-bin 
singularity exec dinc-bin_latest.sif /usr/bin/python /dinc/dinc_job.py -o job-out.log > nohup.out &
cd test-dinc 
cat std_out_and_error.txt    # to find the error

What OS/distro are you running

$ cat /etc/os-release

NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"

How did you install Singularity

Write here how you installed Singularity. Eg. RPM, source.

RPM

dtrudg commented 3 years ago

Try running with --contain. By default singularity binds your $HOME into the container. Your home may contain python packages in $HOME/.local which the containerized python may pick up, and which may be incompatible versions for the python program being run.

samuelkyobe commented 3 years ago

I get no output at all when I add --contain .

dtrudg commented 3 years ago

Possibly you need to mount your data directory using the -B option, as if your data is in $HOME it won't be mounted in when you use --contain.

With docker you are using -v to bind data to /home/data you would need to do the same with singularity. It's also not clear why you are just run ing the docker container, but using exec of a python script for singularity. The container may need some initialization which you are missing with the exec.

In general discussion about using a container is best in Slack or on the mailing list, where more members of the Singularity community will be able to provide advice, and may have used the container before. We generally use GitHub issues to track bugs and feature requests. I'm afraid the developers are unable to answer all usage questions regarding particular containers, which don't appear to be Singularity bugs.

https://join.slack.com/t/hpcng/shared_invite/zt-ndifuetd-oZeWDtpr24rXi3A1ndjYNQ https://groups.google.com/a/lbl.gov/g/singularity

samuelkyobe commented 3 years ago

Oh yes, thank you for the advise. I will pursue the options provided.

samuelkyobe commented 3 years ago

So when I use

singularity exec -B /home/skyobe --contain dinc-bin_latest.sif /usr/bin/python /dinc/dinc_job.py -o job-out.log > nohup.out

I get this error

cat std_out_and_error.txt 
Failed to write all bytes for Bio.KDTree._CKDTree.so
fwrite: No space left on device

I actually believe that I have enough space on the HPC

df -hT /home/skyobe
Filesystem          Type  Size  Used Avail Use% Mounted on
/dev/mapper/cl-home xfs   167G   14G  153G   9% /home

And when I use the run command

singularity run -B /home/skyobe --contain dinc-bin_latest.sif /usr/bin/python /dinc/dinc_job.py -o job-out.log > nohup.out & I get this error

/usr/bin/python: /usr/bin/python: cannot execute binary file

carterpeel commented 3 years ago

Hello,

This is a templated response that is being sent out to all open issues. We are working hard on 'rebuilding' the Singularity community, and a major task on the agenda is finding out what issues are still outstanding.

Please consider the following:

  1. Is this issue a duplicate, or has it been fixed/implemented since being added?
  2. Is the issue still relevant to the current state of Singularity's functionality?
  3. Would you like to continue discussing this issue or feature request?

Thanks, Carter

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had activity in over 60 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically closed because no response was provided within 7 days.