Code Monkey home page Code Monkey logo

Comments (3)

saul-jb avatar saul-jb commented on May 22, 2024 1

@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.

giladgd avatar giladgd commented on May 22, 2024

@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.

pankaj-kumar34 avatar pankaj-kumar34 commented on May 22, 2024

It's working as expected.

from node-llama-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.