test.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: pip install dsdl
  63. - run:
  64. name: Install mmdet dependencies
  65. # numpy may be downgraded after building pycocotools, which causes `ImportError: numpy.core.multiarray failed to import`
  66. # force reinstall pycocotools to ensure pycocotools being built under the currenct numpy
  67. command: |
  68. python -m pip install git+ssh://git@github.com/open-mmlab/mmengine.git@main
  69. pip install -U openmim
  70. mim install 'mmcv >= 2.0.0rc4'
  71. pip install -r requirements/tests.txt -r requirements/optional.txt
  72. pip install --force-reinstall pycocotools
  73. pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
  74. pip install -r requirements/tracking.txt
  75. pip install git+https://github.com/cocodataset/panopticapi.git
  76. pip install git+https://github.com/JonathonLuiten/TrackEval.git
  77. - run:
  78. name: Build and install
  79. command: |
  80. pip install -e .
  81. - run:
  82. name: Run unittests
  83. command: |
  84. python -m coverage run --branch --source mmdet -m pytest tests/
  85. python -m coverage xml
  86. python -m coverage report -m
  87. build_cuda:
  88. parameters:
  89. torch:
  90. type: string
  91. cuda:
  92. type: enum
  93. enum: ["11.1", "11.7"]
  94. cudnn:
  95. type: integer
  96. default: 8
  97. machine:
  98. image: ubuntu-2004-cuda-11.4:202110-01
  99. # docker_layer_caching: true
  100. resource_class: gpu.nvidia.small
  101. steps:
  102. - checkout
  103. - run:
  104. # CLoning repos in VM since Docker doesn't have access to the private key
  105. name: Clone Repos
  106. command: |
  107. git clone -b main --depth 1 ssh://git@github.com/open-mmlab/mmengine.git /home/circleci/mmengine
  108. - run:
  109. name: Build Docker image
  110. command: |
  111. docker build .circleci/docker -t mmdetection:gpu --build-arg PYTORCH=<< parameters.torch >> --build-arg CUDA=<< parameters.cuda >> --build-arg CUDNN=<< parameters.cudnn >>
  112. docker run --gpus all -t -d -v /home/circleci/project:/mmdetection -v /home/circleci/mmengine:/mmengine -w /mmdetection --name mmdetection mmdetection:gpu
  113. docker exec mmdetection apt-get install -y git
  114. - run:
  115. name: Install mmdet dependencies
  116. command: |
  117. docker exec mmdetection pip install -e /mmengine
  118. docker exec mmdetection pip install -U openmim
  119. docker exec mmdetection mim install 'mmcv >= 2.0.0rc4'
  120. docker exec mmdetection pip install -r requirements/tests.txt -r requirements/optional.txt
  121. docker exec mmdetection pip install pycocotools
  122. docker exec mmdetection pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
  123. docker exec mmdetection pip install -r requirements/tracking.txt
  124. docker exec mmdetection pip install git+https://github.com/cocodataset/panopticapi.git
  125. docker exec mmdetection pip install git+https://github.com/JonathonLuiten/TrackEval.git
  126. docker exec mmdetection python -c 'import mmcv; print(mmcv.__version__)'
  127. - run:
  128. name: Build and install
  129. command: |
  130. docker exec mmdetection pip install -e .
  131. - run:
  132. name: Run unittests
  133. command: |
  134. docker exec mmdetection python -m pytest tests/
  135. workflows:
  136. pr_stage_lint:
  137. when: << pipeline.parameters.lint_only >>
  138. jobs:
  139. - lint:
  140. name: lint
  141. filters:
  142. branches:
  143. ignore:
  144. - dev-3.x
  145. pr_stage_test:
  146. when:
  147. not: << pipeline.parameters.lint_only >>
  148. jobs:
  149. - lint:
  150. name: lint
  151. filters:
  152. branches:
  153. ignore:
  154. - dev-3.x
  155. - build_cpu:
  156. name: minimum_version_cpu
  157. torch: 1.8.0
  158. torchvision: 0.9.0
  159. python: 3.7.16
  160. requires:
  161. - lint
  162. - build_cpu:
  163. name: maximum_version_cpu
  164. torch: 2.0.0
  165. torchvision: 0.15.1
  166. python: 3.9.0
  167. requires:
  168. - minimum_version_cpu
  169. - hold:
  170. type: approval
  171. requires:
  172. - maximum_version_cpu
  173. - build_cuda:
  174. name: mainstream_version_gpu
  175. torch: 1.8.1
  176. # Use double quotation mark to explicitly specify its type
  177. # as string instead of number
  178. cuda: "11.1"
  179. requires:
  180. - hold
  181. - build_cuda:
  182. name: maximum_version_gpu
  183. torch: 2.0.0
  184. cuda: "11.7"
  185. cudnn: 8
  186. requires:
  187. - hold
  188. merge_stage_test:
  189. when:
  190. not: << pipeline.parameters.lint_only >>
  191. jobs:
  192. - build_cuda:
  193. name: minimum_version_gpu
  194. torch: 1.8.0
  195. cuda: "11.1"
  196. filters:
  197. branches:
  198. only:
  199. - dev-3.x