-
Notifications
You must be signed in to change notification settings - Fork 2k
Add aarch64 support for tfjs-node #2513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add aarch64 support for tfjs-node #2513
Conversation
|
Hi @kangyizhang, in order to support aarch64, I added architecture into the filename of those pre-compiled resources which are stored in the cloud storage. For example, And I can help to provide the arm64 binaries for linux platform. |
86775a4 to
62381d8
Compare
kangyizhang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Yihong, thanks a lot for this PR. Left minor comment. Let me know when you want me to upload the libtensorflow of arm64.
Reviewable status: 0 of 1 approvals obtained (waiting on @yhwang)
tfjs-node/scripts/install.js, line 93 at r1 (raw file):
} return `${BASE_URI}${libType}-${PLATFORM_MAPPING[platform]}-` +
Can you add a special case here for GPU+darwin? Since there is no gpu libtensorflow for darwin, here the libType should always be CPU if platform is darwin.
62381d8 to
a337cb7
Compare
yhwang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @kangyizhang)
tfjs-node/scripts/install.js, line 93 at r1 (raw file):
Previously, kangyizhang (Kangyi Zhang) wrote…
Can you add a special case here for GPU+darwin? Since there is no gpu libtensorflow for darwin, here the libType should always be
CPUif platform isdarwin.
or should we have a list to store all supported platforms, types and architectures. then reject the unsupported combination?
yhwang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have gpu-linux-arm64 binary. how about cpu-linux-arm64?
Reviewable status: 0 of 1 approvals obtained (waiting on @kangyizhang)
a337cb7 to
5df4cd2
Compare
|
@kangyizhang I made some changes and it detects if the system is supported or not. In arm64 system, it also runs
I put gpu-linux-arm64 here |
5df4cd2 to
2b3be58
Compare
b888da2 to
c2022ca
Compare
|
In the latest change, |
yhwang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @kangyizhang)
tfjs-node/scripts/install.js, line 93 at r1 (raw file):
Previously, yhwang (Yihong Wang) wrote…
or should we have a list to store all supported platforms, types and architectures. then reject the unsupported combination?
I added an array to store all official supported systems and throw an error if it's unsupported system.
yhwang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @kangyizhang)
tfjs-node/scripts/install.js, line 93 at r1 (raw file):
Previously, yhwang (Yihong Wang) wrote…
I added an array to store all official supported systems and throw an error if it's unsupported system.
Done.
kangyizhang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @kangyizhang and @yhwang)
tfjs-node/scripts/get-addon-name.js, line 74 at r2 (raw file):
Quoted 6 lines of code…
customTFLibUri: customBinaries['tf-lib'], customAddon: customBinaries['addon'], ARCH_MAPPING, PLATFORM_MAPPING, PLATFORM_EXTENSION, ALL_SUPPORTED_COMBINATION
can you move these constant values to scripts/deps-constants.js? I think you were having these fields in deps-constants.js file in the previous version of this PR. I'm requesting this because this file is suppose to be only used to generate pre-compiled addon-name, which is heavily used when we develop and publish new NPM package. Other constants should stay in the deps-constants.js file.
tfjs-node/scripts/install.js, line 93 at r1 (raw file):
Previously, yhwang (Yihong Wang) wrote…
Done.
Thanks for adding the list of supported platforms. But we should still make an exception for mac+gpu with no customized binary. Because there might be existing users using tfjs-node-gpu on their mac, maybe developing process that runs on cloud with CUDA GPU, and a new version of this library should not break their development.
tfjs-node/scripts/install.js, line 168 at r2 (raw file):
cp.exec('node scripts/deps-stage.js symlink ' + modulePath); } revertAddonName();
can you keep revertAddonName() here to ensure that it's called after node-pre-gyp install is executed. Otherwise the addon name in package.json might be reverted before node-pre-gyp runs.
kangyizhang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the update. Do you mind to provide an example of the custom-binary.json file (base on the code it seems like it should include all the fields in package.json.binary) so that I can use it to update the readme file?
Reviewable status: 0 of 1 approvals obtained (waiting on @kangyizhang and @yhwang)
Modify the install.js to support external binaries while installing npm package. It reads the `custom-binary.json` configuration file to get URLs for the following resources: - 'tf-lib': libtensorflow and libtensorflow_framework shared libraries. Its value is a URL that points to a `tar.gz` or `zip` and contains the shared libaries and header files. - 'addon': pre-compiled node binding. Its value is a object contains three values: `host`, `remote_path` and `package_name`. These three values are concatenated into a URL that points to the pre-compiled node binding. If you only provide `tf-lib` and no `addon`. It compiles the node binding while installing the npm package. Signed-off-by: Yihong Wang <yh.wang@ibm.com>
c2022ca to
73c8461
Compare
yhwang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added custom-binary.sample.json as the example for custom-binary.json
Reviewable status: 0 of 1 approvals obtained (waiting on @kangyizhang)
tfjs-node/scripts/get-addon-name.js, line 74 at r2 (raw file):
Previously, kangyizhang (Kangyi Zhang) wrote…
customTFLibUri: customBinaries['tf-lib'], customAddon: customBinaries['addon'], ARCH_MAPPING, PLATFORM_MAPPING, PLATFORM_EXTENSION, ALL_SUPPORTED_COMBINATIONcan you move these constant values to
scripts/deps-constants.js? I think you were having these fields in deps-constants.js file in the previous version of this PR. I'm requesting this because this file is suppose to be only used to generate pre-compiled addon-name, which is heavily used when we develop and publish new NPM package. Other constants should stay in the deps-constants.js file.
sure. my thought is those constants belong to add-on. That's why I had them here. I moved them to deps-constants.js now
tfjs-node/scripts/install.js, line 93 at r1 (raw file):
Previously, kangyizhang (Kangyi Zhang) wrote…
Thanks for adding the list of supported platforms. But we should still make an exception for mac+gpu with no customized binary. Because there might be existing users using tfjs-node-gpu on their mac, maybe developing process that runs on cloud with CUDA GPU, and a new version of this library should not break their development.
add an exception for mac+gpu case. done
tfjs-node/scripts/install.js, line 168 at r2 (raw file):
Previously, kangyizhang (Kangyi Zhang) wrote…
can you keep
revertAddonName()here to ensure that it's called afternode-pre-gyp installis executed. Otherwise the addon name in package.json might be reverted before node-pre-gyp runs.
done. I also moved some related code to here. It's easier to read.
kangyizhang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution!
I made some edits for readability and added some instruction in readme file. Please verify if the edition works with your binary. Otherwise LGTM.
Reviewable status:
complete! 1 of 1 approvals obtained (waiting on @kangyizhang)
|
looks good to me. thanks for removing the |
|
thank you for the PR! |
Modify the install.js to support external binaries while installing
npm package. It reads the
custom-binary.jsonconfiguration file toget URLs for the following resources:
Its value is a URL that points to a
tar.gzorzipandcontains the shared libaries and header files.
three values:
host,remote_pathandpackage_name. These threevalues are concatenated into a URL that points to the
pre-compiled node binding.
If you only provide
tf-liband noaddon. It compiles the nodebinding while installing the npm package.
Signed-off-by: Yihong Wang yh.wang@ibm.com
To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.
This change is