|
|
|
@ -10,23 +10,24 @@ package("libtorch") |
|
|
|
|
add_versions("v1.8.2", "e0495a7aa104471d95dc85a1b8f6473fbcc427a8") |
|
|
|
|
add_versions("v1.9.0", "d69c22dd61a2f006dcfe1e3ea8468a3ecaf931aa") |
|
|
|
|
add_versions("v1.9.1", "dfbd030854359207cb3040b864614affeace11ce") |
|
|
|
|
add_versions("v1.11.0", "bc2c6edaf163b1a1330e37a6e34caf8c553e4755") |
|
|
|
|
|
|
|
|
|
add_patches("1.9.x", path.join(os.scriptdir(), "patches", "1.9.0", "gcc11.patch"), "4191bb3296f18f040c230d7c5364fb160871962d6278e4ae0f8bc481f27d8e4b") |
|
|
|
|
add_patches("1.11.0", path.join(os.scriptdir(), "patches", "1.11.0", "gcc11.patch"), "1404b0bc6ce7433ecdc59d3412e3d9ed507bb5fd2cd59134a254d7d4a8d73012") |
|
|
|
|
|
|
|
|
|
add_configs("python", {description = "Build python interface.", default = false, type = "boolean"}) |
|
|
|
|
add_configs("ninja", {description = "Use ninja as build tool.", default = true, type = "boolean"}) |
|
|
|
|
add_configs("cuda", {description = "Enable CUDA support.", default = false, type = "boolean"}) |
|
|
|
|
add_configs("ninja", {description = "Use ninja as build tool.", default = false, type = "boolean"}) |
|
|
|
|
add_configs("blas", {description = "Set BLAS vendor.", default = "openblas", type = "string", values = {"mkl", "openblas", "eigen"}}) |
|
|
|
|
if not is_plat("macosx") then |
|
|
|
|
add_configs("blas", {description = "Set BLAS vendor.", default = "openblas", type = "string", values = {"mkl", "openblas"}}) |
|
|
|
|
add_configs("distributed", {description = "Enable distributed support.", default = false, type = "boolean"}) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
add_deps("cmake") |
|
|
|
|
add_deps("python 3.x", {kind = "binary", system = false}) |
|
|
|
|
add_deps("libuv") |
|
|
|
|
add_deps("cuda", {optional = true, configs = {utils = {"nvrtc", "cudnn", "cufft", "curand", "cublas", "cudart_static"}}}) |
|
|
|
|
add_deps("nvtx", {optional = true, system = true}) |
|
|
|
|
add_deps("python 3.x", {kind = "binary"}) |
|
|
|
|
|
|
|
|
|
add_includedirs("include") |
|
|
|
|
add_includedirs("include/torch/csrc/api/include") |
|
|
|
|
|
|
|
|
|
if is_plat("linux") then |
|
|
|
|
add_syslinks("rt") |
|
|
|
|
end |
|
|
|
@ -40,6 +41,13 @@ package("libtorch") |
|
|
|
|
if package:config("ninja") then |
|
|
|
|
package:add("deps", "ninja") |
|
|
|
|
end |
|
|
|
|
if package:config("cuda") then |
|
|
|
|
package:add("deps", "cuda", {configs = {utils = {"nvrtc", "cudnn", "cufft", "curand", "cublas", "cudart_static"}}}) |
|
|
|
|
package:add("deps", "nvtx") |
|
|
|
|
end |
|
|
|
|
if package:config("distributed") then |
|
|
|
|
package:add("deps", "libuv") |
|
|
|
|
end |
|
|
|
|
if not package:is_plat("macosx") and package:config("blas") then |
|
|
|
|
package:add("deps", package:config("blas")) |
|
|
|
|
end |
|
|
|
@ -56,13 +64,12 @@ package("libtorch") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- tackle link flags |
|
|
|
|
local has_cuda = package:dep("cuda"):exists() and package:dep("nvtx"):exists() |
|
|
|
|
local libnames = {"torch", "torch_cpu"} |
|
|
|
|
if has_cuda then |
|
|
|
|
if package:config("cuda") then |
|
|
|
|
table.insert(libnames, "torch_cuda") |
|
|
|
|
end |
|
|
|
|
table.insert(libnames, "c10") |
|
|
|
|
if has_cuda then |
|
|
|
|
if package:config("cuda") then |
|
|
|
|
table.insert(libnames, "c10_cuda") |
|
|
|
|
end |
|
|
|
|
local suffix = "" |
|
|
|
@ -82,11 +89,10 @@ package("libtorch") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if not package:config("shared") then |
|
|
|
|
for _, lib in ipairs({"nnpack", "pytorch_qnnpack", "qnnpack", "XNNPACK", "caffe2_protos", "protobuf-lite", "protobuf", "protoc", "onnx", "onnx_proto", "foxi_loader", "pthreadpool", "eigen_blas", "fbgemm", "cpuinfo", "clog", "dnnl", "mkldnn", "sleef", "asmjit", "fmt"}) do |
|
|
|
|
for _, lib in ipairs({"nnpack", "pytorch_qnnpack", "qnnpack", "XNNPACK", "caffe2_protos", "protobuf-lite", "protobuf", "protoc", "onnx", "onnx_proto", "foxi_loader", "pthreadpool", "eigen_blas", "fbgemm", "cpuinfo", "clog", "dnnl", "mkldnn", "sleef", "asmjit", "fmt", "kineto"}) do |
|
|
|
|
package:add("links", lib) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
package:add("links", "kineto") |
|
|
|
|
|
|
|
|
|
-- some patches to the third-party cmake files |
|
|
|
|
io.replace("third_party/fbgemm/CMakeLists.txt", "PRIVATE FBGEMM_STATIC", "PUBLIC FBGEMM_STATIC", {plain = true}) |
|
|
|
@ -97,7 +103,9 @@ package("libtorch") |
|
|
|
|
|
|
|
|
|
-- prepare python |
|
|
|
|
os.vrun("python -m pip install typing_extensions pyyaml") |
|
|
|
|
local configs = {"-DUSE_MPI=OFF", "-DCMAKE_INSTALL_LIBDIR=lib"} |
|
|
|
|
local configs = {"-DUSE_MPI=OFF", |
|
|
|
|
"-DCMAKE_INSTALL_LIBDIR=lib", |
|
|
|
|
"-DATEN_NO_TEST=ON"} |
|
|
|
|
if package:config("python") then |
|
|
|
|
table.insert(configs, "-DBUILD_PYTHON=ON") |
|
|
|
|
os.vrun("python -m pip install numpy") |
|
|
|
@ -116,11 +124,17 @@ package("libtorch") |
|
|
|
|
elseif package:config("blas") == "openblas" then |
|
|
|
|
table.insert(configs, "-DBLAS=OpenBLAS") |
|
|
|
|
envs.OpenBLAS_HOME = package:dep("openblas"):installdir() |
|
|
|
|
elseif package:config("blas") == "eigen" then |
|
|
|
|
table.insert(configs, "-DBLAS=Eigen") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
envs.libuv_ROOT = package:dep("libuv"):installdir() |
|
|
|
|
if package:config("distributed") then |
|
|
|
|
envs.libuv_ROOT = package:dep("libuv"):installdir() |
|
|
|
|
end |
|
|
|
|
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) |
|
|
|
|
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) |
|
|
|
|
table.insert(configs, "-DUSE_CUDA=" .. (package:config("cuda") and "ON" or "OFF")) |
|
|
|
|
table.insert(configs, "-DUSE_DISTRIBUTED=" .. (package:config("distributed") and "ON" or "OFF")) |
|
|
|
|
if package:is_plat("windows") then |
|
|
|
|
table.insert(configs, "-DCAFFE2_USE_MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF")) |
|
|
|
|
end |
|
|
|
|