diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/science/math')
23 files changed, 553 insertions, 73 deletions
diff --git a/nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix new file mode 100644 index 00000000000..9bddba0261f --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix @@ -0,0 +1,67 @@ +{ stdenv +, fetchFromGitHub +, perl +, python3 + +# Enable BLAS interface with 64-bit integer width. +, blas64 ? false + +# Target architecture, use "zen" or "zen2", optimization for Zen and +# other families is pretty much mutually exclusive in the AMD fork of +# BLIS. +, withArchitecture ? "zen" + +# Enable OpenMP-based threading. +, withOpenMP ? true +}: + +let + threadingSuffix = if withOpenMP then "-mt" else ""; + blasIntSize = if blas64 then "64" else "32"; +in stdenv.mkDerivation rec { + pname = "amd-blis"; + version = "2.2"; + + src = fetchFromGitHub { + owner = "amd"; + repo = "blis"; + rev = version; + sha256 = "1b2f5bwi0gkw2ih2rb7wfzn3m9hgg7k270kg43rmzpr2acpy86xa"; + }; + + inherit blas64; + + nativeBuildInputs = [ + perl + python3 + ]; + + doCheck = true; + + enableParallelBuilding = true; + + configureFlags = [ + "--enable-cblas" + "--blas-int-size=${blasIntSize}" + ] ++ stdenv.lib.optionals withOpenMP [ "--enable-threading=openmp" ] + ++ [ withArchitecture ]; + + postPatch = '' + patchShebangs configure build/flatten-headers.py + ''; + + postInstall = '' + ln -s $out/lib/libblis${threadingSuffix}.so.2 $out/lib/libblas.so.3 + ln -s $out/lib/libblis${threadingSuffix}.so.2 $out/lib/libcblas.so.3 + ln -s $out/lib/libblas.so.3 $out/lib/libblas.so + ln -s $out/lib/libcblas.so.3 $out/lib/libcblas.so + ''; + + meta = with stdenv.lib; { + description = "BLAS-compatible library optimized for AMD CPUs"; + homepage = "https://developer.amd.com/amd-aocl/blas-library/"; + license = licenses.bsd3; + maintainers = [ maintainers.danieldk ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/add-lapacke.diff b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/add-lapacke.diff new file mode 100644 index 00000000000..3e3ef1e60ff --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/add-lapacke.diff @@ -0,0 +1,34 @@ +diff --git a/Makefile b/Makefile +index 5549ce30..ac2ee51e 100644 +--- a/Makefile ++++ b/Makefile +@@ -583,14 +583,14 @@ endif + + # --- Shared library linker rules --- + +-$(LIBFLAME_SO_PATH): $(MK_ALL_FLAMEC_OBJS) ++$(LIBFLAME_SO_PATH): $(MK_ALL_FLAMEC_OBJS) $(LAPACKE_A_PATH) + ifeq ($(ENABLE_VERBOSE),yes) + ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes) + $(CAT) $(AR_OBJ_LIST_FILE) | xargs -n$(AR_CHUNK_SIZE) $(AR) $(ARFLAGS) $(LIBFLAME_A) + ifeq ($(OS_NAME),Darwin) +- $(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A) $(LDFLAGS) ++ $(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A),$(LAPACKE_A_PATH) $(LDFLAGS) + else +- $(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),--no-whole-archive $(LDFLAGS) ++ $(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),$(LAPACKE_A_PATH)--no-whole-archive $(LDFLAGS) + endif + else + # NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in +@@ -602,9 +602,9 @@ else + ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes) + @$(CAT) $(AR_OBJ_LIST_FILE) | xargs -n$(AR_CHUNK_SIZE) $(AR) $(ARFLAGS) $(LIBFLAME_A) + ifeq ($(OS_NAME),Darwin) +- @$(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A) $(LDFLAGS) ++ @$(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A),$(LAPACKE_A_PATH) $(LDFLAGS) + else +- @$(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),--no-whole-archive $(LDFLAGS) ++ @$(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),$(LAPACKE_A_PATH),--no-whole-archive $(LDFLAGS) + endif + else + # NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in diff --git a/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix new file mode 100644 index 00000000000..1e331bca695 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix @@ -0,0 +1,72 @@ +{ lib +, stdenv +, fetchFromGitHub +, gfortran +, python3 +, amd-blis + +, withOpenMP ? true +}: + +stdenv.mkDerivation rec { + pname = "amd-libflame"; + version = "2.2"; + + src = fetchFromGitHub { + owner = "amd"; + repo = "libflame"; + rev = version; + sha256 = "1s8zvq6p843jb52lrbxra7vv0wzmifs4j36z9bp7wf3xr20a0zi5"; + }; + + patches = [ + # The LAPACKE interface is compiled as a separate static library, + # we want the main dynamic library to provide LAPACKE symbols. + # This patch adds lapacke.a to the shared library as well. + ./add-lapacke.diff + ]; + + nativeBuildInputs = [ gfortran python3 ]; + + buildInputs = [ amd-blis ]; + + configureFlags = [ + # Build a dynamic library with a LAPACK interface. + "--disable-static-build" + "--enable-dynamic-build" + "--enable-lapack2flame" + + # Use C BLAS interface. + "--enable-cblas-interfaces" + + # Avoid overloading maximum number of arguments. + "--enable-max-arg-list-hack" + + # libflame by default leaves BLAS symbols unresolved and leaves it + # up to the application to explicitly link to a BLAS. This is + # problematic for us, since then the BLAS library becomes an + # implicit dependency. Moreover, since the point of the AMD forks + # is to optimized for recent AMD CPUs, link against AMD BLIS. + "LDFLAGS=-lcblas" + ] + ++ lib.optionals withOpenMP [ "--enable-multithreading=openmp" ]; + + enableParallelBuilding = true; + + postPatch = '' + patchShebangs build + ''; + + postInstall = '' + ln -s $out/lib/libflame.so.${version} $out/lib/liblapack.so.3 + ln -s $out/lib/libflame.so.${version} $out/lib/liblapacke.so.3 + ''; + + meta = with stdenv.lib; { + description = "LAPACK-compatible linear algebra library optimized for AMD CPUs"; + homepage = "https://developer.amd.com/amd-aocl/blas-library/"; + license = licenses.bsd3; + maintainers = with maintainers; [ danieldk ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix index 0829557d0f3..02d51f0c419 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix @@ -31,7 +31,7 @@ stdenv.mkDerivation { ]; preCheck = if stdenv.isDarwin then '' - export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH''${DYLD_LIBRARY_PATH:+:}`pwd`/lib + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH''${DYLD_LIBRARY_PATH:+:}`pwd`/lib:${blas}/lib:${lapack}/lib '' else '' export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}`pwd`/lib '' + '' diff --git a/nixpkgs/pkgs/development/libraries/science/math/blis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/blis/default.nix new file mode 100644 index 00000000000..42ba4f25204 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/blis/default.nix @@ -0,0 +1,64 @@ +{ stdenv +, fetchFromGitHub +, perl +, python3 + +# Enable BLAS interface with 64-bit integer width. +, blas64 ? false + +# Target architecture. x86_64 builds Intel and AMD kernels. +, withArchitecture ? "x86_64" + +# Enable OpenMP-based threading. +, withOpenMP ? true +}: + +let + blasIntSize = if blas64 then "64" else "32"; +in stdenv.mkDerivation rec { + pname = "blis"; + version = "0.7.0"; + + src = fetchFromGitHub { + owner = "flame"; + repo = "blis"; + rev = version; + sha256 = "13g9kg7x8j9icg4frdq3wpl2cmp0jnh93mw48daa7ym399w17423"; + }; + + inherit blas64; + + nativeBuildInputs = [ + perl + python3 + ]; + + doCheck = true; + + enableParallelBuilding = true; + + configureFlags = [ + "--enable-cblas" + "--blas-int-size=${blasIntSize}" + ] ++ stdenv.lib.optionals withOpenMP [ "--enable-threading=openmp" ] + ++ [ withArchitecture ]; + + postPatch = '' + patchShebangs configure build/flatten-headers.py + ''; + + postInstall = '' + ln -s $out/lib/libblis.so.3 $out/lib/libblas.so.3 + ln -s $out/lib/libblis.so.3 $out/lib/libcblas.so.3 + ln -s $out/lib/libblas.so.3 $out/lib/libblas.so + ln -s $out/lib/libcblas.so.3 $out/lib/libcblas.so + ''; + + meta = with stdenv.lib; { + description = "BLAS-compatible linear algebra library"; + homepage = "https://github.com/flame/blis"; + license = licenses.bsd3; + maintainers = [ maintainers.danieldk ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix index 765d634a91f..9495366eaaa 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix @@ -1,4 +1,4 @@ -{ callPackage, cudatoolkit_7, cudatoolkit_7_5, cudatoolkit_8, cudatoolkit_9_0, cudatoolkit_9_1, cudatoolkit_9_2, cudatoolkit_10_0, cudatoolkit_10_1, cudatoolkit_10_2 }: +{ callPackage, cudatoolkit_7, cudatoolkit_7_5, cudatoolkit_8, cudatoolkit_9_0, cudatoolkit_9_1, cudatoolkit_9_2, cudatoolkit_10_0, cudatoolkit_10_1, cudatoolkit_10_2, cudatoolkit_11_0 }: let generic = args: callPackage (import ./generic.nix (removeAttrs args ["cudatoolkit"])) { @@ -80,4 +80,13 @@ in rec { }; cudnn_cudatoolkit_10 = cudnn_cudatoolkit_10_1; + + cudnn_cudatoolkit_11_0 = generic rec { + version = "8.0.2"; + cudatoolkit = cudatoolkit_11_0; + srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v8.0.2.39.tgz"; + sha256 = "0ib3v3bgcdxarqapkxngw1nwl0c2a7zz392ns7w9ipcficl4cbv7"; + }; + + cudnn_cudatoolkit_11 = cudnn_cudatoolkit_11_0; } diff --git a/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix b/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix index 5a17e807bd4..e727218c055 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix @@ -37,7 +37,15 @@ stdenv.mkDerivation { # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found. # See the explanation in addOpenGLRunpath. postFixup = '' - addOpenGLRunpath $out/lib/lib*.so + for lib in $out/lib/lib*.so; do + # patchelf fails on libcudnn_cnn_infer due to it being too big. + # Most programs will still get the RPATH since they link to + # other things. + # (https://github.com/NixOS/patchelf/issues/222) + if [ "$(basename $lib)" != libcudnn_cnn_infer.so ]; then + addOpenGLRunpath $lib + fi + done ''; propagatedBuildInputs = [ diff --git a/nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix b/nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix new file mode 100644 index 00000000000..d7fae9ae479 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix @@ -0,0 +1,55 @@ +{ stdenv +, fetchurl +, cmake +, gtest +, blas +, fftw +, liblapack +, gfortran +}: + +stdenv.mkDerivation rec { + pname = "it++"; + version = "4.3.1"; + + src = fetchurl { + url = "mirror://sourceforge/itpp/itpp-${version}.tar.bz2"; + sha256 = "0xxqag9wi0lg78xgw7b40rp6wxqp5grqlbs9z0ifvdfzqlhpcwah"; + }; + + nativeBuildInputs = [ cmake gfortran ]; + buildInputs = [ + fftw + liblapack + + # NOTE: OpenBLAS doesn't work here because IT++ doesn't pass aligned + # buffers, which causes segfaults in the optimized kernels :-( + blas + ]; + + cmakeFlags = [ + "-DBLAS_FOUND:BOOL=TRUE" + "-DBLAS_LIBRARIES:STRING=${blas}/lib/libblas.so" + "-DLAPACK_FOUND:BOOL=TRUE" + "-DLAPACK_LIBRARIES:STRING=${liblapack}/lib/liblapack.so" + "-DGTEST_DIR:PATH=${gtest.src}/googletest" + ]; + + enableParallelBuilding = true; + + doCheck = true; + + checkPhase = '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/itpp + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH''${DYLD_LIBRARY_PATH:+:}$PWD/itpp + ./gtests/itpp_gtests + ''; + + meta = with stdenv.lib; { + description = "IT++ is a C++ library of mathematical, signal processing and communication classes and functions."; + homepage = http://itpp.sourceforge.net/; + license = licenses.gpl3; + platforms = platforms.unix; + maintainers = with maintainers; [ andrew-d ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix b/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix new file mode 100644 index 00000000000..3ae46270586 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix @@ -0,0 +1,111 @@ +{ callPackage +, stdenv +, fetchzip +, lib + +, addOpenGLRunpath +, patchelf +, fixDarwinDylibNames + +, cudaSupport +, nvidia_x11 +}: + +let + version = "1.6.0"; + device = if cudaSupport then "cuda" else "cpu"; + srcs = import ./binary-hashes.nix; + unavailable = throw "libtorch is not available for this platform"; +in stdenv.mkDerivation { + inherit version; + pname = "libtorch"; + + src = fetchzip srcs."${stdenv.targetPlatform.system}-${device}" or unavailable; + + nativeBuildInputs = + if stdenv.isDarwin then [ fixDarwinDylibNames ] + else [ addOpenGLRunpath patchelf ] + ++ stdenv.lib.optionals cudaSupport [ addOpenGLRunpath ]; + + buildInputs = [ + stdenv.cc.cc + ] ++ lib.optionals cudaSupport [ nvidia_x11 ]; + + dontBuild = true; + dontConfigure = true; + dontStrip = true; + + installPhase = '' + # Copy headers and CMake files. + install -Dm755 -t $dev/lib lib/*.a + cp -r include $dev + cp -r share $dev + + install -Dm755 -t $out/lib lib/*${stdenv.hostPlatform.extensions.sharedLibrary}* + + # We do not care about Java support... + rm -f $out/lib/lib*jni* 2> /dev/null || true + ''; + + postFixup = let + libPaths = [ stdenv.cc.cc.lib ] + ++ stdenv.lib.optionals cudaSupport [ nvidia_x11 ]; + rpath = stdenv.lib.makeLibraryPath libPaths; + in stdenv.lib.optionalString stdenv.isLinux '' + find $out/lib -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do + echo "setting rpath for $lib..." + patchelf --set-rpath "${rpath}:$out/lib" "$lib" + ${lib.optionalString cudaSupport '' + addOpenGLRunpath "$lib" + ''} + done + '' + stdenv.lib.optionalString stdenv.isDarwin '' + install_name_tool -change @rpath/libshm.dylib $out/lib/libshm.dylib $out/lib/libtorch_python.dylib + install_name_tool -change @rpath/libc10.dylib $out/lib/libc10.dylib $out/lib/libtorch_python.dylib + install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libtorch_python.dylib + install_name_tool -change @rpath/libtorch.dylib $out/lib/libtorch.dylib $out/lib/libtorch_python.dylib + install_name_tool -change @rpath/libtorch_cpu.dylib $out/lib/libtorch_cpu.dylib $out/lib/libtorch_python.dylib + + install_name_tool -change @rpath/libc10.dylib $out/lib/libc10.dylib $out/lib/libtorch.dylib + install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libtorch.dylib + install_name_tool -change @rpath/libtorch_cpu.dylib $out/lib/libtorch_cpu.dylib $out/lib/libtorch.dylib + + install_name_tool -change @rpath/libc10.dylib $out/lib/libc10.dylib $out/lib/libtorch_cpu.dylib + install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libtorch_cpu.dylib + install_name_tool -change @rpath/libtensorpipe.dylib $out/lib/libtensorpipe.dylib $out/lib/libtorch_cpu.dylib + + install_name_tool -change @rpath/libc10.dylib $out/lib/libc10.dylib $out/lib/libcaffe2_observers.dylib + install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libcaffe2_observers.dylib + install_name_tool -change @rpath/libtorch.dylib $out/lib/libtorch.dylib $out/lib/libcaffe2_observers.dylib + install_name_tool -change @rpath/libtorch_cpu.dylib $out/lib/libtorch_cpu.dylib $out/lib/libcaffe2_observers.dylib + + install_name_tool -change @rpath/libc10.dylib $out/lib/libc10.dylib $out/lib/libcaffe2_module_test_dynamic.dylib + install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libcaffe2_module_test_dynamic.dylib + install_name_tool -change @rpath/libtorch.dylib $out/lib/libtorch.dylib $out/lib/libcaffe2_module_test_dynamic.dylib + install_name_tool -change @rpath/libtorch_cpu.dylib $out/lib/libtorch_cpu.dylib $out/lib/libcaffe2_module_test_dynamic.dylib + + install_name_tool -change @rpath/libc10.dylib $out/lib/libc10.dylib $out/lib/libcaffe2_detectron_ops.dylib + install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libcaffe2_detectron_ops.dylib + install_name_tool -change @rpath/libtorch.dylib $out/lib/libtorch.dylib $out/lib/libcaffe2_detectron_ops.dylib + install_name_tool -change @rpath/libtorch_cpu.dylib $out/lib/libtorch_cpu.dylib $out/lib/libcaffe2_detectron_ops.dylib + + install_name_tool -change @rpath/libc10.dylib $out/lib/libc10.dylib $out/lib/libshm.dylib + install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libshm.dylib + install_name_tool -change @rpath/libtorch.dylib $out/lib/libtorch.dylib $out/lib/libshm.dylib + install_name_tool -change @rpath/libtorch_cpu.dylib $out/lib/libtorch_cpu.dylib $out/lib/libshm.dylib + + install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libtorch_global_deps.dylib + install_name_tool -change @rpath/libtorch_cpu.dylib $out/lib/libtorch_cpu.dylib $out/lib/libtorch_global_deps.dylib + ''; + + outputs = [ "out" "dev" ]; + + passthru.tests = callPackage ./test { }; + + meta = with stdenv.lib; { + description = "C++ API of the PyTorch machine learning framework"; + homepage = "https://pytorch.org/"; + license = licenses.unfree; # Includes CUDA and Intel MKL. + platforms = with platforms; linux ++ darwin; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix b/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix new file mode 100644 index 00000000000..92a2e05e0ba --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix @@ -0,0 +1,14 @@ +{ + x86_64-darwin-cpu = { + url = "https://download.pytorch.org/libtorch/cpu/libtorch-macos-1.6.0.zip"; + sha256 = "0d4n7la31qzl4s9pwvm07la7q6lhcwiww0yjpfz3kw6nvx84p22r"; + }; + x86_64-linux-cpu = { + url = "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.6.0%2Bcpu.zip"; + sha256 = "1975b4zvyihzh89vnwspw0vf9qr05sxj8939vcrlmv3gzvdspcxz"; + }; + x86_64-linux-cuda = { + url = "https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-1.6.0.zip"; + sha256 = "127qnfyi1faqbm40sbnsyqxjhrqj82bzwqyz7c1hs2bm0zgrrpya"; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt new file mode 100644 index 00000000000..b302449ef77 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt @@ -0,0 +1,4 @@ +find_package(Torch REQUIRED) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") +add_executable(test test.cpp) +target_link_libraries(test "${TORCH_LIBRARIES}") diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix new file mode 100644 index 00000000000..d661ec28db9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix @@ -0,0 +1,26 @@ +{ stdenv, cmake, libtorch-bin, symlinkJoin }: + +stdenv.mkDerivation { + pname = "libtorch-test"; + version = libtorch-bin.version; + + src = ./.; + + postPatch = '' + cat CMakeLists.txt + ''; + + makeFlags = [ "VERBOSE=1" ]; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ libtorch-bin ]; + + installPhase = '' + touch $out + ''; + + checkPhase = '' + ./test + ''; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp new file mode 100644 index 00000000000..5537724ce5f --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp @@ -0,0 +1,7 @@ +#include <torch/torch.h> +#include <iostream> + +int main() { + torch::Tensor tensor = torch::eye(3); + std::cout << tensor << std::endl; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix index dbe162c60b3..2079ace021b 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix @@ -1,19 +1,21 @@ -{ stdenv, fetchurl, cmake, gfortran, cudatoolkit, libpthreadstubs, lapack, blas }: +{ stdenv, fetchurl, cmake, gfortran, ninja, cudatoolkit, libpthreadstubs, lapack, blas }: with stdenv.lib; -let version = "2.5.0"; +let version = "2.5.3"; in stdenv.mkDerivation { pname = "magma"; inherit version; src = fetchurl { url = "https://icl.cs.utk.edu/projectsfiles/magma/downloads/magma-${version}.tar.gz"; - sha256 = "0czspk93cv1fy37zyrrc9k306q4yzfxkhy1y4lj937dx8rz5rm2g"; + sha256 = "1xjy3irdx0w1zyhvn4x47zni5fwsh6z97xd4yqldz8zrm5lx40n6"; name = "magma-${version}.tar.gz"; }; - buildInputs = [ gfortran cudatoolkit libpthreadstubs cmake lapack blas ]; + nativeBuildInputs = [ gfortran cmake ninja ]; + + buildInputs = [ cudatoolkit libpthreadstubs lapack blas ]; doCheck = false; @@ -32,7 +34,7 @@ in stdenv.mkDerivation { mkdir -p $out/lib/pkgconfig cp -a ../include/*.h $out/include #cp -a sparse-iter/include/*.h $out/include - cp -a lib/*.a $out/lib + cp -a lib/*.so $out/lib cat ../lib/pkgconfig/magma.pc.in | \ sed -e s:@INSTALL_PREFIX@:"$out": | \ sed -e s:@CFLAGS@:"-I$out/include": | \ @@ -48,4 +50,6 @@ in stdenv.mkDerivation { platforms = platforms.unix; maintainers = with maintainers; [ tbenst ]; }; + + passthru.cudatoolkit = cudatoolkit; } diff --git a/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix b/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix index 016864abed8..2be3baed449 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix @@ -1,9 +1,9 @@ { stdenvNoCC , fetchurl -, pkgconfig , rpmextract , undmg , darwin +, validatePkgConfig , enableStatic ? false }: @@ -19,14 +19,18 @@ let # Darwin is pinned to 2019.3 because the DMG does not unpack; see here for details: # https://github.com/matthewbauer/undmg/issues/4 year = if stdenvNoCC.isDarwin then "2019" else "2020"; - spot = if stdenvNoCC.isDarwin then "3" else "1"; - rel = if stdenvNoCC.isDarwin then "199" else "217"; + spot = if stdenvNoCC.isDarwin then "3" else "3"; + rel = if stdenvNoCC.isDarwin then "199" else "279"; + + # Replace `openmpSpot` by `spot` after 2020.3. Release 2020.03 + # adresses performance regressions and does not update OpenMP. + openmpSpot = if stdenvNoCC.isDarwin then spot else "2"; rpm-ver = "${year}.${spot}-${rel}-${year}.${spot}-${rel}"; # Intel openmp uses its own versioning, but shares the spot release patch. openmp = if stdenvNoCC.isDarwin then "19.0" else "19.1"; - openmp-ver = "${openmp}.${spot}-${rel}-${openmp}.${spot}-${rel}"; + openmp-ver = "${openmp}.${openmpSpot}-${rel}-${openmp}.${openmpSpot}-${rel}"; shlibExt = stdenvNoCC.hostPlatform.extensions.sharedLibrary; @@ -42,19 +46,15 @@ in stdenvNoCC.mkDerivation { }) else (fetchurl { - url = "https://registrationcenter-download.intel.com/akdlm/irc_nas/tec/16533/l_mkl_${version}.tgz"; - sha256 = "0v86hrqg15mbc78m9qk8dbkaaq3mlwashgbf9n79kxpl1gilnah8"; + url = "https://registrationcenter-download.intel.com/akdlm/irc_nas/tec/16903/l_mkl_${version}.tgz"; + sha256 = "013shn3c823bjfssq4jyl3na5lbzj99s09ds608ljqllri7473ib"; }); - nativeBuildInputs = if stdenvNoCC.isDarwin + nativeBuildInputs = [ validatePkgConfig ] ++ (if stdenvNoCC.isDarwin then [ undmg darwin.cctools ] else - [ rpmextract ]; - - installCheckInputs = [ pkgconfig ]; - - doInstallCheck = true; + [ rpmextract ]); buildPhase = if stdenvNoCC.isDarwin then '' for f in Contents/Resources/pkg/*.tgz; do @@ -152,11 +152,6 @@ in stdenvNoCC.mkDerivation { install_name_tool -change @rpath/libtbbmalloc.dylib $out/lib/libtbbmalloc.dylib $out/lib/libtbbmalloc_proxy.dylib ''; - # Validate pkgconfig files, since they break often on updates. - installCheckPhase = '' - pkg-config --validate $out/lib/pkgconfig/*.pc - ''; - # Per license agreement, do not modify the binary dontStrip = true; dontPatchELF = true; diff --git a/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix b/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix index 5f38d45fc4d..eb194c0e9e4 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix @@ -2,13 +2,13 @@ stdenv.mkDerivation rec { name = "nccl-${version}-cuda-${cudatoolkit.majorVersion}"; - version = "2.4.8-1"; + version = "2.7.8-1"; src = fetchFromGitHub { owner = "NVIDIA"; repo = "nccl"; rev = "v${version}"; - sha256 = "05m66y64rgsdyybvjybhy6clikwv438b1m484ikai78fb2b7mvyq"; + sha256 = "0xxiwaw239dc9g015fka3k1nvm5zyl00dzgxnwzkang61dys9wln"; }; outputs = [ "out" "dev" ]; diff --git a/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix index 318922d7f25..89d88bdf564 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix @@ -99,12 +99,12 @@ let in stdenv.mkDerivation rec { pname = "openblas"; - version = "0.3.9"; + version = "0.3.10"; src = fetchFromGitHub { owner = "xianyi"; repo = "OpenBLAS"; rev = "v${version}"; - sha256 = "0nq51j45shb32n6086xff3x374kx5qhr2cwjzvppx4s2z0ahflal"; + sha256 = "174id98ga82bhz2v7sy9yj6pqy0h0088p3mkdikip69p9rh3d17b"; }; inherit blas64; diff --git a/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix index 7517ca9c6cb..560f39e4e99 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix @@ -2,10 +2,10 @@ stdenv.mkDerivation rec { pname = "openlibm"; - version = "0.7.0"; + version = "0.7.1"; src = fetchurl { url = "https://github.com/JuliaLang/openlibm/archive/v${version}.tar.gz"; - sha256 = "18q6mrq4agvlpvhix2k13qcyvqqzh30vj7b329dva64035rzg68n"; + sha256 = "0yg8sfibr38hpb4s5ri7i0ivp96c7khdwhlxngjiymvl3jvm5cnl"; }; makeFlags = [ "prefix=$(out)" ]; diff --git a/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix index a69ae5af15f..926f7ba4789 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix @@ -1,20 +1,16 @@ { stdenv, fetchFromGitHub, cmake, abseil-cpp, gflags, which -, lsb-release, glog, protobuf3_11, cbc, zlib +, lsb-release, glog, protobuf, cbc, zlib , ensureNewerSourcesForZipFilesHook, python, swig }: -let - protobuf = protobuf3_11; - pythonProtobuf = python.pkgs.protobuf.override { inherit protobuf; }; - -in stdenv.mkDerivation rec { +stdenv.mkDerivation rec { pname = "or-tools"; - version = "7.6"; + version = "7.7"; src = fetchFromGitHub { owner = "google"; repo = "or-tools"; rev = "v${version}"; - sha256 = "0605q3y7vh7x7m9azrbkx44blq12zrab6v28b9wmpcn1lmykbw1b"; + sha256 = "06ig9a1afmzgzcg817y0rdq49ahll0q9y7bhhg9d89x6zy959ypv"; }; # The original build system uses cmake which does things like pull @@ -33,7 +29,7 @@ in stdenv.mkDerivation rec { makeFlags = [ "prefix=${placeholder "out"}" - "PROTOBUF_PYTHON_DESC=${pythonProtobuf}/${python.sitePackages}/google/protobuf/descriptor_pb2.py" + "PROTOBUF_PYTHON_DESC=${python.pkgs.protobuf}/${python.sitePackages}/google/protobuf/descriptor_pb2.py" ]; buildFlags = [ "cc" "pypi_archive" ]; @@ -54,7 +50,7 @@ in stdenv.mkDerivation rec { ]; propagatedBuildInputs = [ abseil-cpp gflags glog protobuf cbc - pythonProtobuf python.pkgs.six + python.pkgs.protobuf python.pkgs.six ]; enableParallelBuilding = true; diff --git a/nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix b/nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix new file mode 100644 index 00000000000..9cd062d21f2 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix @@ -0,0 +1,27 @@ +{ stdenv +, fetchFromGitHub +, cmake +}: + +stdenv.mkDerivation rec { + pname = "osqp"; + version = "0.6.0"; + + src = fetchFromGitHub { + owner = "oxfordcontrol"; + repo = "osqp"; + rev = "v${version}"; + sha256 = "1gwk1bqsk0rd85zf7xplbwq822y5pnxjmqc14jj6knqbab9afvrs"; + fetchSubmodules = true; + }; + + nativeBuildInputs = [ cmake ]; + + meta = with stdenv.lib; { + description = "A quadratic programming solver using operator splitting"; + homepage = "https://osqp.org"; + license = licenses.asl20; + maintainers = with maintainers; [ taktoa ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix index 6eeeda9e928..82a0d063570 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix @@ -1,28 +1,38 @@ -{ stdenv , fetchurl , blas , gfortran , lapack , python }: +{ stdenv , darwin , fetchurl , blas , gfortran , lapack , python }: stdenv.mkDerivation rec { pname = "petsc"; - version = "3.13.1"; + version = "3.13.4"; src = fetchurl { url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-${version}.tar.gz"; - sha256 = "0pr604b9pnryl9q0q5arlhs0xdx7wslca0sbz0pzs9qylmz775qp"; + sha256 = "1n2paqw5c0ja392s1qhp7q2ypwav8s5drxxz2w5m2cn31vbspy1c"; }; - nativeBuildInputs = [ blas gfortran.cc.lib lapack python ]; + nativeBuildInputs = [ blas gfortran gfortran.cc.lib lapack python ]; - prePatch = stdenv.lib.optionalString stdenv.isDarwin '' + # Upstream does some hot she-py-bang stuff, this change streamlines that + # process. The original script in upstream is both a shell script and a + # python script, where the shellscript just finds a suitable python + # interpreter to execute the python script. See + # https://github.com/NixOS/nixpkgs/pull/89299#discussion_r450203444 + # for more details. + prePatch = '' + substituteInPlace configure \ + --replace /bin/sh /usr/bin/python + '' + stdenv.lib.optionalString stdenv.isDarwin '' substituteInPlace config/install.py \ - --replace /usr/bin/install_name_tool install_name_tool + --replace /usr/bin/install_name_tool ${darwin.cctools}/bin/install_name_tool ''; preConfigure = '' + export FC="${gfortran}/bin/gfortran" F77="${gfortran}/bin/gfortran" patchShebangs . configureFlagsArray=( $configureFlagsArray "--CC=$CC" "--with-cxx=$CXX" - "--with-fc=0" + "--with-fc=$FC" "--with-mpi=0" "--with-blas-lib=[${blas}/lib/libblas.so,${gfortran.cc.lib}/lib/libgfortran.a]" "--with-lapack-lib=[${lapack}/lib/liblapack.so,${gfortran.cc.lib}/lib/libgfortran.a]" diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix index 5a2c28d3c02..1c910a4f75b 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix @@ -6,7 +6,7 @@ stdenv.mkDerivation rec { pname = "suitesparse-graphblas"; - version = "3.2.2"; + version = "3.3.3"; outputs = [ "out" "dev" ]; @@ -14,7 +14,7 @@ stdenv.mkDerivation rec { owner = "DrTimothyAldenDavis"; repo = "GraphBLAS"; rev = "v${version}"; - sha256 = "04hprrgj0f44ml2f0w4jfwgrvy8l2s6ya0c9xc8gwlbmkc7a4c62"; + sha256 = "1nmygb2yny0mdqp0mc6760gbxklq1jjm0c6s39qkdwzf3n9f8j7p"; }; nativeBuildInputs = [ diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix index f0480e1e238..d50e065efc6 100644 --- a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix +++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix @@ -57,29 +57,6 @@ stdenv.mkDerivation rec { "library" ]; - # Likely fixed after 5.7.2 - # https://github.com/DrTimothyAldenDavis/SuiteSparse/commit/f6daae26ee391e475e2295e77c839aa7c1a8b784 - postInstall = stdenv.lib.optionalString stdenv.isDarwin '' - # The fixDarwinDylibNames in nixpkgs can't seem to fix all the libraries. - # We manually fix them up here. - fixDarwinDylibNames() { - local flags=() - local old_id - - for fn in "$@"; do - flags+=(-change "$PWD/lib/$(basename "$fn")" "$fn") - done - - for fn in "$@"; do - if [ -L "$fn" ]; then continue; fi - echo "$fn: fixing dylib" - install_name_tool -id "$fn" "''${flags[@]}" "$fn" - done - } - - fixDarwinDylibNames $(find "$out" -name "*.dylib") - ''; - meta = with stdenv.lib; { homepage = "http://faculty.cse.tamu.edu/davis/suitesparse.html"; description = "A suite of sparse matrix algorithms"; |