ggerganov commited on
Commit
2831df8
·
unverified ·
1 Parent(s): cd6e534

whisper : disable CUDA mel + fix FFMPEG

Browse files
examples/CMakeLists.txt CHANGED
@@ -11,7 +11,7 @@ if (WHISPER_SDL2)
11
  string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
12
 
13
  message(STATUS "SDL2_INCLUDE_DIRS = ${SDL2_INCLUDE_DIRS}")
14
- message(STATUS "SDL2_LIBRARIES = ${SDL2_LIBRARIES}")
15
  endif()
16
 
17
  if (WHISPER_CLBLAST)
@@ -22,10 +22,35 @@ endif()
22
 
23
  set(TARGET common)
24
 
 
 
25
  if (WHISPER_FFMPEG)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  set(COMMON_SOURCES_FFMPEG ffmpeg-transcode.cpp)
27
  endif()
28
 
 
29
  add_library(${TARGET} STATIC
30
  common.h
31
  common.cpp
@@ -38,7 +63,7 @@ add_library(${TARGET} STATIC
38
 
39
  include(DefaultTargetOptions)
40
 
41
- target_link_libraries(${TARGET} PRIVATE whisper)
42
 
43
  set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
44
  set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
@@ -55,8 +80,8 @@ if (WHISPER_SDL2)
55
 
56
  include(DefaultTargetOptions)
57
 
58
- target_include_directories(${TARGET} PUBLIC ${SDL2_INCLUDE_DIRS})
59
- target_link_libraries(${TARGET} PRIVATE ${SDL2_LIBRARIES})
60
 
61
  set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
62
  set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
@@ -108,7 +133,7 @@ if (WHISPER_SDL2)
108
  set_target_properties(talk-llama PROPERTIES FOLDER "examples")
109
  add_subdirectory(lsp)
110
  set_target_properties(lsp PROPERTIES FOLDER "examples")
111
- if (LLAMA_SYCL)
112
  add_subdirectory(sycl)
113
  set_target_properties(sycl PROPERTIES FOLDER "examples")
114
  endif()
 
11
  string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
12
 
13
  message(STATUS "SDL2_INCLUDE_DIRS = ${SDL2_INCLUDE_DIRS}")
14
+ message(STATUS "SDL2_LIBRARIES = ${SDL2_LIBRARIES}")
15
  endif()
16
 
17
  if (WHISPER_CLBLAST)
 
22
 
23
  set(TARGET common)
24
 
25
+ unset(COMMON_EXTRA_LIBS)
26
+
27
  if (WHISPER_FFMPEG)
28
+ # As of cmake 3.27, there is no official cmake support for FindFFmpeg.
29
+ # Consequnelty we added a FindFFmpeg.cmake script the cmake subfolder:
30
+ # whisper.cpp does not need the full ffmpeg libs, just AVFORMAT AVCODEC AVUTIL SWRESAMPLE
31
+ # libswresample performs highly optimized audio resampling, rematrixing and sample format conversion operations
32
+ # libavcodec provides a generic encoding/decoding framework and contains multiple decoders and encoders for audio, video and subtitle streams, and several bitstream filters.
33
+ # libavformat provides a generic framework for multiplexing and demultiplexing (muxing and demuxing) audio, video and subtitle streams.
34
+ find_package(FFmpeg REQUIRED)
35
+
36
+ if (NOT ${FFMPEG_FOUND})
37
+ message(FATAL_ERROR "Cannot find ffmpeg libs/headers")
38
+ endif()
39
+
40
+ message(STATUS "Found ffmpeg libs: ${FFMPEG_LIBRARIES}")
41
+ message(STATUS "Found ffmpeg headers in: ${FFMPEG_INCLUDE_DIRS}")
42
+ message(STATUS "ffmpeg definitions: ${FFMPEG_DEFINITIONS}")
43
+ message(STATUS "Found avformat ${AVFORMAT_VERSION}")
44
+
45
+ include_directories(${FFMPEG_INCLUDE_DIRS})
46
+ add_compile_definitions(WHISPER_FFMPEG)
47
+
48
+ list(APPEND COMMON_EXTRA_LIBS ${FFMPEG_LIBRARIES})
49
+
50
  set(COMMON_SOURCES_FFMPEG ffmpeg-transcode.cpp)
51
  endif()
52
 
53
+
54
  add_library(${TARGET} STATIC
55
  common.h
56
  common.cpp
 
63
 
64
  include(DefaultTargetOptions)
65
 
66
+ target_link_libraries(${TARGET} PRIVATE whisper ${COMMON_EXTRA_LIBS})
67
 
68
  set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
69
  set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
 
80
 
81
  include(DefaultTargetOptions)
82
 
83
+ target_include_directories(${TARGET} PUBLIC ${SDL2_INCLUDE_DIRS})
84
+ target_link_libraries (${TARGET} PRIVATE ${SDL2_LIBRARIES})
85
 
86
  set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
87
  set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
 
133
  set_target_properties(talk-llama PROPERTIES FOLDER "examples")
134
  add_subdirectory(lsp)
135
  set_target_properties(lsp PROPERTIES FOLDER "examples")
136
+ if (GGML_SYCL)
137
  add_subdirectory(sycl)
138
  set_target_properties(sycl PROPERTIES FOLDER "examples")
139
  endif()
examples/common.cpp CHANGED
@@ -30,7 +30,7 @@ extern bool ffmpeg_decode_audio(const std::string & ifname, std::vector<uint8_t>
30
  #endif
31
 
32
  // Function to check if the next argument exists
33
- std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) {
34
  if (i + 1 < argc && argv[i + 1][0] != '-') {
35
  return argv[++i];
36
  } else {
@@ -346,7 +346,7 @@ std::vector<gpt_vocab::id> gpt_tokenize(const gpt_vocab & vocab, const std::stri
346
  return tokens;
347
  }
348
 
349
- std::vector<gpt_vocab::id> parse_tokens_from_string(const std::string& input, char delimiter) {
350
  std::vector<gpt_vocab::id> output;
351
  std::stringstream ss(input);
352
  std::string token;
@@ -358,7 +358,7 @@ std::vector<gpt_vocab::id> parse_tokens_from_string(const std::string& input, ch
358
  return output;
359
  }
360
 
361
- std::map<std::string, std::vector<gpt_vocab::id>> extract_tests_from_file(const std::string & fpath_test){
362
  if (fpath_test.empty()){
363
  fprintf(stderr, "%s : No test file found.\n", __func__);
364
  return std::map<std::string, std::vector<gpt_vocab::id>>();
 
30
  #endif
31
 
32
  // Function to check if the next argument exists
33
+ static std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) {
34
  if (i + 1 < argc && argv[i + 1][0] != '-') {
35
  return argv[++i];
36
  } else {
 
346
  return tokens;
347
  }
348
 
349
+ static std::vector<gpt_vocab::id> parse_tokens_from_string(const std::string& input, char delimiter) {
350
  std::vector<gpt_vocab::id> output;
351
  std::stringstream ss(input);
352
  std::string token;
 
358
  return output;
359
  }
360
 
361
+ static std::map<std::string, std::vector<gpt_vocab::id>> extract_tests_from_file(const std::string & fpath_test){
362
  if (fpath_test.empty()){
363
  fprintf(stderr, "%s : No test file found.\n", __func__);
364
  return std::map<std::string, std::vector<gpt_vocab::id>>();
scripts/build-info.sh CHANGED
@@ -24,7 +24,7 @@ if out=$($CC -dumpmachine); then
24
  build_target=$out
25
  fi
26
 
27
- echo "int LLAMA_BUILD_NUMBER = ${build_number};"
28
- echo "char const *LLAMA_COMMIT = \"${build_commit}\";"
29
- echo "char const *LLAMA_COMPILER = \"${build_compiler}\";"
30
- echo "char const *LLAMA_BUILD_TARGET = \"${build_target}\";"
 
24
  build_target=$out
25
  fi
26
 
27
+ echo "int WHISPER_BUILD_NUMBER = ${build_number};"
28
+ echo "char const *WHISPER_COMMIT = \"${build_commit}\";"
29
+ echo "char const *WHISPER_COMPILER = \"${build_compiler}\";"
30
+ echo "char const *WHISPER_BUILD_TARGET = \"${build_target}\";"
src/CMakeLists.txt CHANGED
@@ -77,27 +77,27 @@ if (WHISPER_OPENVINO)
77
  set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
78
  endif()
79
 
80
- if (GGML_CUDA)
81
- cmake_minimum_required(VERSION 3.18) # for CMAKE_CUDA_ARCHITECTURES
82
-
83
- find_package(CUDAToolkit)
84
- if (CUDAToolkit_FOUND)
85
- message(STATUS "CUDA found")
86
-
87
- if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
88
- # 52 == lowest CUDA 12 standard
89
- # 60 == f16 CUDA intrinsics
90
- # 61 == integer CUDA intrinsics
91
- # 70 == compute capability at which unrolling a loop in mul_mat_q kernels is faster
92
- set(CMAKE_CUDA_ARCHITECTURES "52;61;70") # lowest CUDA 12 standard + lowest for integer intrinsics
93
- endif()
94
- message(STATUS "Using CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")
95
-
96
- enable_language(CUDA)
97
- else()
98
- message(WARNING "CUDA not found")
99
- endif()
100
- endif()
101
 
102
  # whisper
103
 
@@ -107,11 +107,12 @@ add_library(whisper
107
  whisper-mel.hpp
108
  )
109
 
110
- if (GGML_CUDA)
111
- target_sources(whisper PRIVATE whisper-mel-cuda.cu)
112
-
113
- target_link_libraries(whisper PRIVATE CUDA::cufft)
114
- endif()
 
115
 
116
  # Set the version numbers
117
  set_target_properties(whisper PROPERTIES
 
77
  set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
78
  endif()
79
 
80
+ #if (GGML_CUDA)
81
+ # cmake_minimum_required(VERSION 3.18) # for CMAKE_CUDA_ARCHITECTURES
82
+ #
83
+ # find_package(CUDAToolkit)
84
+ # if (CUDAToolkit_FOUND)
85
+ # message(STATUS "CUDA found")
86
+ #
87
+ # if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
88
+ # # 52 == lowest CUDA 12 standard
89
+ # # 60 == f16 CUDA intrinsics
90
+ # # 61 == integer CUDA intrinsics
91
+ # # 70 == compute capability at which unrolling a loop in mul_mat_q kernels is faster
92
+ # set(CMAKE_CUDA_ARCHITECTURES "52;61;70") # lowest CUDA 12 standard + lowest for integer intrinsics
93
+ # endif()
94
+ # message(STATUS "Using CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")
95
+ #
96
+ # enable_language(CUDA)
97
+ # else()
98
+ # message(WARNING "CUDA not found")
99
+ # endif()
100
+ #endif()
101
 
102
  # whisper
103
 
 
107
  whisper-mel.hpp
108
  )
109
 
110
+ # TODO: disabled because it relies on ggml internals that are no longer accessible (ggml-backend-impl.h, ggml-cuda/common.cuh, ..)
111
+ #if (GGML_CUDA)
112
+ # target_sources(whisper PRIVATE whisper-mel-cuda.cu)
113
+ #
114
+ # target_link_libraries(whisper PRIVATE CUDA::cufft)
115
+ #endif()
116
 
117
  # Set the version numbers
118
  set_target_properties(whisper PROPERTIES
src/whisper-mel-cuda.cu CHANGED
@@ -2,8 +2,7 @@
2
  #include "whisper-mel-cuda.hpp"
3
  #include "whisper.h"
4
 
5
- #include <ggml-cuda/common.cuh>
6
- #include <ggml-backend-impl.h>
7
 
8
  #include <cuda.h>
9
  #include <cuda_runtime.h>
 
2
  #include "whisper-mel-cuda.hpp"
3
  #include "whisper.h"
4
 
5
+ #include <ggml-backend.h>
 
6
 
7
  #include <cuda.h>
8
  #include <cuda_runtime.h>
src/whisper.cpp CHANGED
@@ -3215,7 +3215,9 @@ struct mel_calc_cpu : public whisper_mel_calc {
3215
  }
3216
 
3217
  static whisper_mel_calc * whisper_mel_calc_create(ggml_backend_t backend, const whisper_filters & filters) {
3218
- #if defined(GGML_USE_CUDA) && !defined(GGML_USE_HIPBLAS)
 
 
3219
  if (ggml_backend_is_cuda(backend)) {
3220
  auto ret = whisper_mel_calc_create_cuda(backend, filters);
3221
  if (ret) {
 
3215
  }
3216
 
3217
  static whisper_mel_calc * whisper_mel_calc_create(ggml_backend_t backend, const whisper_filters & filters) {
3218
+ // TODO: disabled because it relies on ggml internals that are no longer accessible (ggml-backend-impl.h, ggml-cuda/common.cuh, ..)
3219
+ //#if defined(GGML_USE_CUDA) && !defined(GGML_USE_HIPBLAS)
3220
+ #if 0
3221
  if (ggml_backend_is_cuda(backend)) {
3222
  auto ret = whisper_mel_calc_create_cuda(backend, filters);
3223
  if (ret) {