Skip to content

Commit

Permalink
fix uses of GGML_USE_CUBLAS in tests and examples (#879)
Browse files Browse the repository at this point in the history
* fix uses of GGML_USE_CUBLAS in tests and examples

* fix ci/run.sh

ggml-ci
  • Loading branch information
slaren authored Jul 2, 2024
1 parent 84376bd commit e3b3846
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SRC=`pwd`
CMAKE_EXTRA=""

if [ ! -z ${GG_BUILD_CUDA} ]; then
CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_CUBLAS=ON"
CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_CUDA=ON"
fi

if [ ! -z ${GG_BUILD_METAL} ]; then
Expand Down
12 changes: 0 additions & 12 deletions examples/gpt-2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,3 @@ target_link_libraries(${TEST_TARGET} PRIVATE ggml common common-ggml)
set(TEST_TARGET gpt-2-batched)
add_executable(${TEST_TARGET} main-batched.cpp)
target_link_libraries(${TEST_TARGET} PRIVATE ggml common common-ggml)


#
# For GPU offloading

if (GGML_CUBLAS)
add_compile_definitions(GGML_USE_CUBLAS)
endif()

if (GGML_METAL)
add_compile_definitions(GGML_USE_METAL)
endif()
4 changes: 2 additions & 2 deletions tests/test-arange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ggml-alloc.h"
#include "ggml-backend.h"

#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
#include "ggml-cuda.h"
#endif

Expand All @@ -22,7 +22,7 @@ int main(int /*argc*/, const char** /*argv*/) {
ggml_backend_t backend = NULL;
//ggml_backend_buffer_t buffer;

#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
if (use_gpu) {
fprintf(stderr, "%s: using CUDA backend\n", __func__);
backend = ggml_backend_cuda_init(0);
Expand Down
6 changes: 2 additions & 4 deletions tests/test-conv1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
#include "ggml-alloc.h"
#include "ggml-backend.h"

// #define GGML_USE_CUBLAS

#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
#include "ggml-cuda.h"
#endif

Expand Down Expand Up @@ -75,7 +73,7 @@ void load_model(test_model & model, bool use_gpu = false) {
};

// initialize the backend
#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
if (use_gpu) {
fprintf(stderr, "%s: using CUDA backend\n", __func__);
model.backend = ggml_backend_cuda_init(0);
Expand Down
6 changes: 2 additions & 4 deletions tests/test-conv2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
#include "ggml-alloc.h"
#include "ggml-backend.h"

// #define GGML_USE_CUBLAS

#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
#include "ggml-cuda.h"
#endif

Expand Down Expand Up @@ -75,7 +73,7 @@ void load_model(test_model & model, bool use_gpu = false) {
};

// initialize the backend
#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
if (use_gpu) {
fprintf(stderr, "%s: using CUDA backend\n", __func__);
model.backend = ggml_backend_cuda_init(0);
Expand Down
6 changes: 2 additions & 4 deletions tests/test-mul-mat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
#include "ggml-alloc.h"
#include "ggml-backend.h"

//#define GGML_USE_CUBLAS // uncomment this to use cuda backend, make sure build ggml lib with GGML_CUBLAS=ON

#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
#include "ggml-cuda.h"
#endif

Expand Down Expand Up @@ -48,7 +46,7 @@ void load_model(test_model & model, float* a, float* b, int M, int N, int K, boo
};

// initialize the backend
#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
if (use_gpu) {
fprintf(stderr, "%s: using CUDA backend\n", __func__);
model.backend = ggml_backend_cuda_init(0);
Expand Down
4 changes: 2 additions & 2 deletions tests/test-timestep_embedding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ggml-alloc.h"
#include "ggml-backend.h"

#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
#include "ggml-cuda.h"
#endif

Expand Down Expand Up @@ -96,7 +96,7 @@ int main(int argc, const char** argv) {
ggml_backend_t backend = NULL;
ggml_backend_buffer_t params_buffer = NULL;

#ifdef GGML_USE_CUBLAS
#ifdef GGML_USE_CUDA
if (use_gpu) {
fprintf(stderr, "%s: using CUDA backend\n", __func__);
backend = ggml_backend_cuda_init(0);
Expand Down

0 comments on commit e3b3846

Please sign in to comment.