1

I'm new to both Node.js and Tensorflow so I apologize if this is kind of stupid. I'm also new to Stack Overflow so I apologize if this isn't the best-formatted question. I'm trying to implement Tensorflow into a Discord bot(to make a chatbot). I have some experience in Java so I was able to fix some node.js errors, but I can't figure out what this error means as it appears to be a Tensorflow error, not a node.js error and I'm completely new to Tensorflow. One more thing: I am using the provided example code found at https://www.tensorflow.org/js/guide/nodejs except for import * as tf from '@tensorflow/tfjs-node' which I replaced with const tf = require('@tensorflow/tfjs-node'); since import gives an error.

The error I am getting:

2020-03-25 21:02:38.317965: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at summary_kernels.cc:57 : Not found: Failed to create a directory: \/tmp; No such file or directory (node:3504) UnhandledPromiseRejectionWarning: Error: Invalid TF_Status: 5 Message: Failed to create a directory: \/tmp; No such file or directory at NodeJSKernelBackend.executeMultipleOutputs (C:\Users\BCG04\node_modules\@tensorflow\tfjs-node\dist\nodejs_kernel_backend.js:206:43) at NodeJSKernelBackend.createSummaryFileWriter (C:\Users\BCG04\node_modules\@tensorflow\tfjs-node\dist\nodejs_kernel_backend.js:1580:14) at Object.summaryFileWriter (C:\Users\BCG04\node_modules\@tensorflow\tfjs-node\dist\tensorboard.js:98:17) at TensorBoardCallback.ensureValWriterCreated (C:\Users\BCG04\node_modules\@tensorflow\tfjs-node\dist\callbacks.js:310:40) at TensorBoardCallback.logMetrics (C:\Users\BCG04\node_modules\@tensorflow\tfjs-node\dist\callbacks.js:296:22) at TensorBoardCallback.<anonymous> (C:\Users\BCG04\node_modules\@tensorflow\tfjs-node\dist\callbacks.js:262:26) at step (C:\Users\BCG04\node_modules\@tensorflow\tfjs-node\dist\callbacks.js:61:23) at Object.next (C:\Users\BCG04\node_modules\@tensorflow\tfjs-node\dist\callbacks.js:42:53) at C:\Users\BCG04\node_modules\@tensorflow\tfjs-node\dist\callbacks.js:36:71 at new Promise (<anonymous>) (node:3504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3) (node:3504) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This is the code with the error:

client.once('ready', () => {
    //Start TENSORFLOW tests

    const model = tf.sequential();
model.add(tf.layers.dense({ units: 1, inputShape: [200] }));
model.compile({
  loss: 'meanSquaredError',
  optimizer: 'sgd',
  metrics: ['MAE']
});


// Generate some random fake data for demo purpose.
const xs = tf.randomUniform([10000, 200]);
const ys = tf.randomUniform([10000, 1]);
const valXs = tf.randomUniform([1000, 200]);
const valYs = tf.randomUniform([1000, 1]);


// Start model training process.
async function train() {
  await model.fit(xs, ys, {
    epochs: 100,
    validationData: [valXs, valYs],
    // Add the tensorBoard callback here.
    callbacks: tf.node.tensorBoard('/tmp/fit_logs_1')
  });
}
train();

    //End TENSORFLOW  tests
    console.log('Ready!');
    console.log("Servers:")
    client.guilds.cache.map((guild) => {
        console.log(" - " + guild.name)

        // List all channels
        client.guilds.cache.map((channel) => {
            console.log(` -- ${channel.name} (${channel.type}) - ${channel.id}`)
        });
    });
});
3
  • Message: Failed to create a directory: \/tmp; looks like you are running in windows box and definitely /tmp will not be available. If you an share code snippet, i think community can help. Commented Mar 26, 2020 at 3:25
  • I updated it with the code with the error. Sorry, I don't really know how to format it good for Stack Overflow Commented Mar 26, 2020 at 3:36
  • Thanks for updating with snippet and sorry for delay in response. Commented Mar 28, 2020 at 6:23

2 Answers 2

1

As you are running on windows machine, this directory is invalid.

Please replace this line callbacks: tf.node.tensorBoard('/tmp/fit_logs_1') with this

callbacks: tf.node.tensorBoard('C:\\Users\\BCG04')
Sign up to request clarification or add additional context in comments.

Comments

0

It seems you dont have access to create tmp folder on root as indicated on the code tf.node.tensorBoard('/tmp/fit_logs_1'). Try to change the path.

For me i've change it into tf.node.tensorBoard('.tmp/fit_logs_1') so it will create .tmp directory on current working path.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.