Skip to content
Snippets Groups Projects
Commit 96972da0 authored by Alex, Tony (PG/R - Comp Sci & Elec Eng)'s avatar Alex, Tony (PG/R - Comp Sci & Elec Eng)
Browse files

Update container.def

parent c2aa8401
No related branches found
No related tags found
No related merge requests found
Pipeline #88460 canceled
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment