-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{ lib | ||
, buildPythonPackage | ||
, fetchFromGitHub | ||
, pytest | ||
, pythonOlder | ||
, cudaSupport ? false | ||
, cudatoolkit | ||
, torchCudaArchList ? "Kepler" | ||
, torch | ||
, torchvision | ||
, torch-bin | ||
, torchvision-bin | ||
, opencv4 | ||
, yapf | ||
, packaging | ||
, pillow | ||
, addict | ||
, ninja | ||
, which | ||
, onnx | ||
, onnxruntime | ||
, scipy | ||
, pyturbojpeg | ||
, tifffile | ||
, lmdb | ||
}: | ||
|
||
buildPythonPackage rec { | ||
pname = "mmcv"; | ||
version = "1.7.0"; | ||
format = "setuptools"; | ||
|
||
disabled = pythonOlder "3.6"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "open-mmlab"; | ||
repo = pname; | ||
rev = "refs/tags/v${version}"; | ||
hash = "sha256-EVu6D6rTeebTKFCMNIbgQpvBS52TKk3vy2ReReJ9VQE="; | ||
}; | ||
|
||
torch-deps = if cudaSupport then [ torch-bin torchvision-bin ] else [ torch torchvision ]; | ||
nativeBuildInputs = [ ninja which ] | ||
++ lib.lists.optionals cudaSupport [ cudatoolkit.lib cudatoolkit.out cudatoolkit.cc ] ++ torch-deps; | ||
|
||
postPatch = '' | ||
substituteInPlace setup.py --replace "cpu_use = 4" "cpu_use = $NIX_BUILD_CORES" | ||
''; | ||
|
||
# reason for not using pytestCheckHook is similiar to what | ||
# is already mentioned in pkgs/development/python-modules/typed-ast | ||
# test_cnn test_ops really requires gpus to be useful. | ||
# some of the tests take exceedingly long time. | ||
# the rest of the tests are disabled due to sandbox env. | ||
checkPhase = '' | ||
pytest --ignore=tests/test_cnn \ | ||
--ignore=tests/test_ops \ | ||
--ignore=tests/test_fileclient.py \ | ||
--ignore=tests/test_load_model_zoo.py \ | ||
--ignore=tests/test_runner/test_checkpoint.py \ | ||
--ignore=tests/test_video/test_processing.py \ | ||
--ignore=tests/test_utils/test_hub.py \ | ||
--ignore=tests/test_video/test_reader.py | ||
''; | ||
nativeCheckInputs = [ pytest ]; | ||
checkInputs = [ lmdb onnx onnxruntime scipy pyturbojpeg tifffile ]; | ||
|
||
propagatedBuildInputs = [ | ||
opencv4 | ||
yapf | ||
packaging | ||
pillow | ||
addict | ||
] ++ torch-deps; | ||
|
||
pythonImportsCheck = [ | ||
"mmcv" | ||
]; | ||
|
||
MMCV_WITH_OPS = 1; | ||
FORCE_CUDA = cudaSupport; | ||
TORCH_CUDA_ARCH_LIST = torchCudaArchList; | ||
LDFLAGS = lib.optionalString cudaSupport "-L${cudatoolkit.lib}/lib"; | ||
|
||
meta = with lib; { | ||
description = "MMCV is a foundational library for computer vision research"; | ||
homepage = "https://github.com/open-mmlab/mmcv"; | ||
changelog = "https://github.com/open-mmlab/mmcv/releases/tag/v${version}"; | ||
license = with licenses; [ asl20 ]; | ||
maintainers = with maintainers; [ rxiao ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters