diff --git a/T/Torch/Torch/build_tarballs.jl b/T/Torch/Torch/build_tarballs.jl new file mode 100644 index 00000000000..7c7ef9f2447 --- /dev/null +++ b/T/Torch/Torch/build_tarballs.jl @@ -0,0 +1,61 @@ +# Note that this script can accept some limited command-line arguments, run +# `julia build_tarballs.jl --help` to see a usage message. +using BinaryBuilder, Pkg + +name = "Torch" +version = v"1.10.2" + +# Collection of sources required to complete build +sources = [ + GitSource("https://github.com/FluxML/Torch.jl.git", "4167e3c21421555ad90868ca5483cd5c2ad0c449"), # v0.1.2 + ArchiveSource("https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.10.2%2Bcpu.zip", "fa3fad287c677526277f64d12836266527d403f21f41cc2e7fb9d904969d4c4a"; unpack_target = "x86_64-linux-gnu-cxx03"), + ArchiveSource("https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.10.2%2Bcpu.zip", "83e43d63d0e7dc9d57ccbdac8a8d7edac6c9e18129bf3043be475486b769a9c2"; unpack_target = "x86_64-linux-gnu-cxx11"), + ArchiveSource("https://download.pytorch.org/libtorch/cpu/libtorch-macos-1.10.2.zip", "d1711e844dc69c2338adfc8ce634806a9ae36e54328afbe501bafd2d70f550e2"; unpack_target = "x86_64-apple-darwin14"), + ArchiveSource("https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-1.10.2%2Bcpu.zip", "0ce2ccd959704cd85c44ad1f3f335c56734c7ff09418bd563e07d5bb7142510c"; unpack_target = "x86_64-w64-mingw32"), +] + +# Bash recipe for building across all platforms +script = raw""" +mkdir -p $includedir $libdir $prefix/share + +cd $WORKSPACE/srcdir + +if [[ $target == *linux* ]]; then + cd $target-`echo $bb_full_target | sed -E -e 's/.*(cxx..).*/\1/'` +else + cd $target +fi +mv libtorch/include/* $includedir +mv libtorch/share/* $prefix/share/ +mv libtorch/lib/* $libdir + +cd $WORKSPACE/srcdir/Torch.jl/build +mkdir build && cd build +cmake -DCMAKE_PREFIX_PATH=$prefix -DTorch_DIR=$prefix/share/cmake/Torch .. +cmake --build . + +cp -r $WORKSPACE/srcdir/Torch.jl/build/build/*.${dlext} "${libdir}" +install_license ${WORKSPACE}/srcdir/Torch.jl/LICENSE +""" + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = [ + Platform("x86_64", "linux"), + Platform("x86_64", "macos"), + Platform("x86_64", "windows"), +] +platforms = expand_cxxstring_abis(platforms; skip = !Sys.islinux) + +# The products that we will ensure are always built +products = [ + LibraryProduct("libdoeye_caml", :libdoeye_caml, dont_dlopen = true), + LibraryProduct("libtorch", :libtorch, dont_dlopen = true), +] + +# Dependencies that must be installed before this package can be built +dependencies = Dependency[ +] + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version = v"7.1.0") diff --git a/T/Torch/TorchCUDA/build_tarballs.jl b/T/Torch/TorchCUDA/build_tarballs.jl new file mode 100644 index 00000000000..c31be4de4f9 --- /dev/null +++ b/T/Torch/TorchCUDA/build_tarballs.jl @@ -0,0 +1,83 @@ +using BinaryBuilder, Pkg +using Base.BinaryPlatforms: arch, os + +include("../../../fancy_toys.jl") + +name = "TorchCUDA" +version = v"1.10.2" + +common_sources = [ + GitSource("https://github.com/FluxML/Torch.jl.git", "4167e3c21421555ad90868ca5483cd5c2ad0c449"), # v0.1.2 + ArchiveSource("https://github.com/JuliaBinaryWrappers/CUDA_full_jll.jl/releases/download/CUDA_full-v11.6.0%2B0/CUDA_full.v11.6.0.x86_64-linux-gnu.tar.gz", "c86b0638417588585c66a121b9bd6c863ddffd5aaf07f51db6f0dcfbff11d98b"; unpack_target = "CUDA_full.v11.6"), +] + +cuda_10_sources = [ + ArchiveSource("https://download.pytorch.org/libtorch/cu102/libtorch-shared-with-deps-1.10.2%2Bcu102.zip", "206ab3f44d482a1d9837713cafbde9dd9d7907efac2dc94f1dc86e9a1101296f"; unpack_target = "x86_64-linux-gnu-cxx03"), + ArchiveSource("https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-1.10.2%2Bcu102.zip", "c1f994b4a019f2f75e3a58b8ddb132aaf8bb99673abc35f0f6d21c3b8f622cc4"; unpack_target = "x86_64-linux-gnu-cxx11"), + ArchiveSource("https://download.pytorch.org/libtorch/cu102/libtorch-win-shared-with-deps-1.10.2%2Bcu102.zip", "558971c390853aac7f1be002fcb1a4d0d94e480edcc23435e1d9c720312d812b"; unpack_target = "x86_64-w64-mingw32"), +] + +cuda_11_sources = [ + ArchiveSource("https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.10.2%2Bcu113.zip", "39f799e272924be118e99582eec10342dc7643c248ee404944defc6753bd88b7"; unpack_target = "x86_64-linux-gnu-cxx03"), + ArchiveSource("https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.10.2%2Bcu113.zip", "2557943af80ec93f8249f6c5c829db6c6688842afa25a7d848f5c471473eb898"; unpack_target = "x86_64-linux-gnu-cxx11"), + ArchiveSource("https://download.pytorch.org/libtorch/cu113/libtorch-win-shared-with-deps-1.10.2%2Bcu113.zip", "abe442bb99e166a68c05e9132e2d4a076e9d31af9fd09610e93be9bde62d3bdc"; unpack_target = "x86_64-w64-mingw32"), +] + +script = raw""" +cuda_version=`echo $bb_full_target | sed -E -e 's/.*cuda\+([0-9]+\.[0-9]+).*/\1/'` +cuda_full_path="$WORKSPACE/srcdir/CUDA_full.v$cuda_version" + +mkdir -p $includedir $libdir $prefix/share + +cd $WORKSPACE/srcdir + +if [[ $target == *linux* ]]; then + cd $target-`echo $bb_full_target | sed -E -e 's/.*(cxx..).*/\1/'` +else + cd $target +fi +mv libtorch/include/* $includedir +mv libtorch/share/* $prefix/share/ +mv libtorch/lib/* $libdir + +cd $WORKSPACE/srcdir/Torch.jl/build +mkdir build && cd build +cmake -DCMAKE_PREFIX_PATH=$prefix -DTorch_DIR=$prefix/share/cmake/Torch -DCUDA_TOOLKIT_ROOT_DIR=$cuda_full_path/cuda .. +cmake --build . + +cp -r $WORKSPACE/srcdir/Torch.jl/build/build/*.${dlext} "${libdir}" +install_license ${WORKSPACE}/srcdir/Torch.jl/LICENSE +""" + +platforms = [ + Platform("x86_64", "linux"), + Platform("x86_64", "windows"), +] +platforms = expand_cxxstring_abis(platforms; skip = !Sys.islinux) + +products = [ + LibraryProduct("libdoeye_caml", :libdoeye_caml, dont_dlopen = true), + LibraryProduct("libtorch", :libtorch, dont_dlopen = true), +] + +dependencies = [ + Dependency("CUDNN_jll") +] + +cuda_versions = [v"11.6"]#[v"10.2", v"11.0", v"11.1", v"11.2", v"11.3", v"11.4", v"11.5", v"11.6"] +for cuda_version in cuda_versions + cuda_tag = "$(cuda_version.major).$(cuda_version.minor)" + if cuda_version.major == 10 + sources = vcat(common_sources, cuda_10_sources) + elseif cuda_version.major == 11 + sources = vcat(common_sources, cuda_11_sources) + end + + for platform in platforms + augmented_platform = Platform(arch(platform), os(platform); cuda=cuda_tag) + should_build_platform(triplet(augmented_platform)) || continue + build_tarballs(ARGS, name, version, sources, script, [augmented_platform], + products, dependencies; lazy_artifacts=true, + preferred_gcc_version = v"7.1.0") + end +end diff --git a/T/Torch/build_tarballs.jl b/T/Torch/build_tarballs.jl deleted file mode 100644 index daf28312e73..00000000000 --- a/T/Torch/build_tarballs.jl +++ /dev/null @@ -1,62 +0,0 @@ -# Note that this script can accept some limited command-line arguments, run -# `julia build_tarballs.jl --help` to see a usage message. -using BinaryBuilder, Pkg - -name = "Torch" -version = v"1.4.0" - -# Collection of sources required to complete build -sources = [ - GitSource("https://github.com/dhairyagandhi96/Torch.jl.git", "85bd08d39e7fba29ec4a643f60dd006ed8be8ede"), - ArchiveSource("https://download.pytorch.org/libtorch/cu101/libtorch-cxx11-abi-shared-with-deps-1.4.0.zip", "f214bfde532877aa5d4e0803e51a28fa8edd97b6a44b6615f75a70352b6b542e"), - ArchiveSource("https://github.com/JuliaGPU/CUDABuilder/releases/download/v0.3.0/CUDNN+CUDA10.1.v7.6.5.x86_64-linux-gnu.tar.gz", "79de5b5085a33bc144b87028e998a1d295a15c3424d6d45b25defe500f616974", unpack_target = "cudnn"), -] - -# Bash recipe for building across all platforms -script = raw""" -cd $WORKSPACE/srcdir - -mv cudnn $prefix -mv libtorch/share/* $prefix/share/ -mv libtorch/lib/* $prefix/lib/ -rm -r libtorch/lib -rm -r libtorch/share -mv libtorch/* $prefix -rm -r libtorch - -mkdir -p /usr/local/cuda/lib64 -cd /usr/local/cuda/lib64 -ln -s ${prefix}/cuda/lib64/libcudart.so libcudart.so -ln -s ${prefix}/cuda/lib64/libnvToolsExt.so libnvToolsExt.so - -cd $WORKSPACE/srcdir/Torch.jl/build -mkdir build && cd build -cmake -DCMAKE_PREFIX_PATH=$prefix -DTorch_DIR=$prefix/share/cmake/Torch -DCUDA_TOOLKIT_ROOT_DIR=$prefix/cuda .. -cmake --build . - -mkdir -p "${libdir}" -cp -r $WORKSPACE/srcdir/Torch.jl/build/build/*.${dlext} "${libdir}" -rm -rf $prefix/cuda -install_license ${WORKSPACE}/srcdir/Torch.jl/LICENSE -""" - -# These are the platforms we will build for by default, unless further -# platforms are passed in on the command line -platforms = [ - Platform("x86_64", "linux"; libc="glibc", cxxstring_abi = "cxx11"), -] - -# The products that we will ensure are always built -products = [ - LibraryProduct("libdoeye_caml", :libdoeye_caml, dont_dlopen = true), - LibraryProduct("libtorch", :libtorch, dont_dlopen = true), -] - -# Dependencies that must be installed before this package can be built -dependencies = [ - BuildDependency(PackageSpec(name="CUDA_full_jll", version=v"10.1.243")), - Dependency(PackageSpec(name="CompilerSupportLibraries_jll")), -] - -# Build the tarballs, and possibly a `build.jl` as well. -build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version = v"7.1.0")