Skip to content

Commit

Permalink
python3.pkgs.mmcv: init at 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
benxiao committed Mar 14, 2023
1 parent 6dca2bd commit c81b004
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
92 changes: 92 additions & 0 deletions pkgs/development/python-modules/mmcv/default.nix
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 = "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 ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6031,6 +6031,8 @@ self: super: with self; {
enablePython = true;
});

mmcv = callPackage ../development/python-modules/mmcv { };

mmh3 = callPackage ../development/python-modules/mmh3 { };

mmpython = callPackage ../development/python-modules/mmpython { };
Expand Down

0 comments on commit c81b004

Please sign in to comment.