Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Add a message for users running tf.js in node without the node backend #1085

Merged
merged 5 commits into from
Jun 7, 2018

Conversation

dsmilkov
Copy link
Contributor

@dsmilkov dsmilkov commented Jun 7, 2018

This PR adds a user-friendly message to remind people that we have node backend whenever they use tf.js in node with the vanilla cpu backend.

Also fixes a problem where a message saying document is not defined shows up at the top of the program. This was a side-effect of trying to access document when registering a WebGL backend.

screen shot 2018-06-06 at 9 46 25 pm

DOC


This change is Reviewable

@dsmilkov dsmilkov changed the title Improve message in node Add a message for users running tf.js in node without the node backend Jun 7, 2018
@caisq
Copy link
Collaborator

caisq commented Jun 7, 2018

Review status: 0 of 3 files reviewed at latest revision, all discussions resolved.


src/kernels/backend_cpu.ts, line 56 at r1 (raw file):

👋

What would this show up as in terminals that don't support unicode? Probably something like a question mark, as what I found when I tried it in non-unicode xterm. While I appreciate the lighthearted style, consider using something more robust. :)


src/kernels/backend_cpu.ts, line 57 at r1 (raw file):

speed up 

Grammar nit: "speech up" is transitive. Maybe say "speed things up" or "speech computation up."


src/kernels/backend_cpu.ts, line 57 at r1 (raw file):

 backend

Grammar nit: add comma after "backend".


src/kernels/backend_cpu.ts, line 59 at r1 (raw file):

`npm i @tensorflow/tfjs-node`

Not only this, but also something like import '@tensorflow/tfjs-node' is required in the source code - is that right?

Also, should you say something about CUDA support?


Comments from Reviewable

@caisq
Copy link
Collaborator

caisq commented Jun 7, 2018

Review status: 0 of 3 files reviewed at latest revision, 4 unresolved discussions.


src/kernels/backend_cpu.ts, line 59 at r1 (raw file):

Previously, caisq (Shanqing Cai) wrote…
`npm i @tensorflow/tfjs-node`

Not only this, but also something like import '@tensorflow/tfjs-node' is required in the source code - is that right?

Also, should you say something about CUDA support?

One idea, you can do a system call like which nvidia-smi to check whether nvidia-smi is on the path and if so, conditionally print some messages about CUDA tfjs-node.


Comments from Reviewable

@dsmilkov
Copy link
Contributor Author

dsmilkov commented Jun 7, 2018

Thanks for the review. PTAL.


Review status: 0 of 3 files reviewed at latest revision, 4 unresolved discussions.


src/kernels/backend_cpu.ts, line 56 at r1 (raw file):

Previously, caisq (Shanqing Cai) wrote…
👋

What would this show up as in terminals that don't support unicode? Probably something like a question mark, as what I found when I tried it in non-unicode xterm. While I appreciate the lighthearted style, consider using something more robust. :)

It shows up as ö, which is not bad. Non-unicode terminals are getting more rare. I think we can afford some emoji in 2018.


src/kernels/backend_cpu.ts, line 57 at r1 (raw file):

Previously, caisq (Shanqing Cai) wrote…
speed up 

Grammar nit: "speech up" is transitive. Maybe say "speed things up" or "speech computation up."

Done.


src/kernels/backend_cpu.ts, line 57 at r1 (raw file):

Previously, caisq (Shanqing Cai) wrote…
 backend

Grammar nit: add comma after "backend".

Done.


src/kernels/backend_cpu.ts, line 59 at r1 (raw file):

Previously, caisq (Shanqing Cai) wrote…

One idea, you can do a system call like which nvidia-smi to check whether nvidia-smi is on the path and if so, conditionally print some messages about CUDA tfjs-node.

Added CUDA. I did say "and import it in the program", but I added require('.....') to be more concise. Note I didn't use import '...' since that's es6 js. require() will work on all node versions. FYI, I didn't mention tf.setBackend('tensorflow') since that is going away in a upcoming PR (the import will do that for you).


Comments from Reviewable

@dsmilkov
Copy link
Contributor Author

dsmilkov commented Jun 7, 2018

Review status: 0 of 3 files reviewed at latest revision, 4 unresolved discussions.


src/kernels/backend_cpu.ts, line 59 at r1 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

Added CUDA. I did say "and import it in the program", but I added require('.....') to be more concise. Note I didn't use import '...' since that's es6 js. require() will work on all node versions. FYI, I didn't mention tf.setBackend('tensorflow') since that is going away in a upcoming PR (the import will do that for you).

Leave which nvidia-smi for a future time. It will be tricky to conditionally import node utility libraries in tfjs-core that execute a system call while still making sure that the browserified bundle doesn't have those imports.


Comments from Reviewable

@caisq
Copy link
Collaborator

caisq commented Jun 7, 2018

:lgtm_strong:

Thanks!


Review status: 0 of 3 files reviewed at latest revision, 4 unresolved discussions.


Comments from Reviewable

@nkreeger
Copy link
Contributor

nkreeger commented Jun 7, 2018

Review status: 0 of 3 files reviewed at latest revision, 4 unresolved discussions, all commit checks successful.


src/kernels/backend_cpu.ts, line 59 at r1 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

Leave which nvidia-smi for a future time. It will be tricky to conditionally import node utility libraries in tfjs-core that execute a system call while still making sure that the browserified bundle doesn't have those imports.

CUDA is Linux only and still a pain to install. Lots of Linux users don't have a CUDA-capable card - so let's not sweat that here. I think if users know about CUDA + nvidia-smi (which is linux only) they'll be able to find @tensorflow/tfjs-node-gpu.

I'd advise dropping this for now.


Comments from Reviewable

@dsmilkov
Copy link
Contributor Author

dsmilkov commented Jun 7, 2018

Review status: 0 of 3 files reviewed at latest revision, 4 unresolved discussions, all commit checks successful.


src/kernels/backend_cpu.ts, line 59 at r1 (raw file):

Previously, nkreeger (Nick Kreeger) wrote…

CUDA is Linux only and still a pain to install. Lots of Linux users don't have a CUDA-capable card - so let's not sweat that here. I think if users know about CUDA + nvidia-smi (which is linux only) they'll be able to find @tensorflow/tfjs-node-gpu.

I'd advise dropping this for now.

I'll still keep the tiny plug for CUDA (in case someone has it, they should know we support it) but not going into details. People that don't know what CUDA is will either 1) ignore the "if you have CUDA" message, or 2) go google it and learn about it, which is also good


Comments from Reviewable

@dsmilkov dsmilkov merged commit b99507d into master Jun 7, 2018
@dsmilkov dsmilkov deleted the improve-node-msg branch June 7, 2018 14:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants