-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApptainer.backend
57 lines (49 loc) · 1.71 KB
/
Apptainer.backend
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
Bootstrap: docker
From: pytorch/pytorch:latest
%setup
mkdir -p ${SINGULARITY_ROOTFS}/CropDoc
%files
./CropDoc/requirements.txt /CropDoc/requirements.txt
%post
apt-get update && apt-get install -y \
git \
vim \
wget \
curl \
htop \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ln -s /usr/bin/python3 /usr/local/bin/python
ln -s /usr/bin/pip3 /usr/local/bin/pip
cd /CropDoc
python -m venv /venv
. /venv/bin/activate
pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
if [ -f requirements.txt ]; then
pip install -r requirements.txt
else
echo "requirements.txt not found in /CropDoc"
ls -la /CropDoc # This will list the contents of the /CropDoc directory
fi
%environment
export PYTHONPATH="/venv/lib/python3.10/site-packages:$PYTHONPATH"
export APP_NAME='CropDoc'
export SECRET_KEY='secretkey'
export FLASK_APP=manage.py
export FLASK_ENV=development
export LOGGING_LEVEL=DEBUG
export ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5000
export LC_ALL=C
%runscript
. /venv/bin/activate
cd /CropDoc
if [ -x "$(command -v nvidia-smi)" ]; then
echo "CUDA is available. Using GPU."
python -c "import torch; print('CUDA available:', torch.cuda.is_available()); print('CUDA version:', torch.version.cuda); print('GPU:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'None')"
else
echo "CUDA is not available. Using CPU."
fi
python manage.py runserver --reload
%startscript
. /venv/bin/activate
cd /CropDoc && python manage.py runserver --reload