Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit e0bca57

Browse files
authored
Merge pull request #44 from janhq/36-build-and-run-on-linux-amd64-with-cuda-enabled
CUDA support for Nitro on amd64 - linux
2 parents 529ec15 + 5d50b53 commit e0bca57

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ set(OPENSSL_USE_STATIC_LIBS TRUE)
2020
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2121
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build_deps/_install) # This is the critical line for installing another package
2222

23+
if (LLAMA_CUBLAS)
24+
cmake_minimum_required(VERSION 3.17)
25+
26+
find_package(CUDAToolkit)
27+
if (CUDAToolkit_FOUND)
28+
message(STATUS "cuBLAS found")
29+
add_compile_definitions(GGML_USE_CUBLAS)
30+
endif()
31+
endif()
32+
2333
add_subdirectory(llama.cpp)
2434
add_executable(${PROJECT_NAME} main.cc)
2535

controllers/llamaCPP.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <chrono>
55
#include <cstring>
66
#include <thread>
7+
#include <regex>
8+
79
std::string create_return_json(const std::string &id, const std::string &model,
810
const std::string &content,
911
Json::Value finish_reason = Json::Value()) {

controllers/llamaCPP.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "llama.h"
88
#include "build-info.h"
99
#include "grammar-parser.h"
10+
#include <regex>
1011

1112
#ifndef NDEBUG
1213
// crash the server in debug mode, otherwise send an http 500 error
@@ -1385,6 +1386,10 @@ class llamaCPP : public drogon::HttpSimpleController<llamaCPP> {
13851386
params.model = conf["llama_model_path"].asString();
13861387
params.n_gpu_layers = conf["ngl"].asInt();
13871388
params.n_ctx = conf["ctx_len"].asInt();
1389+
#ifdef GGML_USE_CUBLAS
1390+
LOG_INFO << "Setting up GGML CUBLAS PARAMS";
1391+
params.mul_mat_q = false;
1392+
#endif // GGML_USE_CUBLAS
13881393
if (params.model_alias == "unknown") {
13891394
params.model_alias = params.model;
13901395
}

controllers/nitro_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ inline void nitro_logo(){
5050
std::cout << resetColor << c;
5151
colorIndex = 0;
5252
} else {
53-
std::cout << rainbowColors[colorIndex % 6] << c;
53+
std::cout << rainbowColors[colorIndex % 2] << c;
5454
colorIndex++;
5555
}
5656
}

0 commit comments

Comments
 (0)