Skip to content

Commit bb37819

Browse files
committed
Address PR feedback
1 parent 9c27481 commit bb37819

File tree

8 files changed

+27
-15
lines changed

8 files changed

+27
-15
lines changed

.devops/nix/package.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ let
9393
rocmBuildInputs = with rocmPackages; [
9494
clr
9595
hipblas
96+
rocblas
9697
];
9798

9899
vulkanBuildInputs = [

.devops/rocm.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ FROM ${BASE_ROCM_DEV_CONTAINER} AS build
1212

1313
# Unless otherwise specified, we make a fat build.
1414
# List from https://github.com/ggerganov/llama.cpp/pull/1087#issuecomment-1682807878
15-
# This is mostly tied to HIP supported archs.
15+
# This is mostly tied to rocBLAS supported archs.
1616
# gfx803, gfx900, gfx1032, gfx1101, gfx1102,not officialy supported
1717
# gfx906 is deprecated
1818
#check https://rocm.docs.amd.com/projects/install-on-linux/en/docs-6.2.4/reference/system-requirements.html

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ jobs:
361361
id: depends
362362
run: |
363363
sudo apt-get update
364-
sudo apt-get install -y build-essential git cmake hipblas-dev
364+
sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
365365
366366
- name: Build with native CMake HIP support
367367
id: cmake_build
@@ -1125,7 +1125,10 @@ jobs:
11251125
-DGGML_HIP=ON `
11261126
-DGGML_RPC=ON
11271127
cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
1128+
md "build\bin\rocblas\library\"
11281129
cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
1130+
cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
1131+
cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
11291132
11301133
- name: Determine tag name
11311134
id: tag

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ endif # GGML_HIP_UMA
781781

782782
MK_LDFLAGS += -L$(ROCM_PATH)/lib -Wl,-rpath=$(ROCM_PATH)/lib
783783
MK_LDFLAGS += -L$(ROCM_PATH)/lib64 -Wl,-rpath=$(ROCM_PATH)/lib64
784-
MK_LDFLAGS += -lhipblas -lamdhip64
784+
MK_LDFLAGS += -lhipblas -lamdhip64 -lrocblas
785785

786786
HIPCC ?= $(CCACHE) $(ROCM_PATH)/bin/hipcc
787787

examples/main/main.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
#include "console.h"
44
#include "log.h"
55
#include "sampling.h"
6-
// vvv REMOVE BEFORE MERGING
7-
#include "llama-model.h"
8-
#include "llama-impl.h"
9-
// ^^^ REMOVE BEFORE MERGING
106
#include "llama.h"
117
#include "chat-template.hpp"
128

@@ -916,13 +912,6 @@ int main(int argc, char ** argv) {
916912
}
917913

918914
LOG("\n\n");
919-
// vvv REMOVE BEFORE MERGING
920-
for (auto * dev : model->devices) {
921-
size_t free, total; // NOLINT
922-
ggml_backend_dev_memory(dev, &free, &total);
923-
LLAMA_LOG_INFO("%s: using device %s (%s) - %zu MiB free\n", __func__, ggml_backend_dev_name(dev), ggml_backend_dev_description(dev), free/1024/1024);
924-
}
925-
// ^^^ REMOVE BEFORE MERGING
926915
common_perf_print(ctx, smpl);
927916

928917
common_sampler_free(smpl);

ggml/src/ggml-cuda/ggml-cuda.cu

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ static cudaError_t ggml_cuda_device_malloc(void ** ptr, size_t size, int device)
120120
}
121121

122122
static ggml_cuda_device_info ggml_cuda_init() {
123+
#ifdef __HIP_PLATFORM_AMD__
124+
// Workaround for a rocBLAS bug when using multiple graphics cards:
125+
// https://github.com/ROCmSoftwarePlatform/rocBLAS/issues/1346
126+
{
127+
char version_string[64];
128+
version_string[0] = '\0';
129+
const rocblas_status status = rocblas_get_version_string(version_string, sizeof(version_string));
130+
if (status != rocblas_status_success || version_string[0] < '4') {
131+
rocblas_initialize();
132+
CUDA_CHECK(cudaDeviceSynchronize());
133+
}
134+
}
135+
#endif
136+
123137
ggml_cuda_device_info info = {};
124138

125139
cudaError_t err = cudaGetDeviceCount(&info.device_count);

ggml/src/ggml-cuda/vendors/hip.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <hipblas/hipblas.h>
55
#include <hip/hip_fp16.h>
66
#include <hip/hip_bfloat16.h>
7+
#ifdef __HIP_PLATFORM_AMD__
8+
// for rocblas_initialize()
9+
#include "rocblas/rocblas.h"
10+
#endif // __HIP_PLATFORM_AMD__
711
#define CUBLAS_COMPUTE_16F HIPBLAS_R_16F
812
#define CUBLAS_COMPUTE_32F HIPBLAS_R_32F
913
#define CUBLAS_COMPUTE_32F_FAST_16F HIPBLAS_R_32F

ggml/src/ggml-hip/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ endif()
3838

3939
find_package(hip REQUIRED)
4040
find_package(hipblas REQUIRED)
41+
find_package(rocblas REQUIRED)
4142

4243
message(STATUS "HIP and hipBLAS found")
4344

@@ -110,4 +111,4 @@ if (GGML_STATIC)
110111
message(FATAL_ERROR "Static linking not supported for HIP/ROCm")
111112
endif()
112113

113-
target_link_libraries(ggml-hip PRIVATE ggml-base hip::host roc::hipblas)
114+
target_link_libraries(ggml-hip PRIVATE ggml-base hip::host roc::rocblas roc::hipblas)

0 commit comments

Comments
 (0)