diff --git a/container.def b/container.def index 204172ca6dc6acd80aad8220f385d8fee9cfc703..2ad4f847e98af007dfacad1f0551a2fc97bc63e0 100644 --- a/container.def +++ b/container.def @@ -1,25 +1,53 @@ -# Get the base image from nvidia/cuda Docker image. -BootStrap: docker -From: nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 +# Use NVIDIA CUDA 11.8 with cuDNN 8 for Ubuntu 22.04 as the base +Bootstrap: docker +From: nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 +### Recreating ubuntu22fairseq docker, with apptainer for testing %post - # Install special software or additions - apt-get update -y # Good practice, update the package database. - apt-get install -y libopenblas-dev # Install the BLAS. - apt-get autoremove -y && apt-get autoclean -y # Good practice, to keep the Docker image as small as possible. + # Set the environment to noninteractive for apt installations + export DEBIAN_FRONTEND=noninteractive -%environment - # Set some environment vars - export PATH=/opt/root/bin:$PATH - export LD_LIBRARY_PATH=/opt/root/lib:$LD_LIBRARY_PATH - export PYTHONPATH=/opt/root/lib + # Update the apt repository and install essential packages + apt-get update && \ + apt-get install -y wget bzip2 && \ + apt-get clean + # Download and install Anaconda + echo "Downloading and installing Anaconda..." + ANACONDA_INSTALLER="Anaconda3-2023.07-1-Linux-x86_64.sh" + wget https://repo.anaconda.com/archive/$ANACONDA_INSTALLER + bash $ANACONDA_INSTALLER -b -p /opt/conda + rm $ANACONDA_INSTALLER + echo "Anaconda installed." -%runscript - # The command that will run when container is started via apptainer run command. - python /opt/root/tutorials/roofit/rf101_basics.py + # Set up conda path + echo "Setting up conda path..." + export PATH="/opt/conda/bin:$PATH" + + # Update conda and create a Python 3.9.13 environment as default + echo "Updating conda and configuring Python 3.9.13 environment..." + conda init bash + conda config --set always_yes yes --set changeps1 no + conda update -n base -c defaults conda + conda create -y -n py3913_env python=3.9.13 # Create a Python 3.9.13 environment + echo "Python 3.9.13 environment created." + + # Clean up package cache to reduce image size + echo "Cleaning up package cache to reduce image size..." + rm -rf /var/lib/apt/lists/* + echo "Cleanup complete." -%labels - # Add custom metadata to the container. - Author Me - Version v0.0.1 \ No newline at end of file +%environment + # Set environment variables + export PATH="/opt/conda/envs/py3913_env/bin:/opt/conda/bin:$PATH" # Ensure Python 3.9.13 from py3913_env is first in PATH + export LC_ALL=C.UTF-8 + export LANG=C.UTF-8 + export PYTHON="/opt/conda/envs/py3913_env/bin/python" # Define PYTHON variable to point to Python 3.9.13 in py3913_env + +%runscript + # Default command when the container is run + echo "The container is equipped with Anaconda and all necessary dependencies." + echo "Activating the Python 3.9.13 conda environment (py3913_env) by default..." + source /opt/conda/etc/profile.d/conda.sh # Source conda profile script + conda activate py3913_env # Activate the Python 3.9.13 environment + exec bash # Start a bash shell in the container for interactive use \ No newline at end of file