Skip to content

Commit 0c95db9

Browse files
committed
fix linux build, add Dockerfile
1 parent 9cdcf89 commit 0c95db9

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
.git
3+
.idea
4+
libtorch
5+
build*
6+
cmake-build*
7+
lib/binding

binding.gyp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
"action_name": "ncmake",
1414
"inputs": [""],
1515
"outputs": [""],
16-
"conditions": [ [ "OS=='linux'", {"action": ["npm", "run", "cmake-rebuild", "-DNAPI_VERSION=<(napi_build_version)"]} ] ],
17-
"conditions": [ [ "OS=='win'", {"action": ["npm run cmake-rebuild", "-DNAPI_VERSION=<(napi_build_version)"]} ] ]
16+
"conditions": [
17+
[ "OS=='linux'",
18+
{"action": ["npm", "run", "cmake-rebuild", "-DNAPI_VERSION=<(napi_build_version)"]}
19+
],
20+
[ "OS=='win'",
21+
{"action": ["npm run cmake-rebuild", "-DNAPI_VERSION=<(napi_build_version)"]}
22+
]
23+
]
1824
}
1925
]
2026
},
@@ -24,33 +30,36 @@
2430
"type": "none",
2531
"dependencies": [ "<(module_name)" ],
2632
"copies": [
27-
{
33+
{
2834
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
2935
"destination": "<(module_path)"
3036
},
3137
{
3238
# include libtorch shared libraries
3339
"files": [ ],
34-
"conditions": [ [ "OS=='linux'", {
35-
"files+": ["libtorch/lib/libtorch.so", "libtorch/lib/libtorch.so.1", "libtorch/lib/libc10.so",
40+
"conditions": [
41+
[ "OS=='linux'",
42+
{ "files+": ["libtorch/lib/libtorch.so", "libtorch/lib/libtorch.so.1", "libtorch/lib/libc10.so",
3643
"libtorch/lib/libcaffe2.so", "libtorch/lib/libmkldnn.so.0",
3744
"libtorch/lib/libmkldnn.so.0.14.0", "libtorch/lib/libonnxifi_dummy.so",
3845
"libtorch/lib/libgomp-7bcb08ae.so.1"]
39-
} ] ],
40-
"conditions": [ [ "OS=='win'", {
41-
"files+": ["libtorch/lib/c10.dll",
46+
}
47+
],
48+
[ "OS=='win'",
49+
{ "files+": ["libtorch/lib/c10.dll",
4250
"libtorch/lib/caffe2.dll",
4351
"libtorch/lib/libiompstubs5md.dll",
4452
"libtorch/lib/caffe2_module_test_dynamic.dll",
4553
"libtorch/lib/libiomp5md.dll",
4654
"libtorch/lib/onnxifi_dummy.dll",
4755
"libtorch/lib/onnxifi.dll",
4856
"libtorch/lib/torch.dll"]
49-
} ] ],
57+
}
58+
]
59+
],
5060
"destination": "<(module_path)"
5161
}
5262
]
5363
}
5464
]
55-
}
56-
65+
}

scripts/Dockerfile.linux-cpu-build

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM fedora:latest
2+
3+
WORKDIR /libtorchjs
4+
5+
# install build tools
6+
RUN yum install -y cmake make gcc-c++ unzip
7+
8+
# install nodejs
9+
RUN curl -sL https://rpm.nodesource.com/setup_10.x | bash - && \
10+
yum install -y nodejs
11+
12+
# download libtorch
13+
ADD https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-latest.zip .
14+
RUN unzip libtorch-shared-with-deps-latest.zip
15+
16+
# install packages first
17+
ADD package*.json ./
18+
RUN npm i --no-scripts
19+
20+
# add rest of the files and build
21+
ADD . .
22+
RUN npm run pre-build
23+
RUN npm test

0 commit comments

Comments
 (0)