-
-
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
3 changed files
with
182 additions
and
10 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
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,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; | ||
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" | ||
''; | ||
|
||
# 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 | ||
''; | ||
|
||
nativeBuildInputs = [ ninja which ] | ||
++ lib.optionals cudaSupport [cuda-native-redist]; | ||
|
||
|
||
buildInputs = [ torch torchvision ] ++ lib.optionals cudaSupport [cuda-redist]; | ||
|
||
nativeCheckInputs = [ pytestCheckHook ]; | ||
|
||
checkInputs = [ lmdb onnx onnxruntime scipy pyturbojpeg tifffile ]; | ||
|
||
propagatedBuildInputs = [ | ||
opencv4 | ||
yapf | ||
packaging | ||
pillow | ||
addict | ||
]; | ||
|
||
pythonImportsCheck = [ | ||
"mmcv" | ||
]; | ||
|
||
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 ]; | ||
}; | ||
} |
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