lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

caffe2: init at 0.8.1 (#34956)

authored by

Yuri Aisaka and committed by
Joachim F
f8c48908 a5ebf4ad

+202
+140
pkgs/development/libraries/science/math/caffe2/default.nix
··· 1 + { stdenv, lib, config, fetchFromGitHub 2 + , cmake 3 + , glog, google-gflags, gtest 4 + , protobuf, snappy 5 + , python, future, six, python-protobuf, numpy, pydot 6 + , eigen3 7 + , doxygen 8 + , useCuda ? (config.cudaSupport or false), cudatoolkit ? null 9 + , useCudnn ? (config.cudnnSupport or false), cudnn ? null 10 + , useOpenmp ? false, openmp ? null 11 + , useOpencv3 ? true, opencv3 ? null 12 + , useLeveldb ? false, leveldb ? null 13 + , useLmdb ? true, lmdb ? null 14 + , useRocksdb ? false, rocksdb ? null 15 + , useZeromq ? false, zeromq ? null 16 + , useMpi ? false, mpi ? null 17 + # TODO: distributed computations 18 + #, useGloo ? false 19 + #, useNccl ? false 20 + #, useNnpack ? false 21 + }: 22 + 23 + assert useCuda -> cudatoolkit != null; 24 + assert useCudnn -> (useCuda && cudnn != null); 25 + assert useOpencv3 -> opencv3 != null; 26 + assert useLeveldb -> leveldb != null; 27 + assert useLmdb -> lmdb != null; 28 + assert useRocksdb -> rocksdb != null; 29 + assert useZeromq -> zeromq != null; 30 + assert useMpi -> mpi != null; 31 + 32 + let 33 + # Third party modules that caffe2 holds as git submodules. 34 + # Download them and create symlinks from caffe2/third_party. 35 + installExtraSrc = extra: '' 36 + rmdir "third_party/${extra.dst}" 37 + ln -s "${extra.src}" "third_party/${extra.dst}" 38 + ''; 39 + 40 + cub = { 41 + src = fetchFromGitHub rec { 42 + owner = "NVlabs"; 43 + repo = "cub"; 44 + rev = "v1.7.4"; 45 + sha256 = "0ksd5n1lxqhm5l5cd2lps4cszhjkf6gmzahaycs7nxb06qci8c66"; 46 + }; 47 + dst = "cub"; 48 + }; 49 + 50 + pybind11 = { 51 + src = fetchFromGitHub { 52 + owner = "pybind"; 53 + repo = "pybind11"; 54 + rev = "86e2ad4f77442c3350f9a2476650da6bee253c52"; 55 + sha256 = "05gi58dirvc8fgm0avpydvidzsbh2zrzgfaq671ym09f6dz0bcgz"; 56 + }; 57 + dst = "pybind11"; 58 + }; 59 + in 60 + 61 + stdenv.mkDerivation rec { 62 + name = "caffe2-${version}"; 63 + version = "0.8.1"; 64 + src = fetchFromGitHub { 65 + owner = "caffe2"; 66 + repo = "caffe2"; 67 + rev = "v${version}"; 68 + sha256 = "18y7zjc69j6n5642l9caddl641b0djf3pjn4wacdsc1wk1jiyqk8"; 69 + }; 70 + 71 + nativeBuildInputs = [ cmake doxygen gtest ]; 72 + outputs = [ "bin" "out" ]; 73 + propagatedBuildOutputs = [ ]; # otherwise propagates out -> bin cycle 74 + 75 + buildInputs = [ glog google-gflags protobuf snappy eigen3 ] 76 + ++ lib.optional useCuda cudatoolkit 77 + ++ lib.optional useCudnn cudnn 78 + ++ lib.optional useOpenmp openmp 79 + ++ lib.optional useOpencv3 opencv3 80 + ++ lib.optional useLeveldb leveldb 81 + ++ lib.optional useLmdb lmdb 82 + ++ lib.optional useRocksdb rocksdb 83 + ++ lib.optional useZeromq zeromq 84 + ; 85 + propagatedBuildInputs = [ numpy future six python-protobuf pydot ]; 86 + 87 + patches = lib.optional stdenv.cc.isClang [ ./update_clang_cvtsh_bugfix.patch ]; 88 + 89 + cmakeFlags = [ ''-DBUILD_TEST=OFF'' 90 + ''-DBUILD_PYTHON=ON'' 91 + ''-DUSE_CUDA=${if useCuda then ''ON''else ''OFF''}'' 92 + ''-DUSE_OPENMP=${if useOpenmp then ''ON''else ''OFF''}'' 93 + ''-DUSE_OPENCV=${if useOpencv3 then ''ON''else ''OFF''}'' 94 + ''-DUSE_MPI=${if useMpi then ''ON''else ''OFF''}'' 95 + ''-DUSE_LEVELDB=${if useLeveldb then ''ON''else ''OFF''}'' 96 + ''-DUSE_LMDB=${if useLmdb then ''ON''else ''OFF''}'' 97 + ''-DUSE_ROCKSDB=${if useRocksdb then ''ON''else ''OFF''}'' 98 + ''-DUSE_ZMQ=${if useZeromq then ''ON''else ''OFF''}'' 99 + ''-DUSE_GLOO=OFF'' 100 + ''-DUSE_NNPACK=OFF'' 101 + ''-DUSE_NCCL=OFF'' 102 + ''-DUSE_REDIS=OFF'' 103 + ''-DUSE_FFMPEG=OFF'' 104 + ] 105 + ++ lib.optional useCuda [ 106 + ''-DCUDA_TOOLKIT_ROOT_DIR=${cudatoolkit}'' 107 + ''-DCUDA_FAST_MATH=ON'' 108 + ''-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/gcc'' 109 + ]; 110 + 111 + preConfigure = '' 112 + ${installExtraSrc cub} 113 + ${installExtraSrc pybind11} 114 + # XXX hack 115 + export NIX_CFLAGS_COMPILE="-I ${eigen3}/include/eigen3/ $NIX_CFLAGS_COMPILE" 116 + ''; 117 + 118 + postInstall = '' 119 + moveToOutput "bin" "$bin" 120 + mkdir -p $out/lib/${python.libPrefix} 121 + ln -s $out/ $out/${python.sitePackages} 122 + ''; 123 + 124 + doCheck = false; 125 + enableParallelBuilding = true; 126 + 127 + meta = { 128 + homepage = https://caffe2.ai/; 129 + description = "A new lightweight, modular, and scalable deep learning framework"; 130 + longDescription = '' 131 + Caffe2 aims to provide an easy and straightforward way for you to experiment 132 + with deep learning and leverage community contributions of new models and 133 + algorithms. You can bring your creations to scale using the power of GPUs in the 134 + cloud or to the masses on mobile with Caffe2's cross-platform libraries. 135 + ''; 136 + platforms = with stdenv.lib.platforms; linux ++ darwin; 137 + license = stdenv.lib.licenses.asl20; 138 + maintainers = with stdenv.lib.maintainers; [ yuriaisaka ]; 139 + }; 140 + }
+55
pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch
··· 1 + diff --git a/caffe2/perfkernels/cvtsh_ss_bugfix.h b/caffe2/perfkernels/cvtsh_ss_bugfix.h 2 + index bd06681..00172b7 100644 3 + --- a/caffe2/perfkernels/cvtsh_ss_bugfix.h 4 + +++ b/caffe2/perfkernels/cvtsh_ss_bugfix.h 5 + @@ -1,10 +1,36 @@ 6 + +/** 7 + + * Copyright (c) 2016-present, Facebook, Inc. 8 + + * 9 + + * Licensed under the Apache License, Version 2.0 (the "License"); 10 + + * you may not use this file except in compliance with the License. 11 + + * You may obtain a copy of the License at 12 + + * 13 + + * http://www.apache.org/licenses/LICENSE-2.0 14 + + * 15 + + * Unless required by applicable law or agreed to in writing, software 16 + + * distributed under the License is distributed on an "AS IS" BASIS, 17 + + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 + + * See the License for the specific language governing permissions and 19 + + * limitations under the License. 20 + + */ 21 + + 22 + #pragma once 23 + 24 + -#if defined(__APPLE__) && (__clang_major__ < 8) 25 + +// Apple clang was fixed in 8.1 26 + +#if defined(__apple_build_version__) && ((__clang_major__ < 8) || ((__clang_major__ == 8) && (__clang_minor__ < 1))) 27 + +#define __APPLE_NEED_FIX 1 28 + +#endif 29 + + 30 + +// Regular clang was fixed in 3.9 31 + +#if defined(__clang__) && (__clang_major__ < 4) && (__clang_minor__ < 9) 32 + +#define __CLANG_NEED_FIX 1 33 + +#endif 34 + + 35 + +#if __APPLE_NEED_FIX || __CLANG_NEED_FIX 36 + 37 + #include <emmintrin.h> 38 + 39 + -// This version of apple clang has a bug that _cvtsh_ss is not defined, see 40 + +// This version of clang has a bug that _cvtsh_ss is not defined, see 41 + // https://reviews.llvm.org/D16177 42 + static __inline float 43 + __attribute__((__always_inline__, __nodebug__, __target__("f16c"))) 44 + @@ -15,7 +41,10 @@ _cvtsh_ss(unsigned short a) 45 + return r[0]; 46 + } 47 + 48 + -#endif // defined(__APPLE__) && (__clang_major__ < 8) 49 + +#endif // __APPLE_NEED_FIX || __CLANG_NEED_FIX 50 + + 51 + +#undef __APPLE_NEED_FIX 52 + +#undef __CLANG_NEED_FIX 53 + 54 + #ifdef _MSC_VER 55 +
+7
pkgs/top-level/all-packages.nix
··· 19553 19553 cudnnSupport = cudaSupport; 19554 19554 }; 19555 19555 19556 + caffe2 = callPackage ../development/libraries/science/math/caffe2 { 19557 + eigen3 = eigen3_3; 19558 + inherit (python3Packages) python future six numpy pydot; 19559 + protobuf = protobuf3_1; 19560 + python-protobuf = python3Packages.protobuf3_1; 19561 + }; 19562 + 19556 19563 cntk = callPackage ../applications/science/math/cntk rec { 19557 19564 cudaSupport = pkgs.config.cudaSupport or false; 19558 19565 cudnnSupport = cudaSupport;