Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3.pkgs.mmcv: init at 1.7.1 #219815

Merged
merged 1 commit into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
122 changes: 122 additions & 0 deletions pkgs/development/python-modules/mmcv/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, pytestCheckHook
, pythonOlder
, torch
, torchvision
, opencv4
, yapf
, packaging
, pillow
, addict
, ninja
, which
, onnx
, onnxruntime
, scipy
, pyturbojpeg
, tifffile
, lmdb
, symlinkJoin
}:

let
inherit (torch) cudaCapabilities cudaPackages cudaSupport;
inherit (cudaPackages) backendStdenv cudaVersion;

cuda-common-redist = with cudaPackages; [
cuda_cccl # <thrust/*>
libcublas # cublas_v2.h
libcusolver # cusolverDn.h
libcusparse # cusparse.h
];

cuda-native-redist = symlinkJoin {
name = "cuda-native-redist-${cudaVersion}";
paths = with cudaPackages; [
cuda_cudart # cuda_runtime.h
cuda_nvcc
] ++ cuda-common-redist;
};

cuda-redist = symlinkJoin {
name = "cuda-redist-${cudaVersion}";
paths = cuda-common-redist;
};

in
buildPythonPackage rec {
pname = "mmcv";
version = "1.7.1";
format = "setuptools";

disabled = pythonOlder "3.6";

src = fetchFromGitHub {
owner = "open-mmlab";
repo = pname;
SuperSandro2000 marked this conversation as resolved.
Show resolved Hide resolved
rev = "refs/tags/v${version}";
hash = "sha256-b4MLBPNRCcPq1osUvqo71PCWVX7lOjAH+dXttd4ZapU";
};

preConfigure = ''
export MMCV_WITH_OPS=1
'' + lib.optionalString cudaSupport ''
export CC=${backendStdenv.cc}/bin/cc
export CXX=${backendStdenv.cc}/bin/c++
export TORCH_CUDA_ARCH_LIST="${lib.concatStringsSep ";" cudaCapabilities}"
export FORCE_CUDA=1
'';

postPatch = ''
substituteInPlace setup.py --replace "cpu_use = 4" "cpu_use = $NIX_BUILD_CORES"
'';

preCheck = ''
# remove the conflicting source directory
rm -rf mmcv
'';

# 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.
disabledTests = [
"test_cnn"
"test_ops"
"test_fileclient"
"test_load_model_zoo"
"test_processing"
"test_checkpoint"
"test_hub"
"test_reader"
];

nativeBuildInputs = [ ninja which ]
++ lib.optionals cudaSupport [ cuda-native-redist ];

buildInputs = [ torch ] ++ lib.optionals cudaSupport [ cuda-redist ];

nativeCheckInputs = [ pytestCheckHook torchvision lmdb onnx onnxruntime scipy pyturbojpeg tifffile ];

propagatedBuildInputs = [
torch
opencv4
yapf
SuperSandro2000 marked this conversation as resolved.
Show resolved Hide resolved
packaging
pillow
addict
];

pythonImportsCheck = [
"mmcv"
];

meta = with lib; {
description = "A Foundational Library for Computer Vision Research";
homepage = "https://github.com/open-mmlab/mmcv";
benxiao marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -6078,6 +6078,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