-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.torch2
114 lines (79 loc) · 4.3 KB
/
Dockerfile.torch2
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
# https://hub.docker.com/r/pytorch/pytorch
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
# NOTE:
# pytorch/pytorch:1.13.1-cuda11.6-cudnn8-runtime has python version 3.10.8, system version Ubuntu 18.04.6 LTS
# pytorch/pytorch:1.10.1-cuda11.3-cudnn8-runtime has python version 3.7.x
# pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime has python version 3.10.11, system version Ubuntu 20.04.6 LTS
# pytorch/pytorch:2.1.2-cuda11.8-cudnn8-runtime has python version 3.10.13, system version Ubuntu 20.04.6 LTS
# set the environment variable to avoid interactive installation
# which might stuck the docker build process
ENV DEBIAN_FRONTEND=noninteractive
# check distribution of the base image
RUN cat /etc/issue
# check detailed system version of the base image
RUN cat /etc/os-release
# check python version of the base image
RUN python --version
# check CUDA version of the base image if is installed
RUN if [ -x "$(command -v nvcc)" ]; then nvcc --version; fi
# NOTE: The GPU provided by the Challenge is nvidia Tesla T4
# running on a g4ad.4xlarge (or g4dn.4xlarge?) instance on AWS,
# which has 16 vCPUs, 64 GB RAM, 300 GB of local storage.
# nvidiaDriverVersion: 525.85.12
# CUDA Version: 12.0
# Check via:
# https://aws.amazon.com/ec2/instance-types/g4/
# https://aws.amazon.com/about-aws/whats-new/2021/07/introducing-new-amazon-ec2-g4ad-instance-sizes/
# https://github.com/awsdocs/amazon-ec2-user-guide/blob/master/doc_source/accelerated-computing-instances.md#gpu-instances
# https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
# https://download.pytorch.org/whl/torch_stable.html
## The MAINTAINER instruction sets the author field of the generated images.
LABEL maintainer="[email protected]"
# latest version of biosppy uses opencv
# https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo
RUN apt update
RUN apt install build-essential -y
RUN apt install git ffmpeg libsm6 libxext6 vim libsndfile1 -y
# NOTE that redis is not installed in the base image
# install redis
# https://redis.io/docs/getting-started/installation/install-redis-on-linux/
# RUN apt install lsb-release curl -y
# RUN curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
# RUN echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list
# RUN apt update && apt install redis -y
# # check redis version
# RUN redis-server --version
RUN ln -s /usr/bin/python3 /usr/bin/python && ln -s /usr/bin/pip3 /usr/bin/pip
# list packages installed in the base image
RUN pip list
# alternative pypi sources
# http://mirrors.aliyun.com/pypi/simple/
# http://pypi.douban.com/simple/
# RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
RUN python -m pip install --upgrade pip setuptools wheel
# NOTE that torch and torchaudio should be installed first
# torch already installed in the base image
# RUN pip install torch==1.13.1+cu116 -f https://download.pytorch.org/whl/torch_stable.html
# compatible with torch
# RUN pip install torchaudio==0.13.1+cu116 --no-deps -f https://download.pytorch.org/whl/torch_stable.html
RUN pip install torch-ecg
## DO NOT EDIT the 3 lines.
RUN mkdir /challenge
COPY ./requirements-docker.txt /challenge
WORKDIR /challenge
# install dependencies other than torch-related packages
RUN pip install -r requirements-docker.txt
# list packages after installing requirements
RUN pip list
# copy the whole project to the docker container
COPY ./ /challenge
# NOTE: also run test_local.py to test locally
# since GitHub Actions does not have GPU,
# one need to run test_local.py to avoid errors related to devices
# RUN python test_docker.py
# commands to run test with docker container:
# sudo docker build -t image .
# sudo docker run -it --shm-size=10240m --gpus all -v ~/Jupyter/temp/cinc2023_docker_test/model:/challenge/model -v ~/Jupyter/temp/cinc2023_docker_test/test_data:/challenge/test_data -v ~/Jupyter/temp/cinc2023_docker_test/test_outputs:/challenge/test_outputs -v ~/Jupyter/temp/cinc2023_docker_test/data:/challenge/training_data image bash
# python train_model.py training_data model
# python run_model.py model test_data test_outputs
# python evaluate_model.py labels outputs scores.csv