-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer.def
127 lines (97 loc) · 4.09 KB
/
container.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Bootstrap: docker
From: ubuntu:latest
# vim: ft=sh
# Description of this container.
%help
This is a basic singularity image for general python execution with a focus on deep learning.
To build this container from your workstation at Inria, use:
sudo singularity build container.sif container.def
# Metadata for this container
%labels
Author [email protected]
Version v0.1.0
# List of host files to be copied inside the container.
%files
# You can specify a single path.
# In this case, the file will be copied to the same path from / in the container
# Example:
# foo/bar/hello.txt
# will copy `foo/bar/hello.txt` to `/foo/bar/hello.txt` in the container.
# You may also specify the location in the container
# Example:
# foo/bar/hello.txt /bonjour
# will copy `foo/bar/hello.txt` to `/bonjour/hello.txt` in the container.
requirements.txt
# The `%environment` section allows you to define environment variables that will be set at runtime.
# Note that these variables are not made available at build time by their inclusion in the
# `%environment` section.
# This means that if you need the same variables during the build process, you should also define
# them in your `%post` section.
%environment
export PYTHONPATH=.
# This section is where we download files from the internet with tools like git and wget, install
# new software and libraries, write configuration files, create new directories, etc.
%post
export DEBIAN_FRONTEND="noninteractive"
export TZ="Europe/Paris"
# Update Ubuntu apt repository
apt-get update
# Upgrade packages
apt-get upgrade -y
# Install apt packages
alias apt_install="apt-get install -y --no-install-recommends"
##########
# PYTHON #######################################################################################
##########
# Secify the version of python you want to install
PYTHON_VERSION='3.9'
PYTHON=python${PYTHON_VERSION}
VERSION_NUMBER=$(echo $PYTHON_VERSION | cut -d '.' -f 2)
# Needed for older versions of python (<3.10)
if [ $VERSION_NUMBER -lt 10 ]; then
# if true; then
apt_install software-properties-common gpg-agent
add-apt-repository ppa:deadsnakes/ppa
apt update -y
fi
apt_install curl # To download `get-pip.py` from the internet
apt_install ca-certificates # Required by `curl`
apt_install $PYTHON # The specified version of Python
apt_install ${PYTHON}-dev # Header files, a static library and development tools for
# building Python modules and more.
apt_install ${PYTHON}-distutils # Support for building and installing additional Python
# modules
# Set the default python
ln -sf /usr/bin/$PYTHON /usr/bin/python3
ln -sf /usr/bin/python3 /usr/bin/python
# Install pip
curl https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py
python /tmp/get-pip.py
# Install some pip packages
alias pip_install="python -m pip install"
pip_install -U pip setuptools
################
# APT packages #################################################################################
################
# >>> Here you can install your apt packages
# For example,
# apt_install cmake
# apt_install nvidia-cuda-toolkit
# apt_install sox time gcc
apt_install git
apt_install gcc g++
apt_install libglib2.0-0 libsm6 libxrender1 libxext6
apt_install cmake make
apt_install protobuf-compiler libprotobuf-dev
###################
# Python packages ##############################################################################
###################
# >>> Here you can install your python packages
# For example,
# pip_install torch
# pip_install numpy
# Install other projects requirements
pip_install torch
pip_install -r /requirements.txt
mkdir -p /usr/nltk_data
python -c "import nltk; nltk.download('punkt', download_dir='/usr/nltk_data')"