Cuda is Nivida provided api that lets c/c++ use gpu for some stuff, even though i don't what that some stuff is & would like to know, from what i saw the gains were remarkable. Also cuda only works for nivida gpus...
There does exist a module for nodejs, but it's only for 64bit version of windows, yet there exists cuda for 32bit version as well so only thing missing binding/extension for nodejs to cuda in c++. And There is no sign of documents anywhere on github or internet about that module. Last commits were like 1/2 year+ ago.
If it's all possible than it'd be very great. As nodejs would be able to use gpu for operations, putting it in the whole new level for web stuff, and other applications. Also given parallel nature of nodejs it fits perfectly with gpu's parallel nature.
Suppose there is no module that exists right now. What are my choices.
it's been done already by someone else: http://www.cs.cmu.edu/afs/cs/academic/class/15418-s12/www/competition/r2jitu.com/418/final_report.pdf
In short, GPU. js is a JavaScript acceleration library that can be used for general-purpose computations on GPUs using JavaScript. It supports browsers, Node. js and TypeScript.
Using the CUDA Toolkit you can accelerate your C or C++ applications by updating the computationally intensive portions of your code to run on GPUs. To accelerate your applications, you can call functions from drop-in libraries as well as develop custom applications using languages including C, C++, Fortran and Python.
Node. js can be used to create a variety of applications, including Command-Line Applications, Web Applications, Real-time Chat Applications, REST API Servers, and so on.
here is a binding.gyp file that will build a node extension using two source files hello.cpp, goodby.cu, and goodby1.cu
{
## for windows, be sure to do node-gyp rebuild -msvs_version=2013,
## and run under a msvs shell
## for all targets
'conditions': [
[ 'OS=="win"', {'variables': {'obj': 'obj'}},
{'variables': {'obj': 'o'}}]],
"targets": [
{
"target_name": "hello",
"sources": [ "hello.cpp", "goodby.cu", "goodby1.cu",],
'rules': [{
'extension': 'cu',
'inputs': ['<(RULE_INPUT_PATH)'],
'outputs':[ '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)'],
'conditions': [
[ 'OS=="win"',
{'rule_name': 'cuda on windows',
'message': "compile cuda file on windows",
'process_outputs_as_sources': 0,
'action': ['nvcc -c <(_inputs) -o <(_outputs)'],
},
{'rule_name': 'cuda on linux',
'message': "compile cuda file on linux",
'process_outputs_as_sources': 1,
'action': ['nvcc','-Xcompiler','-fpic','-c',
'<@(_inputs)','-o','<@(_outputs)'],
}]]}],
'conditions': [
[ 'OS=="mac"', {
'libraries': ['-framework CUDA'],
'include_dirs': ['/usr/local/include'],
'library_dirs': ['/usr/local/lib'],
}],
[ 'OS=="linux"', {
'libraries': ['-lcuda', '-lcudart'],
'include_dirs': ['/usr/local/include'],
'library_dirs': ['/usr/local/lib', '/usr/local/cuda/lib64'],
}],
[ 'OS=="win"', {
'conditions': [
['target_arch=="x64"',
{
'variables': { 'arch': 'x64' }
}, {
'variables': { 'arch': 'Win32' }
}
],
],
'variables': {
'cuda_root%': '$(CUDA_PATH)'
},
'libraries': [
'-l<(cuda_root)/lib/<(arch)/cuda.lib',
'-l<(cuda_root)/lib/<(arch)/cudart.lib',
],
"include_dirs": [
"<(cuda_root)/include",
],
}, {
"include_dirs": [
"/usr/local/cuda/include"
],
}]
]
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With