Hi,
As an OSX user with an Intel chip, I am unable to use CUDA. For this, I am trying to use libraries for non-NVIDIA systems such as Kompute. (see this documentation)
So far I couldn’t manage to use it in TouchDesigner since it causes a fatal error and a crash.
An example Script CHOP script which causes a fatal error:
# Test Script CHOP code
# Import necessary libraries
from kp import Manager, Tensor
def onCook(scriptOp):
# Define vector data
vector_a = [1.0, 2.0, 3.0, 4.0]
vector_b = [5.0, 6.0, 7.0, 8.0]
# Create Kompute Manager
mgr = Manager()
# Create tensors and upload to GPU
tensor_a = mgr.tensor(vector_a, dtype='float32')
tensor_b = mgr.tensor(vector_b, dtype='float32')
tensor_result = mgr.tensor([0.0] * len(vector_a), dtype='float32')
# Upload tensors to GPU
mgr.eval_tensor_upload([tensor_a, tensor_b, tensor_result])
# Shader code to perform addition on the GPU
shader_code = """
#version 450
layout (local_size_x = 1) in;
layout(set = 0, binding = 0) buffer a { float a[]; };
layout(set = 0, binding = 1) buffer b { float b[]; };
layout(set = 0, binding = 2) buffer result { float result[]; };
void main() {
uint index = gl_GlobalInvocationID.x;
result[index] = a[index] + b[index];
}
"""
# Define and execute the operation
mgr.eval_algo(shader_code, [tensor_a, tensor_b, tensor_result])
# Download results back to CPU
mgr.eval_tensor_download([tensor_result])
# Write the result to Script TOP
result = tensor_result.data()
scriptOp.clear()
scriptOp.appendChan("result")
for val in result:
scriptOp.appendSample([val])
return
Is there anyone who has used Kompute or a similar library in TouchDesigner for GPU acceleration? If so, did you encounter any similar issues or have any tips on how to avoid crashes?
Bw
Edit:
Build 2023.11600
MacOSX 14.4.1 (23E224)
Edit 2: corrected typo (typed TOP instead of CHOP by mistake)