Comments (3)
@pankaj-kumar34 I was having issues with CUDA support as well, you need to enable the cuda flag when downloading/building:
npx node-llama-cpp download --cuda
It would compile successfully but I would get a warning saying something about cuBLAS
not being detected, so to fix that I installed the CUDA toolkit: https://developer.nvidia.com/cuda-downloads
Then when I compiled it would say -- cuBLAS found
but I would get an error:
CMake Error at ~/.local/lib/python3.10/site-packages/cmake/data/share/cmake-3.26/Modules/CMakeDetermineCUDACompiler.cmake:603 (message):
Failed to detect a default CUDA architecture.
Compiler output:
Call Stack (most recent call first):
llama.cpp/CMakeLists.txt:285 (enable_language)
-- Configuring incomplete, errors occurred!
To fix this you need to set environment to the directory:
export CUDACXX=/usr/local/cuda-12.2/bin/nvcc
Note that your CUDA version may vary. Once this is done you can run the download command again and it should be successful.
Then when defining the Llama model enable gpuLayers:
const model = new LlamaModel({
modelPath,
gpuLayers: 64 // Or whatever makes sense.
});
When running you should be able to see an output similar to:
llm_load_tensors: ggml ctx size = 0.09 MB
llm_load_tensors: using CUDA for GPU acceleration
llm_load_tensors: mem required = 41.11 MB (+ 2048.00 MB per state)
llm_load_tensors: offloading 32 repeating layers to GPU
llm_load_tensors: offloading non-repeating layers to GPU
llm_load_tensors: offloading v cache to GPU
llm_load_tensors: offloading k cache to GPU
llm_load_tensors: offloaded 35/35 layers to GPU
llm_load_tensors: VRAM used: 4741 MB
You can monitor GPU usage with:
watch -d nvidia-smi
from node-llama-cpp.
@pankaj-kumar34 There are many environment variables that you can set during the build and runtime to configure the CUDA support of llama.cpp
; you can find more details here.
I do not have an Nvidia GPU, so I can't test how well (if at all) the CUDA support works or provide better documentation for this process.
You're welcome to play around with the code to try making it work and share your conclusions here or open a PR to improve the CUDA support of this node module.
from node-llama-cpp.
It's working as expected.
from node-llama-cpp.
Related Issues (20)
- langchain.js - throws error "disposed undefined" HOT 1
- feat: max GPU layers param HOT 1
- Issue with Webpack Compilation HOT 8
- Could not find a KV slot HOT 6
- Add llama.cpp build number as info HOT 3
- CLI does not work with Bun HOT 1
- ESM support? HOT 3
- Bun support HOT 1
- Fail to run in docker image HOT 6
- Grammars folder not found HOT 4
- EOS token is not detected properly for some models after upgrading to v3.0 HOT 2
- Support file based prompt caching HOT 9
- Inconsistent tokenization/encoding HOT 3
- kv slot none HOT 2
- Error: ENOENT: no such file or directory, open undefinedbinariesGithubRelease.json HOT 9
- Cannot instantiate new LlamaModel bc class constructor was changed to private in beta HOT 3
- Function call error HOT 2
- Need help, Can't get CUDA support to work HOT 2
- Support for Llama 3 HOT 1
- Integrate TS compiler to parse types to grammar HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-llama-cpp.