-
-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python3Packages.torch: enable USE_SYSTEM_LIBS
- Loading branch information
1 parent
f114fcd
commit 3513293
Showing
21 changed files
with
2,006 additions
and
8 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,88 @@ | ||
{ | ||
fetchFromGitHub, | ||
lib, | ||
stdenv, | ||
# nativeBuildInputs | ||
cmake, | ||
ninja, | ||
pkg-config, | ||
# buildInputs | ||
libpfm, | ||
# checkInputs | ||
filecheck, | ||
gtest, | ||
# Configuration options | ||
buildSharedLibs ? true, | ||
enableLTO ? true, | ||
enableLibPFM ? true, | ||
}: let | ||
inherit | ||
(lib) | ||
lists | ||
strings | ||
; | ||
setBool = bool: | ||
if bool | ||
then "ON" | ||
else "OFF"; | ||
setBuildSharedLibrary = bool: | ||
if bool | ||
then "shared" | ||
else "static"; | ||
in | ||
stdenv.mkDerivation (finalAttrs: { | ||
strictDeps = true; | ||
pname = "benchmark"; | ||
version = "1.8.0"; | ||
src = fetchFromGitHub { | ||
owner = "google"; | ||
repo = finalAttrs.pname; | ||
rev = "v${finalAttrs.version}"; | ||
hash = "sha256-pUW9YVaujs/y00/SiPqDgK4wvVsaM7QUp/65k0t7Yr0="; | ||
}; | ||
postPatch = strings.optionalString enableLibPFM '' | ||
substituteInPlace test/perf_counters_gtest.cc \ | ||
--replace \ | ||
'TEST(PerfCountersTest, NegativeTest) {' \ | ||
'TEST(PerfCountersTest, NegativeTest) { GTEST_SKIP() << "Skipping single test";' | ||
''; | ||
nativeBuildInputs = [ | ||
cmake | ||
ninja | ||
pkg-config | ||
]; | ||
buildInputs = lists.optionals enableLibPFM [libpfm]; | ||
checkInputs = [ | ||
filecheck | ||
gtest | ||
]; | ||
cmakeFlags = | ||
[ | ||
"-DBENCHMARK_DOWNLOAD_DEPENDENCIES=OFF" | ||
# TODO(@connorbaker): Assembly tests require filecheck, which isn't correctly detected, and | ||
# fails to compile. Also warns because we're using a version of GCC newer than 5.x. | ||
"-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF" | ||
"-DBENCHMARK_ENABLE_GTEST_TESTS=${setBool finalAttrs.doCheck}" | ||
"-DBENCHMARK_ENABLE_LIBPFM=${setBool enableLibPFM}" | ||
"-DBENCHMARK_ENABLE_LTO=${setBool enableLTO}" | ||
"-DBENCHMARK_ENABLE_TESTING=${setBool finalAttrs.doCheck}" | ||
"-DBENCHMARK_INSTALL_DOCS=ON" | ||
"-DBENCHMARK_USE_BUNDLED_GTEST=OFF" | ||
# TODO(@connorbaker): Test with clang | ||
# "-DBENCHMARK_USE_LIBCXX=OFF" | ||
# NOTE: When building static libraries, you may get linker errors due to private symbols! | ||
"-DBUILD_SHARED_LIBS=${setBuildSharedLibrary buildSharedLibs}" | ||
] | ||
++ lists.optionals finalAttrs.doCheck [ | ||
"-DLLVM_FILECHECK_EXE=${lib.getExe filecheck}" | ||
]; | ||
doCheck = true; | ||
enableParallelChecking = false; | ||
meta = with lib; { | ||
description = "A microbenchmark support library"; | ||
homepage = "https://github.com/google/benchmark"; | ||
license = licenses.asl20; | ||
maintainers = with maintainers; [connorbaker]; | ||
platforms = platforms.all; | ||
}; | ||
}) |
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,66 @@ | ||
{ | ||
fetchFromGitHub, | ||
fetchpatch, | ||
lib, | ||
stdenv, | ||
# nativeBuildInputs | ||
cmake, | ||
ninja, | ||
# buildInputs | ||
fxdiv, | ||
# checkInputs | ||
google-benchmark, | ||
gtest, | ||
# Configuration options | ||
buildSharedLibs ? true, | ||
}: let | ||
setBool = bool: | ||
if bool | ||
then "ON" | ||
else "OFF"; | ||
setBuildSharedLibrary = bool: | ||
if bool | ||
then "shared" | ||
else "static"; | ||
in | ||
stdenv.mkDerivation (finalAttrs: { | ||
strictDeps = true; | ||
pname = "pthreadpool"; | ||
version = finalAttrs.src.rev; | ||
src = fetchFromGitHub { | ||
owner = "Maratyszcza"; | ||
repo = finalAttrs.pname; | ||
rev = "edeb5d6b967bef092ff195ab40e216fa5ac11f61"; | ||
hash = "sha256-A5wPra4hkalizEHh/Rgga8itI4V1N7ZzascQ68ntXn4="; | ||
}; | ||
patches = [ | ||
(fetchpatch { | ||
url = "https://github.com/Maratyszcza/pthreadpool/pull/27.patch"; | ||
hash = "sha256-9OMEc/M/XyOedAeavpvErFA4g3/hJGYpKSQzMJXvkEA="; | ||
}) | ||
]; | ||
nativeBuildInputs = [ | ||
cmake | ||
ninja | ||
]; | ||
buildInputs = [fxdiv]; | ||
cmakeFlags = [ | ||
"-DBUILD_SHARED_LIBS:STRING=${setBuildSharedLibrary buildSharedLibs}" | ||
"-DPTHREADPOOL_ALLOW_DEPRECATED_API:BOOL=ON" | ||
"-DPTHREADPOOL_BUILD_BENCHMARKS:BOOL=${setBool finalAttrs.doCheck}" | ||
"-DPTHREADPOOL_BUILD_TESTS:BOOL=${setBool finalAttrs.doCheck}" | ||
"-DUSE_SYSTEM_LIBS:BOOL=ON" | ||
]; | ||
doCheck = true; | ||
checkInputs = [ | ||
google-benchmark | ||
gtest | ||
]; | ||
meta = with lib; { | ||
description = "Portable (POSIX/Windows/Emscripten) thread pool for C/C++"; | ||
homepage = "https://github.com/Maratyszcza/pthreadpool"; | ||
license = licenses.bsd2; | ||
maintainers = with maintainers; [connorbaker]; | ||
platforms = platforms.all; | ||
}; | ||
}) |
82 changes: 82 additions & 0 deletions
82
pkgs/development/libraries/science/math/fbgemm/default.nix
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,82 @@ | ||
{ | ||
fetchFromGitHub, | ||
fetchpatch, | ||
lib, | ||
stdenv, | ||
# nativeBuildInputs | ||
cmake, | ||
ninja, | ||
python3, | ||
# buildInputs | ||
asmjit, | ||
blas, | ||
cpuinfo, | ||
# checkInputs | ||
google-benchmark, | ||
gtest, | ||
# Configuration options | ||
buildSharedLibs ? true, | ||
}: let | ||
setBool = bool: | ||
if bool | ||
then "ON" | ||
else "OFF"; | ||
setBuildSharedLibrary = bool: | ||
if bool | ||
then "shared" | ||
else "static"; | ||
in | ||
stdenv.mkDerivation (finalAttrs: { | ||
strictDeps = true; | ||
pname = "FBGEMM"; | ||
version = finalAttrs.src.rev; | ||
src = fetchFromGitHub { | ||
owner = "pytorch"; | ||
repo = finalAttrs.pname; | ||
rev = "a7e7d3e3b0655dc4e9324413bc01e5bb8622dde1"; | ||
fetchSubmodules = true; | ||
hash = "sha256-waVN/hxJhjmDOkR8pIEOZAKftXFiq28FTt0Jvp7PtUc="; | ||
}; | ||
patches = [ | ||
(fetchpatch { | ||
url = "https://github.com/pytorch/FBGEMM/pull/1859.patch"; | ||
hash = "sha256-IJvSFgpFO1tMAQnrDyYQ3TJ35UrVGN7/nd0wTO0Wo+U="; | ||
}) | ||
]; | ||
nativeBuildInputs = [ | ||
cmake | ||
ninja | ||
python3 | ||
]; | ||
buildInputs = [ | ||
asmjit | ||
blas | ||
cpuinfo | ||
]; | ||
# NOTE: GPU-enabled FBGEMM has a dependency on libtorch. Unfortunately, | ||
# libtorch itself depends on FBGEMM. I (@connorbaker) don't know how to cleanly | ||
# resolve this circular dependency, so I'm just going to disable GPU support. | ||
# NOTE: There's no real USE_CUDA flag. FBGEMM uses USE_ROCM to determine if | ||
# it should use CUDA or ROCm. | ||
cmakeFlags = [ | ||
"-DUSE_SYSTEM_LIBS:BOOL=ON" | ||
"-DFBGEMM_BUILD_BENCHMARKS:BOOL=${setBool finalAttrs.doCheck}" | ||
"-DFBGEMM_BUILD_FBGEMM_GPU:BOOL=OFF" | ||
"-DFBGEMM_BUILD_TESTS:BOOL=${setBool finalAttrs.doCheck}" | ||
"-DFBGEMM_LIBRARY_TYPE:STRING=${setBuildSharedLibrary buildSharedLibs}" | ||
]; | ||
# To avoid installing the benchmarks and test libraries, set doCheck to false. | ||
doCheck = false; | ||
checkInputs = [ | ||
google-benchmark | ||
gtest | ||
]; | ||
passthru = {inherit blas;}; | ||
meta = with lib; { | ||
description = "Low-precision, high-performance matrix-matrix multiplications and convolution library for server-side inference"; | ||
homepage = "https://github.com/pytorch/FBGEMM"; | ||
license = licenses.bsd2; | ||
maintainers = with maintainers; [connorbaker]; | ||
platforms = platforms.all; | ||
}; | ||
}) |
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,58 @@ | ||
{ | ||
fetchFromGitHub, | ||
fetchpatch, | ||
lib, | ||
stdenv, | ||
# nativeBuildInputs | ||
cmake, | ||
ninja, | ||
# buildInputs | ||
psimd, | ||
# checkInputs | ||
google-benchmark, | ||
gtest, | ||
}: let | ||
setBool = bool: | ||
if bool | ||
then "ON" | ||
else "OFF"; | ||
in | ||
stdenv.mkDerivation (finalAttrs: { | ||
strictDeps = true; | ||
pname = "FP16"; | ||
version = finalAttrs.src.rev; | ||
src = fetchFromGitHub { | ||
owner = "Maratyszcza"; | ||
repo = finalAttrs.pname; | ||
rev = "0a92994d729ff76a58f692d3028ca1b64b145d91"; | ||
hash = "sha256-m2d9bqZoGWzuUPGkd29MsrdscnJRtuIkLIMp3fMmtRY="; | ||
}; | ||
patches = [ | ||
(fetchpatch { | ||
url = "https://github.com/Maratyszcza/FP16/pull/23.patch"; | ||
hash = "sha256-NojFGBJ8T+KDglOE6eCEjGVPGv/vrupol1hB5KVleb0="; | ||
}) | ||
]; | ||
nativeBuildInputs = [ | ||
cmake | ||
ninja | ||
]; | ||
buildInputs = [psimd]; | ||
cmakeFlags = [ | ||
"-DFP16_BUILD_BENCHMARKS:BOOL=${setBool finalAttrs.doCheck}" | ||
"-DFP16_BUILD_TESTS:BOOL=${setBool finalAttrs.doCheck}" | ||
"-DUSE_SYSTEM_LIBS:BOOL=ON" | ||
]; | ||
doCheck = true; | ||
checkInputs = [ | ||
google-benchmark | ||
gtest | ||
]; | ||
meta = with lib; { | ||
description = "Header-only library for conversion to/from half-precision floating point formats"; | ||
homepage = "https://github.com/Maratyszcza/FP16"; | ||
license = licenses.mit; | ||
maintainers = with maintainers; [connorbaker]; | ||
platforms = platforms.all; | ||
}; | ||
}) |
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,58 @@ | ||
{ | ||
fetchFromGitHub, | ||
fetchpatch, | ||
lib, | ||
stdenv, | ||
# nativeBuildInputs | ||
cmake, | ||
ninja, | ||
# checkInputs | ||
google-benchmark, | ||
gtest, | ||
# Configuration options | ||
useInlineAssembly ? false, | ||
}: let | ||
setBool = bool: | ||
if bool | ||
then "ON" | ||
else "OFF"; | ||
in | ||
stdenv.mkDerivation (finalAttrs: { | ||
strictDeps = true; | ||
pname = "FXdiv"; | ||
version = finalAttrs.src.rev; | ||
src = fetchFromGitHub { | ||
owner = "Maratyszcza"; | ||
repo = finalAttrs.pname; | ||
rev = "63058eff77e11aa15bf531df5dd34395ec3017c8"; | ||
hash = "sha256-LjX5kivfHbqCIA5pF9qUvswG1gjOFo3CMpX0VR+Cn38="; | ||
}; | ||
patches = [ | ||
(fetchpatch { | ||
url = "https://github.com/Maratyszcza/FXdiv/pull/5.patch"; | ||
hash = "sha256-VFY4vgb2gKv3NFqHfjqKo1SVSZKriilAqzCJLvJB+GI="; | ||
}) | ||
]; | ||
nativeBuildInputs = [ | ||
cmake | ||
ninja | ||
]; | ||
cmakeFlags = [ | ||
"-DUSE_SYSTEM_LIBS:BOOL=ON" | ||
"-DFXDIV_BUILD_BENCHMARKS:BOOL=${setBool finalAttrs.doCheck}" | ||
"-DFXDIV_BUILD_TESTS:BOOL=${setBool finalAttrs.doCheck}" | ||
"-DFXDIV_USE_INLINE_ASSEMBLY:BOOL=${setBool useInlineAssembly}" | ||
]; | ||
doCheck = true; | ||
checkInputs = [ | ||
google-benchmark | ||
gtest | ||
]; | ||
meta = with lib; { | ||
description = "Header-only library for division via fixed-point multiplication by inverse"; | ||
homepage = "https://github.com/Maratyszcza/FXdiv"; | ||
license = licenses.mit; | ||
maintainers = with maintainers; [connorbaker]; | ||
platforms = platforms.all; | ||
}; | ||
}) |
Oops, something went wrong.