Tests/docker (#1573)

* devel image

* try parallel

* new image
This commit is contained in:
Jirka Borovec 2020-04-23 18:52:59 +02:00 committed by GitHub
parent e977d1cde5
commit 0b22b64a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 49 additions and 16 deletions

View File

@ -14,7 +14,7 @@ references:
pip install "$TORCH_VERSION"
pip install -r requirements.txt -q
sudo pip install pytest pytest-cov pytest-flake8 -q
pip install -r ./tests/requirements.txt -q
pip install -r ./tests/requirements-devel.txt -q
tests: &tests
run:

View File

@ -6,7 +6,7 @@ name: torch-GPU
steps:
- name: testing
image: pytorch/pytorch:1.4-cuda10.1-cudnn7-devel
image: pytorchlightning/pytorch_lightning:devel-pt_1_4
environment:
SLURM_LOCALID: 0
@ -31,11 +31,10 @@ steps:
- pip install pip -U
- pip --version
- nvidia-smi
# - bash ./tests/install_AMP.sh
# - bash ./tests/install_AMP.sh
- apt-get update && apt-get install -y cmake
- pip install -r requirements.txt --user -q
- pip install coverage pytest pytest-cov pytest-flake8 codecov -q
- pip install -r ./tests/requirements.txt --user -q
- pip install -r ./tests/requirements-devel.txt --user -q
- pip list
- python -c "import torch ; print(' & '.join([torch.cuda.get_device_name(i) for i in range(torch.cuda.device_count())]) if torch.cuda.is_available() else 'only CPU')"
- coverage run --source pytorch_lightning -m py.test pytorch_lightning tests benchmarks -v --doctest-modules # --flake8

View File

@ -129,7 +129,7 @@ Test your work locally to speed up your work since so you can focus only in part
To setup a local development environment, install both local and test dependencies:
```bash
pip install -r requirements.txt
pip install -r tests/requirements.txt
pip install -r tests/requirements-devel.txt
```
You can run the full test-case in your terminal via this bash script:

View File

@ -81,7 +81,7 @@ jobs:
run: |
# python -m pip install --upgrade --user pip
pip install -r requirements.txt -U -f https://download.pytorch.org/whl/torch_stable.html -q
HOROVOD_BUILD_ARCH_FLAGS="-mfma" pip install -r ./tests/requirements.txt -q
HOROVOD_BUILD_ARCH_FLAGS="-mfma" pip install -r ./tests/requirements-devel.txt -q
# pip install tox coverage
python --version
pip --version

View File

@ -7,4 +7,5 @@ test_tube>=0.7.5
wandb>=0.8.21
trains>=0.14.1
matplotlib>=3.1.1
horovod[pytorch]>=0.19.1
# no need to install with [pytorch] as pytorch is already installed and torchvision is required only for Horovod examples
horovod>=0.19.1

View File

@ -1,7 +1,27 @@
ARG TORCH_VERSION=1.4
ARG CUDA_VERSION=10.1
FROM pytorch/pytorch:${TORCH_VERSION}-cuda${CUDA_VERSION}-cudnn7-runtime
FROM pytorch/pytorch:${TORCH_VERSION}-cuda${CUDA_VERSION}-cudnn7-devel
ENV HOROVOD_GPU_ALLREDUCE: NCCL
ENV HOROVOD_GPU_BROADCAST: NCCL
ENV HOROVOD_WITH_PYTORCH: 1
ENV HOROVOD_WITHOUT_TENSORFLOW: 1
ENV HOROVOD_WITHOUT_MXNET: 1
ENV HOROVOD_WITH_GLOO: 1
ENV HOROVOD_WITHOUT_MPI: 1
ENV PATH: "$PATH:/root/.local/bin"
ENV MAKEFLAGS: "-j$(nproc)"
COPY ./tests/install_AMP.sh install_AMP.sh
COPY ./requirements.txt requirements.txt
COPY ./requirements-extra.txt requirements-extra.txt
COPY ./tests/requirements.txt requirements-tests.txt
# Install AMP
RUN bash ./tests/install_AMP.sh
RUN apt-get update && apt-get install -y cmake && \
bash install_AMP.sh && \
pip install -r requirements.txt --user && \
pip install -r requirements-extra.txt --user && \
pip install -r requirements-tests.txt --user && \
pip list

View File

@ -17,7 +17,7 @@ cd pytorch-lightning
bash tests/install_AMP.sh
# install dev deps
pip install -r tests/requirements.txt
pip install -r tests/requirements-devel.txt
# run tests
py.test -v
@ -36,7 +36,7 @@ Make sure to run coverage on a GPU machine with at least 2 GPUs and NVIDIA apex
```bash
cd pytorch-lightning
# generate coverage (coverage is also installed as part of dev dependencies under tests/requirements.txt)
# generate coverage (coverage is also installed as part of dev dependencies under tests/requirements-devel.txt)
coverage run --source pytorch_lightning -m py.test pytorch_lightning tests examples -v --doctest-modules
# print coverage stats
@ -46,4 +46,16 @@ coverage report -m
coverage xml
```
## Building test image
You can build it on your own, note it takes lots of time, be prepared.
```bash
git clone <git-repository>
docker image build -t pytorch_lightning:devel-pt_1_4 -f tests/Dockerfile --build-arg TORCH_VERSION=1.4 .
```
To build other versions, select different Dockerfile.
```bash
docker image list
docker run --rm -it pytorch_lightning:devel-pt_1_4 bash
docker image rm pytorch_lightning:devel-pt_1_4
```

View File

@ -0,0 +1,5 @@
# install all extra dependencies for full package testing
-r ../requirements-extra.txt
# extended list of dependencies dor development and run lint and tests
-r ./requirements.txt

View File

@ -1,7 +1,3 @@
# install all extra dependencies for full package testing
-r ../requirements-extra.txt
# extended list of dependencies dor development and run lint and tests
coverage
codecov
pytest>=3.0.5