CPU time limit exceeded, any way to check sdk version?
Is there any way to check the sdk version? I redeployed, but am still experiencing the same timeout issues today
4 Replies
Not sure if there's any convenient way. I assumed that you use(d) the "Text to Image" template in the dashboard to create a worker. If so, the latest (1.1.0) version should be bundled with your worker (tested it myself) , and you're kinda stuck with it. If you are using wrangler, you can find the version in
<path to your worker>/node_modules/@cloudflare/ai/package.json
and update the package by running cd <path to your worker>
+ npm update @cloudflare/ai --save-dev
.
In any case, you can check the CPU usage by navigating to your worker in the dashboard. Select "Last 30 minutes", fire off a dozen requests or so and look at the CPU time graph. Before version 1.1.0, calling@cf/bytedance/stable-diffusion-xl-lightning
took hundreds of milliseconds.
Now, there's a twist. If you're running 1.1.0 on the free tier and still getting CPU time limit exceeded, then it might be that the processing happening behind the scenes still counts somehow. (I've upgraded to paid, so can't test it.) If that's the case, then one option would be having your worker running the model via API instead.That appears to be the case - all of these requests timed out, but all had 0 reported CPU time used... And I do believe that I am running the model via API. Relevant code snippet: const response = await ai.run(
model,
inputs
);
It's hard for me to tell what version of cloudflare/ai I'm using, becuase that actually isn't in my package.json at all. I've got the src/vendor/@cloudflare/ai.js instead.
ai.run(......)
means that you're using a worker binding (i.e. not the REST API).
I've put together two snippets for you: https://gist.github.com/Raylight-PWL/2531a8794084f6ffc2120efc2972ee95 The first one is a tiny (but complete) worker with an interactive "front end" that should be compatible the the current Text to Image template in the dashboard. The second one shows how you call the model using REST API instead of a worker binding.This is super helpful - you've really gone above and beyond! 🙂 I've updated my worker to use the REST API, and things have been working great.