Spaces:
Sleeping
Sleeping
Commit
·
7373a84
1
Parent(s):
cd7c5fe
added log statements to see wheter a gpu is used or not
Browse files- src/main.js +23 -1
src/main.js
CHANGED
|
@@ -6,9 +6,28 @@ async function initializeWebGPU() {
|
|
| 6 |
return;
|
| 7 |
}
|
| 8 |
|
|
|
|
|
|
|
| 9 |
const adapter = await navigator.gpu.requestAdapter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
const device = await adapter.requestDevice();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
const context = canvas.getContext("webgpu");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
context.configure({
|
| 14 |
device: device,
|
|
@@ -16,9 +35,12 @@ async function initializeWebGPU() {
|
|
| 16 |
alphaMode: "opaque",
|
| 17 |
});
|
| 18 |
|
| 19 |
-
console.log("WebGPU initialized.");
|
| 20 |
}
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
async function submitQuestion(imageFile, question) {
|
| 23 |
const formData = new FormData();
|
| 24 |
formData.append("image", imageFile);
|
|
|
|
| 6 |
return;
|
| 7 |
}
|
| 8 |
|
| 9 |
+
console.log("WebGPU is supported.");
|
| 10 |
+
|
| 11 |
const adapter = await navigator.gpu.requestAdapter();
|
| 12 |
+
if (!adapter) {
|
| 13 |
+
console.error("Failed to get GPU adapter.");
|
| 14 |
+
return;
|
| 15 |
+
}
|
| 16 |
+
console.log("GPU adapter obtained.");
|
| 17 |
+
|
| 18 |
const device = await adapter.requestDevice();
|
| 19 |
+
if (!device) {
|
| 20 |
+
console.error("Failed to get GPU device.");
|
| 21 |
+
return;
|
| 22 |
+
}
|
| 23 |
+
console.log("GPU device obtained.");
|
| 24 |
+
|
| 25 |
const context = canvas.getContext("webgpu");
|
| 26 |
+
if (!context) {
|
| 27 |
+
console.error("Failed to get WebGPU context.");
|
| 28 |
+
return;
|
| 29 |
+
}
|
| 30 |
+
console.log("WebGPU context obtained.");
|
| 31 |
|
| 32 |
context.configure({
|
| 33 |
device: device,
|
|
|
|
| 35 |
alphaMode: "opaque",
|
| 36 |
});
|
| 37 |
|
| 38 |
+
console.log("WebGPU initialized and canvas configured.");
|
| 39 |
}
|
| 40 |
|
| 41 |
+
// Call the initializeWebGPU function to ensure it runs
|
| 42 |
+
initializeWebGPU();
|
| 43 |
+
|
| 44 |
async function submitQuestion(imageFile, question) {
|
| 45 |
const formData = new FormData();
|
| 46 |
formData.append("image", imageFile);
|