Spaces:
pngwn
/
Runtime error

File size: 5,170 Bytes
938e515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2

# -------------------------------------------------------------------------------------
# Environments to run the jobs in
# -------------------------------------------------------------------------------------
cpu: &cpu
  docker:
    - image: circleci/python:3.6.8-stretch
  resource_class: medium

gpu: &gpu
  machine:
    image: ubuntu-1604:201903-01
    docker_layer_caching: true
  resource_class: gpu.small

# -------------------------------------------------------------------------------------
# Re-usable commands
# -------------------------------------------------------------------------------------
install_python: &install_python
  - run:
      name: Install Python
      working_directory: ~/
      command: |
        pyenv install 3.6.1
        pyenv global 3.6.1

setup_venv: &setup_venv
  - run:
      name: Setup Virtual Env
      working_directory: ~/
      command: |
        python -m venv ~/venv
        echo ". ~/venv/bin/activate" >> $BASH_ENV
        . ~/venv/bin/activate
        python --version
        which python
        which pip
        pip install --upgrade pip

install_dep: &install_dep
  - run:
      name: Install Dependencies
      command: |
        pip install --progress-bar off -U 'git+https://github.com/facebookresearch/fvcore'
        pip install --progress-bar off cython opencv-python
        pip install --progress-bar off 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
        pip install --progress-bar off torch torchvision

install_detectron2: &install_detectron2
  - run:
      name: Install Detectron2
      command: |
        gcc --version
        pip install -U --progress-bar off -e .[dev]
        python -m detectron2.utils.collect_env

install_nvidia_driver: &install_nvidia_driver
  - run:
      name: Install nvidia driver
      working_directory: ~/
      command: |
        wget -q 'https://s3.amazonaws.com/ossci-linux/nvidia_driver/NVIDIA-Linux-x86_64-430.40.run'
        sudo /bin/bash ./NVIDIA-Linux-x86_64-430.40.run -s --no-drm
        nvidia-smi

run_unittests: &run_unittests
  - run:
      name: Run Unit Tests
      command: |
        python -m unittest discover -v -s tests

# -------------------------------------------------------------------------------------
# Jobs to run
# -------------------------------------------------------------------------------------
jobs:
  cpu_tests:
    <<: *cpu

    working_directory: ~/detectron2

    steps:
      - checkout
      - <<: *setup_venv

      # Cache the venv directory that contains dependencies
      - restore_cache:
          keys:
            - cache-key-{{ .Branch }}-ID-20200425

      - <<: *install_dep

      - save_cache:
          paths:
            - ~/venv
          key: cache-key-{{ .Branch }}-ID-20200425

      - <<: *install_detectron2

      - run:
          name: isort
          command: |
            isort -c -sp .
      - run:
          name: black
          command: |
            black --check -l 100 .
      - run:
          name: flake8
          command: |
            flake8 .

      - <<: *run_unittests

  gpu_tests:
    <<: *gpu

    working_directory: ~/detectron2

    steps:
      - checkout
      - <<: *install_nvidia_driver

      - run:
          name: Install nvidia-docker
          working_directory: ~/
          command: |
            curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
            distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
            curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
            sudo tee /etc/apt/sources.list.d/nvidia-docker.list
            sudo apt-get update && sudo apt-get install -y nvidia-docker2
            # reload the docker daemon configuration
            sudo pkill -SIGHUP dockerd

      - run:
          name: Launch docker
          working_directory: ~/detectron2/docker
          command: |
            nvidia-docker build -t detectron2:v0 -f Dockerfile-circleci .
            nvidia-docker run -itd --name d2 detectron2:v0
            docker exec -it d2 nvidia-smi

      - run:
          name: Build Detectron2
          command: |
            docker exec -it d2 pip install 'git+https://github.com/facebookresearch/fvcore'
            docker cp ~/detectron2 d2:/detectron2
            # This will build d2 for the target GPU arch only
            docker exec -it d2 pip install -e /detectron2
            docker exec -it d2 python3 -m detectron2.utils.collect_env
            docker exec -it d2 python3 -c 'import torch; assert(torch.cuda.is_available())'

      - run:
          name: Run Unit Tests
          command: |
            docker exec -e CIRCLECI=true -it d2 python3 -m unittest discover -v -s /detectron2/tests

workflows:
  version: 2
  regular_test:
    jobs:
      - cpu_tests
      - gpu_tests

  #nightly_test:
    #jobs:
      #- gpu_tests
    #triggers:
      #- schedule:
          #cron: "0 0 * * *"
          #filters:
            #branches:
              #only:
                #- master