test.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. version: 2.1
  2. # the default pipeline parameters, which will be updated according to
  3. # the results of the path-filtering orb
  4. parameters:
  5. lint_only:
  6. type: boolean
  7. default: true
  8. jobs:
  9. lint:
  10. docker:
  11. - image: cimg/python:3.7.4
  12. steps:
  13. - checkout
  14. - run:
  15. name: Install pre-commit hook
  16. command: |
  17. pip install pre-commit
  18. pre-commit install
  19. - run:
  20. name: Linting
  21. command: pre-commit run --all-files
  22. - run:
  23. name: Check docstring coverage
  24. command: |
  25. pip install interrogate
  26. interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-magic --ignore-regex "__repr__" --fail-under 85 mmdet
  27. build_cpu:
  28. parameters:
  29. # The python version must match available image tags in
  30. # https://circleci.com/developer/images/image/cimg/python
  31. python:
  32. type: string
  33. torch:
  34. type: string
  35. torchvision:
  36. type: string
  37. docker:
  38. - image: cimg/python:<< parameters.python >>
  39. resource_class: large
  40. steps:
  41. - checkout
  42. - run:
  43. name: Install Libraries
  44. command: |
  45. sudo apt-get update
  46. sudo apt-get install -y ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx libjpeg-dev zlib1g-dev libtinfo-dev libncurses5
  47. - run:
  48. name: Configure Python & pip
  49. command: |
  50. pip install --upgrade pip
  51. pip install wheel
  52. - run:
  53. name: Install PyTorch
  54. command: |
  55. python -V
  56. python -m pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html
  57. - when:
  58. condition:
  59. equal: ["3.9.0", << parameters.python >>]
  60. steps:
  61. - run: pip install "protobuf <= 3.20.1" && sudo apt-get update && sudo apt-get -y install libprotobuf-dev protobuf-compiler cmake
  62. - run:
  63. name: Install mmdet dependencies
  64. # numpy may be downgraded after building pycocotools, which causes `ImportError: numpy.core.multiarray failed to import`
  65. # force reinstall pycocotools to ensure pycocotools being built under the currenct numpy
  66. command: |
  67. python -m pip install git+ssh://git@github.com/open-mmlab/mmengine.git@main
  68. pip install -U openmim
  69. mim install 'mmcv >= 2.0.0rc4'
  70. pip install -r requirements/tests.txt -r requirements/optional.txt
  71. pip install --force-reinstall pycocotools
  72. pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
  73. pip install git+https://github.com/cocodataset/panopticapi.git
  74. - run:
  75. name: Build and install
  76. command: |
  77. pip install -e .
  78. - run:
  79. name: Run unittests
  80. command: |
  81. python -m coverage run --branch --source mmdet -m pytest tests/
  82. python -m coverage xml
  83. python -m coverage report -m
  84. build_cuda:
  85. parameters:
  86. torch:
  87. type: string
  88. cuda:
  89. type: enum
  90. enum: ["10.1", "10.2", "11.1", "11.7"]
  91. cudnn:
  92. type: integer
  93. default: 7
  94. machine:
  95. image: ubuntu-2004-cuda-11.4:202110-01
  96. # docker_layer_caching: true
  97. resource_class: gpu.nvidia.small
  98. steps:
  99. - checkout
  100. - run:
  101. # CLoning repos in VM since Docker doesn't have access to the private key
  102. name: Clone Repos
  103. command: |
  104. git clone -b main --depth 1 ssh://git@github.com/open-mmlab/mmengine.git /home/circleci/mmengine
  105. - run:
  106. name: Build Docker image
  107. command: |
  108. docker build .circleci/docker -t mmdetection:gpu --build-arg PYTORCH=<< parameters.torch >> --build-arg CUDA=<< parameters.cuda >> --build-arg CUDNN=<< parameters.cudnn >>
  109. docker run --gpus all -t -d -v /home/circleci/project:/mmdetection -v /home/circleci/mmengine:/mmengine -w /mmdetection --name mmdetection mmdetection:gpu
  110. docker exec mmdetection apt-get install -y git
  111. - run:
  112. name: Install mmdet dependencies
  113. command: |
  114. docker exec mmdetection pip install -e /mmengine
  115. docker exec mmdetection pip install -U openmim
  116. docker exec mmdetection mim install 'mmcv >= 2.0.0rc4'
  117. docker exec mmdetection pip install -r requirements/tests.txt -r requirements/optional.txt
  118. docker exec mmdetection pip install pycocotools
  119. docker exec mmdetection pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
  120. docker exec mmdetection pip install git+https://github.com/cocodataset/panopticapi.git
  121. docker exec mmdetection python -c 'import mmcv; print(mmcv.__version__)'
  122. - run:
  123. name: Build and install
  124. command: |
  125. docker exec mmdetection pip install -e .
  126. - run:
  127. name: Run unittests
  128. command: |
  129. docker exec mmdetection python -m pytest tests/
  130. workflows:
  131. pr_stage_lint:
  132. when: << pipeline.parameters.lint_only >>
  133. jobs:
  134. - lint:
  135. name: lint
  136. filters:
  137. branches:
  138. ignore:
  139. - dev-3.x
  140. pr_stage_test:
  141. when:
  142. not: << pipeline.parameters.lint_only >>
  143. jobs:
  144. - lint:
  145. name: lint
  146. filters:
  147. branches:
  148. ignore:
  149. - dev-3.x
  150. - build_cpu:
  151. name: minimum_version_cpu
  152. torch: 1.6.0
  153. torchvision: 0.7.0
  154. python: 3.7.4 # The lowest python 3.7.x version available on CircleCI images
  155. requires:
  156. - lint
  157. - build_cpu:
  158. name: maximum_version_cpu
  159. torch: 2.0.0
  160. torchvision: 0.15.1
  161. python: 3.9.0
  162. requires:
  163. - minimum_version_cpu
  164. - hold:
  165. type: approval
  166. requires:
  167. - maximum_version_cpu
  168. - build_cuda:
  169. name: mainstream_version_gpu
  170. torch: 1.8.1
  171. # Use double quotation mark to explicitly specify its type
  172. # as string instead of number
  173. cuda: "10.2"
  174. requires:
  175. - hold
  176. - build_cuda:
  177. name: maximum_version_gpu
  178. torch: 2.0.0
  179. cuda: "11.7"
  180. cudnn: 8
  181. requires:
  182. - hold
  183. merge_stage_test:
  184. when:
  185. not: << pipeline.parameters.lint_only >>
  186. jobs:
  187. - build_cuda:
  188. name: minimum_version_gpu
  189. torch: 1.6.0
  190. cuda: "10.1"
  191. filters:
  192. branches:
  193. only:
  194. - dev-3.x