ROCm support

#667 got closed during a bad rebase attempt. This should be just about the minimum I can come up with to use build tags to switch between ROCm and CUDA, as well as docs for how to build it. The existing dockerfiles are updated so they do not break.
Please let me know @jmorganca @mxyng @BruceMacD if you'd like this in a different approach or something, or if you don't want to do this. Closes #738. Will post test results for GGML and GGUF files.

Example build instructions:
AMDGPU_TARGETS='gfx1100;gfx1030;gfx906;gfx900' GPU_TARGETS='gfx1100;gfx1030;gfx906;gfx900' ROCM_PATH=/opt/rocm CLBlast_DIR=/usr/lib/cmake/CLBlast go generate -tags rocm ./...

then
go build -tags rocm

GGUF (uses ROCm for acceleration, RX6950XT)  mistral-7b-q8:
llama_print_timings:      sample time =   171.71 ms /   343 runs   (    0.50 ms per token,  1997.54 tokens per second)
llama_print_timings: prompt eval time =    67.25 ms /     2 tokens (   33.63 ms per token,    29.74 tokens per second)
llama_print_timings:        eval time =  6391.72 ms /   342 runs   (   18.69 ms per token,    53.51 tokens per second)

GGML (legacy, uses CLBlast for acceleration, RX6950XT) llama-7b-q2k:
llama_print_timings:      sample time =    48.79 ms /    87 runs   (    0.56 ms per token,  1783.19 tokens per second)
llama_print_timings: prompt eval time =  1712.33 ms /     2 tokens (  856.17 ms per token,     1.17 tokens per second)
llama_print_timings:        eval time =  2790.58 ms /    86 runs   (   32.45 ms per token,    30.82 tokens per second)

Hi @65a, sorry for not jumping in on the other PR sooner. Will take a look at this, and thank you so much for taking all of the time to give adding ROCm a go!

@jmorganca no worries, I'm using it locally so I have to keep going regardless :)

Hey @65a, I have been monitoring #667 and will continue to do so with this PR. Thank you for your time, regardless if you're using it locally yourself or not - it's much appreciated!

just wanted to say, your repo built flawlessly and is working great on my 6700XT

actually, doesn't seem to work with mistral 7B, guessing it's because it's using a different backed or something in ollama?

@TheScreechingBagel you can see above I tested with Mistral-7b. Likely you are falling back to CPU, there will be an error in your logs, but perhaps we can continue the conversation in #738

Rebased on HEAD and incorporated changes, testing again

ROCm: 7900XTX GGUF (Mistral 7b q8):
llama_print_timings:      sample time =      58.70 ms /   422 runs   (    0.14 ms per token,  7189.34 tokens per second)
llama_print_timings: prompt eval time =      64.29 ms /     3 tokens (   21.43 ms per token,    46.66 tokens per second)
llama_print_timings:        eval time =    5419.35 ms /   421 runs   (   12.87 ms per token,    77.68 tokens per second)

OpenCL: 7900XTX GGML (Llama-7b q2k):
llama_print_timings:      sample time =    58.91 ms /   102 runs   (    0.58 ms per token,  1731.37 tokens per second)
llama_print_timings: prompt eval time =   983.92 ms /     3 tokens (  327.97 ms per token,     3.05 tokens per second)
llama_print_timings:        eval time =  3137.99 ms /   101 runs   (   31.07 ms per token,    32.19 tokens per second)

Seems to work, and ready for review @jmorganca

We should be able to test this now. I ordered a Radeon 7900 XTX  and it just came in, but I still have to pull a machine apart and get it working. Thanks for your patience!

@pdevine sounds good! I can try syncing to head and rebuilding to make sure things are still in a good state.

Seems like it's working still (7900XTX, Mistral-7b quantized to q8):
llama_print_timings:        load time =   60239.98 ms
llama_print_timings:      sample time =       1.74 ms /    13 runs   (    0.13 ms per token,  7475.56 tokens per second)
llama_print_timings: prompt eval time =      65.56 ms /     7 tokens (    9.37 ms per token,   106.77 tokens per second)
llama_print_timings:        eval time =     153.20 ms /    12 runs   (   12.77 ms per token,    78.33 tokens per second)
llama_print_timings:       total time =     221.35 ms

Tested this on my Vega 56 on Linux, with llama2 (7b, 13b) and mistral, works! Thanks a lot.
How do run this benchmark you did? I'm curious about how my old card stacks up.

Hi I'm currently trying to run this with my 6700XT.
is there a way to specify a make -j24 when running go generate I have a bunch of extra cores but it doesn't look like theyre being used lol.
also it looks like its building a lot of ggml cuda code. can we turn that off somehow?
-- Generating done (0.1s)
-- Build files have been written to: /home/julian/opt/ollama/llm/llama.cpp/gguf/build/rocm
[  6%] Building CXX object CMakeFiles/ggml-rocm.dir/ggml-cuda.cu.o
/home/julian/opt/ollama/llm/llama.cpp/gguf/ggml-cuda.cu:4001:5: warning: loop not unrolled: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transf
ormation ordering [-Wpass-failed=transform-warning]
   ...

@K1ngjulien The "cuda" code is actually hipified for ROCm, and it's compiled with your graphics device for several targets (hence slow). I'll leave more parallelism for the next PR, if it's possible, though if it's bottlenecked on compiling the "cuda" (actually ROCm) kernels, it might help to just override AMDGPU_TARGETS and friends to only your card and trade portability for compile time locally.

Rebased on HEAD and made sure nVidia behavior matches it by copying new changes in CheckVRAM and generators

@lu4p the benchmark is in the logs for wherever you are running ollama serve (maybe a terminal, or maybe a systemd log or something). I also have a similar gfx906 card (Mi60-like ebay card), should be much faster than a CPU or iGPU.

My card a lot slower, than yours by  factor 10 or so.
llama_print_timings:        load time =    1052.60 ms
llama_print_timings:      sample time =       7.35 ms /    26 runs   (    0.28 ms per token,  3535.97 tokens per second)
llama_print_timings: prompt eval time =    2107.46 ms /    25 tokens (   84.30 ms per token,    11.86 tokens per second)
llama_print_timings:        eval time =    2796.51 ms /    25 runs   (  111.86 ms per token,     8.94 tokens per second)
llama_print_timings:       total time =    4917.49 ms

My cpu ryzen 5 3600 for reference, around 30% slower.
llama_print_timings:        load time =    3325.86 ms
llama_print_timings:      sample time =       4.73 ms /    16 runs   (    0.30 ms per token,  3382.66 tokens per second)
llama_print_timings: prompt eval time =    2452.26 ms /    21 tokens (  116.77 ms per token,     8.56 tokens per second)
llama_print_timings:        eval time =    2442.76 ms /    15 runs   (  162.85 ms per token,     6.14 tokens per second)
llama_print_timings:       total time =    4903.49 ms

Is this a problem? (output from ollama serve)
2023/11/10 04:10:18 accelerator_rocm.go:71: ROCm presenting 0 bytes of available VRAM on device ""

I'd prefer to provide support in #738, if that's all right. I would need the full log from ollama serve, but I suspect there's an error and ollama is falling back to CPU.

@lu4p I put some more validation around the error case, hopefully we can figure out what the error you have is on #738, but it will now return "no GPU" if the total parsed VRAM is 0, and log the cards it finds and the amount of free VRAM in MiB.

Fixed typo in generate_linux_rocm.go

Finally managed a successful test on 6700S again:
llama_print_timings:      sample time =      45.18 ms /   422 runs   (    0.11 ms per token,  9339.80 tokens per second)
llama_print_timings: prompt eval time =     164.41 ms /     3 tokens (   54.80 ms per token,    18.25 tokens per second)
llama_print_timings:        eval time =   13110.55 ms /   421 runs   (   31.14 ms per token,    32.11 tokens per second)

HIP_VISIBLE_DEVICES=0 needs to be set in environment on devices with AMD iGPU+dGPU it appears.

hmm looks like its detecting the gpu correctly, but then something goes wrong and it falls back to the cpu:
2023/11/10 10:42:55 routes.go:696: Listening on <IP_ADDRESS>:11434 (version 0.0.0)                                                                                [378/1748]
2023/11/10 10:42:55 accelerator_rocm.go:66: ROCm found 11462 MiB of available VRAM on device "card0"
2023/11/10 10:42:55 accelerator_rocm.go:76: ROCm selecting device "card0"
[GIN] 2023/11/10 - 10:43:15 | 200 |        25.9µs |       <IP_ADDRESS> | HEAD     "/"
[GIN] 2023/11/10 - 10:43:15 | 200 |     362.294µs |       <IP_ADDRESS> | POST     "/api/show"
2023/11/10 10:43:15 accelerator_rocm.go:66: ROCm found 11462 MiB of available VRAM on device "card0"
2023/11/10 10:43:15 accelerator_rocm.go:76: ROCm selecting device "card0"
2023/11/10 10:43:15 llama.go:254: 11462 MB VRAM available, loading up to 75 GPU layers
2023/11/10 10:43:15 llama.go:379: starting llama runner
2023/11/10 10:43:15 llama.go:437: waiting for llama runner to start responding

rocBLAS error: Cannot read /opt/rocm/lib/rocblas/library/TensileLibrary.dat: Illegal seek
2023/11/10 10:43:15 llama.go:394: Cannot read /opt/rocm/lib/rocblas/library/TensileLibrary.dat: Illegal seek
2023/11/10 10:43:15 llama.go:402: error starting llama runner: llama runner process has terminated
2023/11/10 10:43:15 llama.go:468: llama runner stopped successfully
2023/11/10 10:43:15 llama.go:379: starting llama runner
2023/11/10 10:43:15 llama.go:437: waiting for llama runner to start responding
{"timestamp":1699609395,"level":"WARNING","function":"server_params_parse","line":871,"message":"Not compiled with GPU offload support, --n-gpu-layers option will be ignored. See main README.md for information on enabling GPU BLAS support",
"n_gpu_layers":-1}
{"timestamp":1699609395,"level":"INFO","function":"main","line":1323,"message":"build info","build":1412,"commit":"9e70cc0"}
{"timestamp":1699609395,"level":"INFO","function":"main","line":1325,"message":"system info","n_threads":12,"n_threads_batch":-1,"total_threads":24,"system_info":"AVX = 1 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0
 | NEON = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | "}
llama_model_loader: loaded meta data with 19 key-value pairs and 291 tensors from /home/julian/.ollama/models/blobs/sha256:22f7f8ef5f4c791c1b03d7eb414399294764d7cc82c7e94aa81a1feb80a983a2 (version GGUF V2 (latest))
llama_model_loader: - tensor    0:                token_embd.weight q4_0     [  4096, 32000,     1,     1 ]

any ideas?

GOT IT!
from this comment.
my 6700xt seems to not officially be supported yet but overriding the version makes it work anyway lol.
HSA_OVERRIDE_GFX_VERSION=10.3.0 ROCM_PATH=/opt/rocm ./ollama serve
on Ryzen 9 5900X:
llama_print_timings:        load time =     751.10 ms
llama_print_timings:      sample time =      34.37 ms /   242 runs   (    0.14 ms per token,  7041.43 tokens per second)
llama_print_timings: prompt eval time =    1007.78 ms /    26 tokens (   38.76 ms per token,    25.80 tokens per second)
llama_print_timings:        eval time =   24948.13 ms /   241 runs   (  103.52 ms per token,     9.66 tokens per second)
llama_print_timings:       total time =   26043.89 ms

with this change:

llama_print_timings:        load time =    1556.60 ms
llama_print_timings:      sample time =      14.41 ms /   121 runs   (    0.12 ms per token,  8396.36 tokens per second)
llama_print_timings: prompt eval time =     104.54 ms /    25 tokens (    4.18 ms per token,   239.13 tokens per second)
llama_print_timings:        eval time =    2132.34 ms /   120 runs   (   17.77 ms per token,    56.28 tokens per second)
llama_print_timings:       total time =    2259.01 ms

so we went from 25t/s to 240t/s, id call that a win :tada:

Minor code cleanup to make the way runners are accumulated (though I'm not sure CPU fallback is ever good UX...out of scope for this change). It would be great to have someone test the cuda side of this change as well, I only made sure it compiles, as I don't have any nvidia cards.

Sync to HEAD, tested 6700S (dGPU) again on a clean checkout with a mistral-7b q5k quant:
llama_print_timings:      sample time =      20.29 ms /   191 runs   (    0.11 ms per token,  9413.50 tokens per second)
llama_print_timings: prompt eval time =     163.72 ms /     2 tokens (   81.86 ms per token,    12.22 tokens per second)
llama_print_timings:        eval time =    5803.15 ms /   190 runs   (   30.54 ms per token,    32.74 tokens per second)

Tested again with 7900XTX (a mistral-7b, not quantized/f16):
llama_print_timings:      sample time =      36.39 ms /   258 runs   (    0.14 ms per token,  7089.08 tokens per second)
llama_print_timings: prompt eval time =      58.05 ms /     3 tokens (   19.35 ms per token,    51.68 tokens per second)
llama_print_timings:        eval time =    6778.75 ms /   257 runs   (   26.38 ms per token,    37.91 tokens per second)

retested OpenCL on the same card (ggml acceleration for older models, llama-7b q2k):
llama_print_timings:      sample time =   537.35 ms /   946 runs   (    0.57 ms per token,  1760.50 tokens per second)
llama_print_timings: prompt eval time =  1150.85 ms /     3 tokens (  383.62 ms per token,     2.61 tokens per second)
llama_print_timings:        eval time = 30633.54 ms /   945 runs   (   32.42 ms per token,    30.85 tokens per second)

Finally, managed to compile it. Compiler looked for OpenCL lib in fixed patch /usr/lib/x86_64-linux-gnu/libOpenCL.so so I had to create symlink. Seems to work fine. Is there any way to set number of layers offloated to GPU (like llama.cpp -ngl argument?)

@TeddyDD the number of offloaded layers is set automatically by VRAM, or you can put it in the modelfile (see the normal ollama docs). The worst case is that CLBlast isn't found, and then ggml files (which are old/obsolete) will only get CPU accel instead of limited GPU accel. That path might be a default if the CLBlast cmake includes are not found? Just using the upstream support here.

I find that Ollama ends up using 100% of the GPU after inference, however, the API/runner stays to be responsive and there does not seem to be a request running. I tested that by prompting the LLama2-13B model using the following command: ollama run llama2:13b-chat.
Here might be useful information coming from the output of Ollama's binary, which I compiled with the instructions provided:
Nov 13 19:54:51 Ubuntu-Desktop ollama[2930]: llm_load_tensors: ggml ctx size =    0.12 MB
Nov 13 19:54:51 Ubuntu-Desktop ollama[2930]: llm_load_tensors: using ROCm for GPU acceleration
Nov 13 19:54:51 Ubuntu-Desktop ollama[2930]: llm_load_tensors: mem required  =   88.01 MB
Nov 13 19:54:51 Ubuntu-Desktop ollama[2930]: llm_load_tensors: offloading 40 repeating layers to GPU
Nov 13 19:54:51 Ubuntu-Desktop ollama[2930]: llm_load_tensors: offloading non-repeating layers to GPU
Nov 13 19:54:51 Ubuntu-Desktop ollama[2930]: llm_load_tensors: offloaded 43/43 layers to GPU
Nov 13 19:54:51 Ubuntu-Desktop ollama[2930]: llm_load_tensors: VRAM used: 6936.01 MB
Nov 13 19:54:58 Ubuntu-Desktop ollama[2930]: ...................................................................................................
Nov 13 19:54:58 Ubuntu-Desktop ollama[2930]: llama_new_context_with_model: n_ctx      = 4096
Nov 13 19:54:58 Ubuntu-Desktop ollama[2930]: llama_new_context_with_model: freq_base  = 10000.0
Nov 13 19:54:58 Ubuntu-Desktop ollama[2930]: llama_new_context_with_model: freq_scale = 1
Nov 13 19:54:58 Ubuntu-Desktop ollama[2930]: llama_kv_cache_init: offloading v cache to GPU
Nov 13 19:54:58 Ubuntu-Desktop ollama[2930]: llama_kv_cache_init: offloading k cache to GPU
Nov 13 19:54:58 Ubuntu-Desktop ollama[2930]: llama_kv_cache_init: VRAM kv self = 3200.00 MB
Nov 13 19:54:58 Ubuntu-Desktop ollama[2930]: llama_new_context_with_model: kv self size  = 3200.00 MB
Nov 13 19:54:58 Ubuntu-Desktop ollama[2930]: llama_new_context_with_model: compute buffer total size = 364.13 MB
Nov 13 19:54:59 Ubuntu-Desktop ollama[2930]: llama_new_context_with_model: VRAM scratch buffer: 358.00 MB
Nov 13 19:54:59 Ubuntu-Desktop ollama[2930]: llama_new_context_with_model: total VRAM used: 10494.01 MB (model: 6936.01 MB, context: 3558.00 MB)
Nov 13 19:54:59 Ubuntu-Desktop ollama[11984]: llama server listening at http://<IP_ADDRESS>:63912
Nov 13 19:54:59 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901699,"level":"INFO","function":"main","line":1749,"message":"HTTP server listening","hostname":"<IP_ADDRESS>","port":63912}
Nov 13 19:54:59 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901699,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":36078,"status":200,"method":"HEAD","path":"/","params":{}}
Nov 13 19:54:59 Ubuntu-Desktop ollama[2930]: 2023/11/13 19:54:59 llama.go:444: llama runner started in 9.601349 seconds
Nov 13 19:54:59 Ubuntu-Desktop ollama[2930]: [GIN] 2023/11/13 - 19:54:59 | 200 |  9.812678297s |       <IP_ADDRESS> | POST     "/api/generate"
Nov 13 19:55:40 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901740,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":45060,"status":200,"method":"HEAD","path":"/","params":{}}
Nov 13 19:55:46 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901746,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":45060,"status":200,"method":"POST","path":"/completion","params":{}}
Nov 13 19:55:46 Ubuntu-Desktop ollama[2930]: llama_print_timings:        load time =    7508.76 ms
Nov 13 19:55:46 Ubuntu-Desktop ollama[2930]: llama_print_timings:      sample time =      37.42 ms /   381 runs   (    0.10 ms per token, 10180.90 tokens per second)
Nov 13 19:55:46 Ubuntu-Desktop ollama[2930]: llama_print_timings: prompt eval time =     118.68 ms /    28 tokens (    4.24 ms per token,   235.92 tokens per second)
Nov 13 19:55:46 Ubuntu-Desktop ollama[2930]: llama_print_timings:        eval time =    5975.70 ms /   380 runs   (   15.73 ms per token,    63.59 tokens per second)
Nov 13 19:55:46 Ubuntu-Desktop ollama[2930]: llama_print_timings:       total time =    6150.55 ms
Nov 13 19:55:46 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901746,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":46872,"status":200,"method":"POST","path":"/tokenize","params":{}}
Nov 13 19:55:46 Ubuntu-Desktop ollama[2930]: [GIN] 2023/11/13 - 19:55:46 | 200 |  6.154027482s |       <IP_ADDRESS> | POST     "/api/generate"
Nov 13 19:56:00 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901760,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":48098,"status":200,"method":"HEAD","path":"/","params":{}}
Nov 13 19:56:00 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901760,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":48098,"status":200,"method":"POST","path":"/detokenize","params":{}}
Nov 13 19:56:06 Ubuntu-Desktop ollama[2930]: llama_print_timings:        load time =    7508.76 ms
Nov 13 19:56:06 Ubuntu-Desktop ollama[2930]: llama_print_timings:      sample time =      35.51 ms /   358 runs   (    0.10 ms per token, 10081.67 tokens per second)
Nov 13 19:56:06 Ubuntu-Desktop ollama[2930]: llama_print_timings: prompt eval time =     144.15 ms /    27 tokens (    5.34 ms per token,   187.30 tokens per second)
Nov 13 19:56:06 Ubuntu-Desktop ollama[2930]: llama_print_timings:        eval time =    6057.62 ms /   357 runs   (   16.97 ms per token,    58.93 tokens per second)
Nov 13 19:56:06 Ubuntu-Desktop ollama[2930]: llama_print_timings:       total time =    6255.72 ms
Nov 13 19:56:06 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901766,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":48098,"status":200,"method":"POST","path":"/completion","params":{}}
Nov 13 19:56:06 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901766,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":60974,"status":200,"method":"POST","path":"/tokenize","params":{}}
Nov 13 19:56:06 Ubuntu-Desktop ollama[2930]: [GIN] 2023/11/13 - 19:56:06 | 200 |  6.303318256s |       <IP_ADDRESS> | POST     "/api/generate"
Nov 13 19:56:19 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901779,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":38146,"status":200,"method":"HEAD","path":"/","params":{}}
Nov 13 19:56:19 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901779,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":38146,"status":200,"method":"POST","path":"/detokenize","params":{}}
Nov 13 19:56:27 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901787,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":38146,"status":200,"method":"POST","path":"/completion","params":{}}
Nov 13 19:56:27 Ubuntu-Desktop ollama[2930]: llama_print_timings:        load time =    7508.76 ms
Nov 13 19:56:27 Ubuntu-Desktop ollama[2930]: llama_print_timings:      sample time =      38.40 ms /   394 runs   (    0.10 ms per token, 10260.15 tokens per second)
Nov 13 19:56:27 Ubuntu-Desktop ollama[2930]: llama_print_timings: prompt eval time =     172.85 ms /    25 tokens (    6.91 ms per token,   144.64 tokens per second)
Nov 13 19:56:27 Ubuntu-Desktop ollama[2930]: llama_print_timings:        eval time =    7149.25 ms /   393 runs   (   18.19 ms per token,    54.97 tokens per second)
Nov 13 19:56:27 Ubuntu-Desktop ollama[2930]: llama_print_timings:       total time =    7382.44 ms
Nov 13 19:56:27 Ubuntu-Desktop ollama[11984]: {"timestamp":1699901787,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":48284,"status":200,"method":"POST","path":"/tokenize","params":{}}
Nov 13 19:56:27 Ubuntu-Desktop ollama[2930]: [GIN] 2023/11/13 - 19:56:27 | 200 |  7.429706995s |       <IP_ADDRESS> | POST     "/api/generate"

I interpret that Ollama knows the generation has finished but still does something in the background, which does not seem to affect inference speed. One should note the Ollama runner is successfully killed, stopping it from using more resources, after a timeout. I also reproduced this problem with the Mistral-7B model. No additional CPU resources are being used after inference. The GPU's utilization constantly stays at 100%, the frequency on 3GHz.
My Graphics card is the 7900XT, ROCm version 5.7. I'm happy to provide more details or a demonstration if required.
I hope my comment helps verifying normal operation of Ollama. Thank you for your enthusiasm.
Apart from that, I observed page faults after exceeding a certain amount of vram usage, specifically 14GB. I believe this is an issue with ROCm and not the hardware nor Ollama.

I have a similar issue. GPU chugs on 100% usage, inference starts after a while but it's really slow. llama.cpp compiled from source does not have this issue on the same models.
Logs below:

2023/11/14 00:03:10 images.go:824: total blobs: 9
2023/11/14 00:03:10 images.go:831: total unused blobs removed: 0
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.

using env:   export GIN_MODE=release
using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] POST   /api/pull                 --> github.com/jmorganca/ollama/server.PullModelHandler (5 handlers)
[GIN-debug] POST   /api/generate             --> github.com/jmorganca/ollama/server.GenerateHandler (5 handlers)
[GIN-debug] POST   /api/embeddings           --> github.com/jmorganca/ollama/server.EmbeddingHandler (5 handlers)
[GIN-debug] POST   /api/create               --> github.com/jmorganca/ollama/server.CreateModelHandler (5 handlers)
[GIN-debug] POST   /api/push                 --> github.com/jmorganca/ollama/server.PushModelHandler (5 handlers)
[GIN-debug] POST   /api/copy                 --> github.com/jmorganca/ollama/server.CopyModelHandler (5 handlers)
[GIN-debug] DELETE /api/delete               --> github.com/jmorganca/ollama/server.DeleteModelHandler (5 handlers)
[GIN-debug] POST   /api/show                 --> github.com/jmorganca/ollama/server.ShowModelHandler (5 handlers)
[GIN-debug] GET    /                         --> github.com/jmorganca/ollama/server.Serve.func2 (5 handlers)
[GIN-debug] GET    /api/tags                 --> github.com/jmorganca/ollama/server.ListModelsHandler (5 handlers)
[GIN-debug] HEAD   /                         --> github.com/jmorganca/ollama/server.Serve.func2 (5 handlers)
[GIN-debug] HEAD   /api/tags                 --> github.com/jmorganca/ollama/server.ListModelsHandler (5 handlers)
2023/11/14 00:03:10 routes.go:696: Listening on <IP_ADDRESS>:11434 (version 0.0.0)
2023/11/14 00:03:10 accelerator_rocm.go:73: ROCm found 15446 MiB of available VRAM on device "card0"
[GIN] 2023/11/14 - 00:03:16 | 200 |      41.459µs |       <IP_ADDRESS> | HEAD     "/"
[GIN] 2023/11/14 - 00:03:16 | 200 |     360.157µs |       <IP_ADDRESS> | POST     "/api/show"
2023/11/14 00:03:17 accelerator_rocm.go:73: ROCm found 15427 MiB of available VRAM on device "card0"
2023/11/14 00:03:17 accelerator_rocm.go:83: ROCm selecting device "card0"
2023/11/14 00:03:17 llama.go:247: 15427 MB VRAM available, loading up to 77 GPU layers
2023/11/14 00:03:17 llama.go:372: starting llama runner
2023/11/14 00:03:17 llama.go:430: waiting for llama runner to start responding
/tmp/ollama916426868/llama.cpp/gguf/build/rocm/bin/ollama-runner: /usr/lib64/libtinfo.so.6: no version information available (required by /opt/rocm-5.6.0/lib/libamd_comgr.so.2)
ggml_init_cublas: found 1 ROCm devices:
Device 0: AMD Radeon RX 6950 XT, compute capability 10.3
{"timestamp":1699916598,"level":"INFO","function":"main","line":1324,"message":"build info","build":1412,"commit":"9e70cc"}
{"timestamp":1699916598,"level":"INFO","function":"main","line":1330,"message":"system info","n_threads":12,"n_threads_batch":-1,"total_threads":24,"system_info":"AVX = 1 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0 | NEON = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | "}
llama_model_loader: loaded meta data with 20 key-value pairs and 291 tensors from /home/teddy/.ollama/models/blobs/sha256:940f1e531a522e38e7e4b1f14432dbcfc6cc7a0e5972b9a433688755e90c5323 (version GGUF V2 (latest))
llama_model_loader: - tensor    0:                token_embd.weight q5_K     [  4096, 32000,     1,     1 ]
llama_model_loader: - tensor    1:              blk.0.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor    2:              blk.0.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor    3:              blk.0.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor    4:         blk.0.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor    5:            blk.0.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor    6:              blk.0.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor    7:            blk.0.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor    8:           blk.0.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor    9:            blk.0.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   10:              blk.1.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   11:              blk.1.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   12:              blk.1.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   13:         blk.1.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   14:            blk.1.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   15:              blk.1.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   16:            blk.1.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   17:           blk.1.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   18:            blk.1.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   19:              blk.2.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   20:              blk.2.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   21:              blk.2.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   22:         blk.2.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   23:            blk.2.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   24:              blk.2.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   25:            blk.2.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   26:           blk.2.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   27:            blk.2.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   28:              blk.3.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   29:              blk.3.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   30:              blk.3.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   31:         blk.3.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   32:            blk.3.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   33:              blk.3.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   34:            blk.3.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   35:           blk.3.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   36:            blk.3.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   37:              blk.4.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   38:              blk.4.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   39:              blk.4.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   40:         blk.4.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   41:            blk.4.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   42:              blk.4.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   43:            blk.4.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   44:           blk.4.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   45:            blk.4.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   46:              blk.5.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   47:              blk.5.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   48:              blk.5.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   49:         blk.5.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   50:            blk.5.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   51:              blk.5.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   52:            blk.5.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   53:           blk.5.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   54:            blk.5.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   55:              blk.6.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   56:              blk.6.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   57:              blk.6.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   58:         blk.6.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   59:            blk.6.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   60:              blk.6.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   61:            blk.6.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   62:           blk.6.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   63:            blk.6.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   64:              blk.7.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   65:              blk.7.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   66:              blk.7.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   67:         blk.7.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   68:            blk.7.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   69:              blk.7.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   70:            blk.7.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   71:           blk.7.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   72:            blk.7.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   73:              blk.8.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   74:              blk.8.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   75:              blk.8.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   76:         blk.8.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   77:            blk.8.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   78:              blk.8.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   79:            blk.8.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   80:           blk.8.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   81:            blk.8.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   82:              blk.9.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   83:              blk.9.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   84:              blk.9.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   85:         blk.9.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   86:            blk.9.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   87:              blk.9.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   88:            blk.9.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   89:           blk.9.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   90:            blk.9.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   91:             blk.10.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   92:             blk.10.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   93:             blk.10.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor   94:        blk.10.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor   95:           blk.10.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   96:             blk.10.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor   97:           blk.10.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor   98:          blk.10.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor   99:           blk.10.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  100:             blk.11.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  101:             blk.11.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  102:             blk.11.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  103:        blk.11.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  104:           blk.11.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  105:             blk.11.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  106:           blk.11.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  107:          blk.11.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  108:           blk.11.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  109:             blk.12.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  110:             blk.12.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  111:             blk.12.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  112:        blk.12.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  113:           blk.12.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  114:             blk.12.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  115:           blk.12.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  116:          blk.12.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  117:           blk.12.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  118:             blk.13.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  119:             blk.13.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  120:             blk.13.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  121:        blk.13.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  122:           blk.13.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  123:             blk.13.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  124:           blk.13.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  125:          blk.13.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  126:           blk.13.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  127:             blk.14.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  128:             blk.14.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  129:             blk.14.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  130:        blk.14.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  131:           blk.14.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  132:             blk.14.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  133:           blk.14.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  134:          blk.14.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  135:           blk.14.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  136:             blk.15.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  137:             blk.15.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  138:             blk.15.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  139:        blk.15.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  140:           blk.15.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  141:             blk.15.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  142:           blk.15.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  143:          blk.15.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  144:           blk.15.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  145:             blk.16.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  146:             blk.16.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  147:             blk.16.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  148:        blk.16.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  149:           blk.16.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  150:             blk.16.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  151:           blk.16.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  152:          blk.16.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  153:           blk.16.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  154:             blk.17.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  155:             blk.17.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  156:             blk.17.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  157:        blk.17.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  158:           blk.17.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  159:             blk.17.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  160:           blk.17.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  161:          blk.17.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  162:           blk.17.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  163:             blk.18.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  164:             blk.18.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  165:             blk.18.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  166:        blk.18.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  167:           blk.18.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  168:             blk.18.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  169:           blk.18.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  170:          blk.18.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  171:           blk.18.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  172:             blk.19.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  173:             blk.19.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  174:             blk.19.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  175:        blk.19.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  176:           blk.19.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  177:             blk.19.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  178:           blk.19.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  179:          blk.19.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  180:           blk.19.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  181:             blk.20.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  182:             blk.20.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  183:             blk.20.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  184:        blk.20.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  185:           blk.20.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  186:             blk.20.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  187:           blk.20.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  188:          blk.20.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  189:           blk.20.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  190:             blk.21.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  191:             blk.21.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  192:             blk.21.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  193:        blk.21.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  194:           blk.21.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  195:             blk.21.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  196:           blk.21.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  197:          blk.21.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  198:           blk.21.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  199:             blk.22.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  200:             blk.22.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  201:             blk.22.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  202:        blk.22.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  203:           blk.22.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  204:             blk.22.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  205:           blk.22.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  206:          blk.22.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  207:           blk.22.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  208:             blk.23.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  209:             blk.23.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  210:             blk.23.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  211:        blk.23.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  212:           blk.23.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  213:             blk.23.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  214:           blk.23.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  215:          blk.23.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  216:           blk.23.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  217:             blk.24.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  218:             blk.24.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  219:             blk.24.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  220:        blk.24.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  221:           blk.24.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  222:             blk.24.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  223:           blk.24.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  224:          blk.24.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  225:           blk.24.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  226:             blk.25.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  227:             blk.25.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  228:             blk.25.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  229:        blk.25.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  230:           blk.25.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  231:             blk.25.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  232:           blk.25.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  233:          blk.25.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  234:           blk.25.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  235:             blk.26.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  236:             blk.26.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  237:             blk.26.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  238:        blk.26.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  239:           blk.26.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  240:             blk.26.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  241:           blk.26.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  242:          blk.26.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  243:           blk.26.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  244:             blk.27.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  245:             blk.27.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  246:             blk.27.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  247:        blk.27.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  248:           blk.27.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  249:             blk.27.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  250:           blk.27.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  251:          blk.27.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  252:           blk.27.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  253:             blk.28.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  254:             blk.28.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  255:             blk.28.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  256:        blk.28.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  257:           blk.28.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  258:             blk.28.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  259:           blk.28.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  260:          blk.28.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  261:           blk.28.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  262:             blk.29.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  263:             blk.29.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  264:             blk.29.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  265:        blk.29.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  266:           blk.29.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  267:             blk.29.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  268:           blk.29.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  269:          blk.29.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  270:           blk.29.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  271:             blk.30.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  272:             blk.30.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  273:             blk.30.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  274:        blk.30.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  275:           blk.30.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  276:             blk.30.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  277:           blk.30.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  278:          blk.30.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  279:           blk.30.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  280:             blk.31.attn_q.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  281:             blk.31.attn_k.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  282:             blk.31.attn_v.weight q5_K     [  4096,  1024,     1,     1 ]
llama_model_loader: - tensor  283:        blk.31.attn_output.weight q5_K     [  4096,  4096,     1,     1 ]
llama_model_loader: - tensor  284:           blk.31.ffn_gate.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  285:             blk.31.ffn_up.weight q5_K     [  4096, 14336,     1,     1 ]
llama_model_loader: - tensor  286:           blk.31.ffn_down.weight q5_K     [ 14336,  4096,     1,     1 ]
llama_model_loader: - tensor  287:          blk.31.attn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  288:           blk.31.ffn_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  289:               output_norm.weight f32      [  4096,     1,     1,     1 ]
llama_model_loader: - tensor  290:                    output.weight q6_K     [  4096, 32000,     1,     1 ]
llama_model_loader: - kv   0:                       general.architecture str
llama_model_loader: - kv   1:                               general.name str
llama_model_loader: - kv   2:                       llama.context_length u32
llama_model_loader: - kv   3:                     llama.embedding_length u32
llama_model_loader: - kv   4:                          llama.block_count u32
llama_model_loader: - kv   5:                  llama.feed_forward_length u32
llama_model_loader: - kv   6:                 llama.rope.dimension_count u32
llama_model_loader: - kv   7:                 llama.attention.head_count u32
llama_model_loader: - kv   8:              llama.attention.head_count_kv u32
llama_model_loader: - kv   9:     llama.attention.layer_norm_rms_epsilon f32
llama_model_loader: - kv  10:                       llama.rope.freq_base f32
llama_model_loader: - kv  11:                          general.file_type u32
llama_model_loader: - kv  12:                       tokenizer.ggml.model str
llama_model_loader: - kv  13:                      tokenizer.ggml.tokens arr
llama_model_loader: - kv  14:                      tokenizer.ggml.scores arr
llama_model_loader: - kv  15:                  tokenizer.ggml.token_type arr
llama_model_loader: - kv  16:                tokenizer.ggml.bos_token_id u32
llama_model_loader: - kv  17:                tokenizer.ggml.eos_token_id u32
llama_model_loader: - kv  18:            tokenizer.ggml.unknown_token_id u32
llama_model_loader: - kv  19:               general.quantization_version u32
llama_model_loader: - type  f32:   65 tensors
llama_model_loader: - type q5_K:  225 tensors
llama_model_loader: - type q6_K:    1 tensors
llm_load_vocab: special tokens definition check successful ( 259/32000 ).
llm_load_print_meta: format           = GGUF V2 (latest)
llm_load_print_meta: arch             = llama
llm_load_print_meta: vocab type       = SPM
llm_load_print_meta: n_vocab          = 32000
llm_load_print_meta: n_merges         = 0
llm_load_print_meta: n_ctx_train      = 32768
llm_load_print_meta: n_embd           = 4096
llm_load_print_meta: n_head           = 32
llm_load_print_meta: n_head_kv        = 8
llm_load_print_meta: n_layer          = 32
llm_load_print_meta: n_rot            = 128
llm_load_print_meta: n_gqa            = 4
llm_load_print_meta: f_norm_eps       = 0.0e+00
llm_load_print_meta: f_norm_rms_eps   = 1.0e-05
llm_load_print_meta: f_clamp_kqv      = 0.0e+00
llm_load_print_meta: f_max_alibi_bias = 0.0e+00
llm_load_print_meta: n_ff             = 14336
llm_load_print_meta: freq_base_train  = 10000.0
llm_load_print_meta: freq_scale_train = 1
llm_load_print_meta: model type       = 7B
llm_load_print_meta: model ftype      = mostly Q5_K - Small
llm_load_print_meta: model params     = 7.24 B
llm_load_print_meta: model size       = 4.65 GiB (5.52 BPW)
llm_load_print_meta: general.name   = mistralai
llm_load_print_meta: BOS token = 1 ''
llm_load_print_meta: EOS token = 2 ''
llm_load_print_meta: UNK token = 0 ''
llm_load_print_meta: LF token  = 13 '<0x0A>'
llm_load_tensors: ggml ctx size =    0.10 MB
llm_load_tensors: using ROCm for GPU acceleration
llm_load_tensors: mem required  =   86.04 MB
llm_load_tensors: offloading 32 repeating layers to GPU
llm_load_tensors: offloading non-repeating layers to GPU
llm_load_tensors: offloaded 35/35 layers to GPU
llm_load_tensors: VRAM used: 4679.55 MB
..................................................................................................
llama_new_context_with_model: n_ctx      = 2048
llama_new_context_with_model: freq_base  = 10000.0
llama_new_context_with_model: freq_scale = 1
llama_kv_cache_init: offloading v cache to GPU
llama_kv_cache_init: offloading k cache to GPU
llama_kv_cache_init: VRAM kv self = 256.00 MB
llama_new_context_with_model: kv self size  =  256.00 MB
llama_new_context_with_model: compute buffer total size = 162.13 MB
llama_new_context_with_model: VRAM scratch buffer: 156.00 MB
llama_new_context_with_model: total VRAM used: 5091.56 MB (model: 4679.55 MB, context: 412.00 MB)
llama server listening at http://<IP_ADDRESS>:64085
{"timestamp":1699916656,"level":"INFO","function":"main","line":1749,"message":"HTTP server listening","hostname":"<IP_ADDRESS>","port":64085}
2023/11/14 00:04:17 llama.go:444: llama runner started in 60.000538 seconds
{"timestamp":1699916657,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":33310,"status":200,"method":"HEAD","path":"/","params":{}}
[GIN] 2023/11/14 - 00:04:17 | 200 |          1m0s |       <IP_ADDRESS> | POST     "/api/generate"
{"timestamp":1699916687,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":46536,"status":200,"method":"HEAD","path":"/","params":{}}
[GIN] 2023/11/14 - 00:06:00 | 200 |         1m13s |       <IP_ADDRESS> | POST     "/api/generate"
llama_print_timings:        load time =   58069.41 ms
llama_print_timings:      sample time =      28.83 ms /    19 runs   (    1.52 ms per token,   659.04 tokens per second)
llama_print_timings: prompt eval time =   51879.48 ms /    13 tokens ( 3990.73 ms per token,     0.25 tokens per second)
llama_print_timings:        eval time =   22313.13 ms /    18 runs   ( 1239.62 ms per token,     0.81 tokens per second)
llama_print_timings:       total time =   74225.82 ms
{"timestamp":1699916761,"level":"INFO","function":"log_server_request","line":1240,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":46536,"status":200,"method":"POST","path":"/completion","params":{}}
^C2023/11/14 00:06:02 llama.go:387: signal: interrupt

@arch-user-france1 and @TeddyDD can we use #738 for support/debugging? It sounds like two separate issues, but interested in both. I have seen the behavior @TeddyDD mentions and have more questions if a completely clean checkout doesn't fix it. I have not seen the behavior @arch-user-france1 describes, but it may involve issues like prompting strategies etc, but also interested in debugging it there in #738.

Ah, I think I see @arch-user-france1 what you are saying. The graphics pipeline is running while llama.cpp is running with ROCm support. I don't think that can be fixed here, if it is a bug, it's upstream in llama.cpp or in ROCm. The runner is literally just a compiled copy of llama.cpp. @TeddyDD do let me know in #738 if a completely clean build exhibits that behavior.

I have an error running go generate on Ubuntu 22.04 with a 6950XT. The command I ran was ROCM_PATH=/opt/rocm CLBlast_DIR=/usr/local/lib/cmake/CLBlast go generate -tags rocm ./.... I changed CLBlast_DIR to /usr/local/lib/cmake/CLBlast because /usr/lib/cmake/CLBlast didn't exist, but I'm not sure if that's even the right dir. The only things in that directory are CLBlastConfig.cmake and CLBlastConfig-noconfig.cmake. Regardless, I had the same error trying it both ways.

error log
-- The CXX compiler identification is Clang 17.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /opt/rocm/llvm/bin/clang++
-- Check for working CXX compiler: /opt/rocm/llvm/bin/clang++ - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler

    "/opt/rocm/llvm/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/jakeku/Downloads/ollama/llm/llama.cpp/gguf/build/rocm/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_a80fd/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_a80fd.dir/build.make CMakeFiles/cmTC_a80fd.dir/build
    gmake[1]: Entering directory '/home/jakeku/Downloads/ollama/llm/llama.cpp/gguf/build/rocm/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_a80fd.dir/testCXXCompiler.cxx.o
    /opt/rocm/llvm/bin/clang++    -MD -MT CMakeFiles/cmTC_a80fd.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_a80fd.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_a80fd.dir/testCXXCompiler.cxx.o -c /home/jakeku/Downloads/ollama/llm/llama.cpp/gguf/build/rocm/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    Linking CXX executable cmTC_a80fd
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a80fd.dir/link.txt --verbose=1
    /opt/rocm/llvm/bin/clang++ CMakeFiles/cmTC_a80fd.dir/testCXXCompiler.cxx.o -o cmTC_a80fd
    ld.lld: error: unable to find library -lstdc++
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[1]: *** [CMakeFiles/cmTC_a80fd.dir/build.make:100: cmTC_a80fd] Error 1
    gmake[1]: Leaving directory '/home/jakeku/Downloads/ollama/llm/llama.cpp/gguf/build/rocm/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:127: cmTC_a80fd/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)

I am not sure what to do to fix this. apt list --installed shows that I have:
libstdc++-11-dev/jammy-updates,jammy-security,now 11.4.0-1ubuntu1~22.04 amd64 [installed]
libstdc++6/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]
libstdc++6/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 i386 [installed,automatic]

I don't know what I'm doing so I just ignored the error and ran go build anyway. That built without error and ollama was able to run and detect my VRAM, but it was slow so I assume it had to be falling back to CPU. I'll include those logs even though the issue is probably the problem above.

serve/run logs
> ollama serve

2023/11/15 10:33:48 images.go:824: total blobs: 4
2023/11/15 10:33:48 images.go:831: total unused blobs removed: 0
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

[GIN-debug] POST   /api/pull                 --> github.com/jmorganca/ollama/server.PullModelHandler (5 handlers)
[GIN-debug] POST   /api/generate             --> github.com/jmorganca/ollama/server.GenerateHandler (5 handlers)
[GIN-debug] POST   /api/embeddings           --> github.com/jmorganca/ollama/server.EmbeddingHandler (5 handlers)
[GIN-debug] POST   /api/create               --> github.com/jmorganca/ollama/server.CreateModelHandler (5 handlers)
[GIN-debug] POST   /api/push                 --> github.com/jmorganca/ollama/server.PushModelHandler (5 handlers)
[GIN-debug] POST   /api/copy                 --> github.com/jmorganca/ollama/server.CopyModelHandler (5 handlers)
[GIN-debug] DELETE /api/delete               --> github.com/jmorganca/ollama/server.DeleteModelHandler (5 handlers)
[GIN-debug] POST   /api/show                 --> github.com/jmorganca/ollama/server.ShowModelHandler (5 handlers)
[GIN-debug] GET    /                         --> github.com/jmorganca/ollama/server.Serve.func2 (5 handlers)
[GIN-debug] GET    /api/tags                 --> github.com/jmorganca/ollama/server.ListModelsHandler (5 handlers)
[GIN-debug] HEAD   /                         --> github.com/jmorganca/ollama/server.Serve.func2 (5 handlers)
[GIN-debug] HEAD   /api/tags                 --> github.com/jmorganca/ollama/server.ListModelsHandler (5 handlers)
2023/11/15 10:33:48 routes.go:696: Listening on <IP_ADDRESS>:11434 (version 0.0.0)
2023/11/15 10:33:48 accelerator_rocm.go:39: warning: ROCM_PATH is not set. Trying a likely fallback path, but it is recommended to set this variable in the environment.
2023/11/15 10:33:48 accelerator_rocm.go:73: ROCm found 15217 MiB of available VRAM on device "card0"
2023/11/15 10:33:48 accelerator_rocm.go:83: ROCm selecting device "card0"

> ollama run mistral

2023/11/15 10:41:16 accelerator_rocm.go:39: warning: ROCM_PATH is not set. Trying a likely fallback path, but it is recommended to set this variable in the environment.
2023/11/15 10:41:16 accelerator_rocm.go:73: ROCm found 15277 MiB of available VRAM on device "card0"
2023/11/15 10:41:16 accelerator_rocm.go:83: ROCm selecting device "card0"
2023/11/15 10:41:16 llama.go:247: 15277 MB VRAM available, loading up to 93 GPU layers
2023/11/15 10:41:16 llama.go:346: llama runner not found: stat /tmp/ollama3875790972/llama.cpp/gguf/build/rocm/bin/ollama-runner: no such file or directory
2023/11/15 10:41:16 llama.go:372: starting llama runner
2023/11/15 10:41:16 llama.go:430: waiting for llama runner to start responding
{"timestamp":1700062876,"level":"WARNING","function":"server_params_parse","line":871,"message":"Not compiled with GPU offload support, --n-gpu-layers option will be ignored. See main README.md for information on enabling GPU BLAS support","n_gpu_layers":-1}
{"timestamp":1700062876,"level":"INFO","function":"main","line":1323,"message":"build info","build":1,"commit":"9e70cc0"}
{"timestamp":1700062876,"level":"INFO","function":"main","line":1325,"message":"system info","n_threads":8,"n_threads_batch":-1,"total_threads":16,"system_info":"AVX = 1 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0 | NEON = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | "}
llama_model_loader: loaded meta data with 20 key-value pairs and 291 tensors from /home/jakeku/.ollama/models/blobs/sha256:6ae28029995007a3ee8d0b8556d50f3b59b831074cf19c84de87acf51fb54054 (version GGUF V2 (latest))
llama_model_loader: spam x1000 removed since i don't think it matters
llm_load_vocab: special tokens definition check successful ( 259/32000 ).
llm_load_print_meta: format           = GGUF V2 (latest)
llm_load_print_meta: arch             = llama
llm_load_print_meta: vocab type       = SPM
llm_load_print_meta: n_vocab          = 32000
llm_load_print_meta: n_merges         = 0
llm_load_print_meta: n_ctx_train      = 32768
llm_load_print_meta: n_embd           = 4096
llm_load_print_meta: n_head           = 32
llm_load_print_meta: n_head_kv        = 8
llm_load_print_meta: n_layer          = 32
llm_load_print_meta: n_rot            = 128
llm_load_print_meta: n_gqa            = 4
llm_load_print_meta: f_norm_eps       = 0.0e+00
llm_load_print_meta: f_norm_rms_eps   = 1.0e-05
llm_load_print_meta: f_clamp_kqv      = 0.0e+00
llm_load_print_meta: f_max_alibi_bias = 0.0e+00
llm_load_print_meta: n_ff             = 14336
llm_load_print_meta: freq_base_train  = 10000.0
llm_load_print_meta: freq_scale_train = 1
llm_load_print_meta: model type       = 7B
llm_load_print_meta: model ftype      = mostly Q4_0
llm_load_print_meta: model params     = 7.24 B
llm_load_print_meta: model size       = 3.83 GiB (4.54 BPW)
llm_load_print_meta: general.name   = mistralai
llm_load_print_meta: BOS token = 1 '<s>'
llm_load_print_meta: EOS token = 2 '</s>'
llm_load_print_meta: UNK token = 0 '<unk>'
llm_load_print_meta: LF token  = 13 '<0x0A>'
llm_load_tensors: ggml ctx size =    0.10 MB
llm_load_tensors: mem required  = 3917.96 MB
..................................................................................................
llama_new_context_with_model: n_ctx      = 2048
llama_new_context_with_model: freq_base  = 10000.0
llama_new_context_with_model: freq_scale = 1
llama_new_context_with_model: kv self size  =  256.00 MB
llama_new_context_with_model: compute buffer total size = 162.13 MB

llama server listening at http://<IP_ADDRESS>:49618

{"timestamp":1700062876,"level":"INFO","function":"main","line":1746,"message":"HTTP server listening","hostname":"<IP_ADDRESS>","port":49618}
{"timestamp":1700062876,"level":"INFO","function":"log_server_request","line":1233,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":57018,"status":200,"method":"HEAD","path":"/","params":{}}
2023/11/15 10:41:16 llama.go:444: llama runner started in 0.401371 seconds

Sending a prompt results in
llama_print_timings:        load time =     340.94 ms
llama_print_timings:      sample time =       2.60 ms /    16 runs   (    0.16 ms per token,  6163.33 tokens per second)
llama_print_timings: prompt eval time =    1187.05 ms /    13 tokens (   91.31 ms per token,    10.95 tokens per second)
llama_print_timings:        eval time =    1945.57 ms /    15 runs   (  129.70 ms per token,     7.71 tokens per second)

Added better build docs for CPU, nVidia and AMD (makes it easier to copy line by line). Will add ROCm and CLBlast docs links

Added lots of links and information about dependencies, with a disclaimer that distro-specific packages are often preferred, but links to ROCm, CUDA and CLblast installation docs.

Quick check with mistral (gguf runner, 7900xtx) shows things are still happy after rebase:
llama_print_timings:      sample time =      20.58 ms /   153 runs   (    0.13 ms per token,  7435.85 tokens per second)
llama_print_timings: prompt eval time =      66.89 ms /    12 tokens (    5.57 ms per token,   179.39 tokens per second)
llama_print_timings:        eval time =    1920.18 ms /   152 runs   (   12.63 ms per token,    79.16 tokens per second)

GGML (CLBlast still working too, same card)
llama_print_timings:      sample time =    19.27 ms /    34 runs   (    0.57 ms per token,  1764.86 tokens per second)
llama_print_timings: prompt eval time =   598.93 ms /     7 tokens (   85.56 ms per token,    11.69 tokens per second)
llama_print_timings:        eval time =  1054.20 ms /    33 runs   (   31.95 ms per token,    31.30 tokens per second)

Minor update to text, but also added a step to clean up the cmake build directories. At least for ROCm, this should help prevent the "slower than CPU generation" bug, which seems to be caused by bad cmake cache as identified/reproduced by @TeddyDD

Should we mention there are two possible backends to choose from (CLBlast and hipBLAS) and hipBLAS takes precedence when both are installed, so users will be aware of that?

@GZGavinZhao that's not how this works, HIP is used for all GGUF files, and CLBlast is used for all GGML files, but the runners do not have both configured.

If hipBLAS is always being used, then shouldn't there be a comment saying that hipBLAS should be a dependency?

Wait, I think I'm a little confused as to why there are two ollama-runner, one in gguf/build/rocm/bin and the other in ggml/build/rocm/bin, but in any case, if LLAMA_HIPBLAS is set to ON in generate_linux_rocm.go, I think in the README there should at least be mentions of hipBLAS being a potential build dependency.

Ah, I think I see @arch-user-france1 what you are saying. The graphics pipeline is running while llama.cpp is running with ROCm support. I don't think that can be fixed here, if it is a bug, it's upstream in llama.cpp or in ROCm. The runner is literally just a compiled copy of llama.cpp. @TeddyDD do let me know in #738 if a completely clean build exhibits that very slow inference behavior.

https://github.com/ggerganov/llama.cpp/issues/3929
Apparently it is a problem with ROCm only affecting RDNA3 architectures, according to the author, and indeed can not be fixed here.

@GZGavinZhao the docs describe the dependencies: "HIPBLAS" is provided by ROCm, which the README.md now links the install guide. The two runners are for different kinds of models, "GGML" are old models and the version of llama.cpp that still supports them is from before the HIP/ROCm merge, so the best it can do is clblast (honestly I'm for just dropping ggml support, but idk). "GGUF" is the modern copy of llama.cpp which does support ROCm, described as "HIPBLAS" in the Cmake rules.  Only one accelerated runner is present for each model type.

Hi @65a - nice work and thanks for taking the initiative maintain rocm support. Checking to see if you have come across a way to set the "main device" when you have multiple AMD GPUs.
For example I have the below output from llama logs
ggml_init_cublas: found 2 ROCm devices:
  Device 0: AMD Radeon RX 6600 XT, compute capability 10.3
  Device 1: AMD Radeon RX 6900 XT, compute capability 10.3

Then the logs indicate the below
ggml_cuda_set_main_device: using device 0 (AMD Radeon RX 6600 XT) as main device

I would like to use the Device 1 (RX 6900 XT) as the main device for processing rather than low powered RX 6600 XT. Usually in llama.cpp I could pass in the argument --main-gpu like below with the entire command I use with llama.cpp.
HIP_VISIBLE_DEVICES="0,1" ./main --main-gpu 1 -ngl 63 -m ~/Storage/TheBloke_Wizard-Vicuna-30B-Uncensored-GGUF/Wizard-Vicuna-30B-Uncensored.Q4_K_M.gguf -p "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: Write an essay about pigeons in 1000 words ASSISTANT:"

Thanks!

@purinda I think ollama will pick the 6900xt, but llama won't, which is annoying (I have a similar issue with the iGPU + dGPU on a laptop). Does it work if you run HIP_VISIBLE_DEVICES=1 ollama serve? This is not necessarily ideal, but it might get you out of the edge case. I need to look at how ollama handles this for cuda and see if that can be used here as well...

Thanks for this patch,

I am encountering an issue when attempting to run Ollama with GPU BLAS support on my AMD GPU architecture (gfx1010). It appears that the necessary TensileLibrary component is missing for my specific GPU architecture.
Basic testing with CPU mode has yielded satisfactory results, but performance is significantly slower than anticipated.
System Information:

GPU Architecture: gfx1010 (AMD Radeon RX 5700)

>$ /opt/rocm/llvm/bin/amdgpu-arch
gfx1010

Operating System: Ubuntu 23.04

>$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 23.04
Release:	23.04
Codename:	lunar

Linux Kernel Version: 6.2.0-36-generic

> $ uname -a
Linux 6.2.0-36-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct  4 10:14:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Observations:

Ollama fails to run with GPU BLAS support.

2023/11/18 21:41:52 accelerator_rocm.go:39: warning: ROCM_PATH is not set. Trying a likely fallback path, but it is recommended to set this variable in the environment.
2023/11/18 21:41:52 accelerator_rocm.go:73: ROCm found 7384 MiB of available VRAM on device "card0"
2023/11/18 21:41:52 accelerator_rocm.go:83: ROCm selecting device "card0"
2023/11/18 21:41:52 llama.go:247: 7384 MB VRAM available, loading up to 48 GPU layers
2023/11/18 21:41:52 llama.go:372: starting llama runner
2023/11/18 21:41:52 llama.go:430: waiting for llama runner to start responding

rocBLAS error: Cannot read /opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary.dat: Illegal seek for GPU arch : gfx1010
 List of available TensileLibrary Files :
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx1030.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx1100.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx1101.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx1102.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx803.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx900.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx906.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx908.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx90a.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx940.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx941.dat"
"/opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary_lazy_gfx942.dat"
2023/11/18 21:41:53 llama.go:387: Cannot read /opt/rocm-5.7.0/lib/rocblas/library/TensileLibrary.dat: Illegal seek for GPU arch : gfx1010
2023/11/18 21:41:53 llama.go:395: error starting llama runner: llama runner process has terminated
2023/11/18 21:41:53 llama.go:461: llama runner stopped successfully
2023/11/18 21:41:53 llama.go:372: starting llama runner
2023/11/18 21:41:53 llama.go:430: waiting for llama runner to start responding
{"timestamp":1700323913,"level":"WARNING","function":"server_params_parse","line":871,"message":"Not compiled with GPU offload support, --n-gpu-layers option will be ignored. See main README.md for information on enabling GPU BLAS support","n_gpu_layers":-1}
{"timestamp":1700323913,"level":"INFO","function":"main","line":1323,"message":"build info","build":1412,"commit":"9e70cc0"}
{"timestamp":1700323913,"level":"INFO","function":"main","line":1325,"message":"system info","n_threads":8,"n_threads_batch":-1,"total_threads":16,"system_info":"AVX = 1 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0 | NEON = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | "}
llama_model_loader: loaded meta data with 19 key-value pairs and 291 tensors from /home/popoyi/.ollama/models/blobs/sha256:22f7f8ef5f4c791c1b03d7eb414399294764d7cc82c7e94aa81a1feb80a983a2 (version GGUF V2 (latest))

CPU mode (without GPU acceleartion) looks OK but exhibits slow performance.

llama_print_timings:        load time =    1491.78 ms
llama_print_timings:      sample time =     160.43 ms /   553 runs   (    0.29 ms per token,  3447.09 tokens per second)
llama_print_timings: prompt eval time =   97655.27 ms /   915 tokens (  106.73 ms per token,     9.37 tokens per second)
llama_print_timings:        eval time =  144534.43 ms /   552 runs   (  261.84 ms per token,     3.82 tokens per second)
llama_print_timings:       total time =  242514.53 ms
{"timestamp":1700326220,"level":"INFO","function":"log_server_request","line":1233,"message":"request","remote_addr":"<IP_ADDRESS>","remote_port":33328,"status":200,"method":"POST","path":"/tokenize","params":{}}
[GIN] 2023/11/18 - 22:20:20 | 200 |          4m2s |       <IP_ADDRESS> | POST     "/api/generate"

Request:
I would appreciate any guidance or assistance from the community regarding the configuration of AMD GPU-based systems (gfx1010 architecture) to enable GPU acceleration for Ollama. Any pointers to resolve this issue would be greatly valued.

Your graphics architecture seems unsupported, you probably need HSA_OVERRIDE_GFX_VERSION to be set in the environment to something ROCm does support. Please use #738 for questions/support, your issue is not a problem with the PR.

Thanks @65a .
Tried below commands:

HSA_OVERRIDE_GFX_VERSION=10.3.0 ./ollama serve , no luck. Hit with "Memory access fault"

HSA_OVERRIDE_GFX_VERSION=1030 ./ollama serve, no luck. Hit with "Could not initialize Tensile host"

With Command HSA_OVERRIDE_GFX_VERSION=10.3.0 ./ollama serve
>$ HSA_OVERRIDE_GFX_VERSION=10.3.0 ./ollama serve

 HSA_OVERRIDE_GFX_VERSION=10.3.0 ./ollama serve
2023/11/18 23:12:04 images.go:799: total blobs: 6
2023/11/18 23:12:04 images.go:806: total unused blobs removed: 0
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode.  Trying a likely fallback path, but it is recommended to set this variable in the environment.
2023/11/18 23:12:04 accelerator_rocm.go:73: ROCm found 7435 MiB of available VRAM on device "card0"
2023/11/18 23:12:04 accelerator_rocm.go:83: ROCm selecting device "card0"
2023/11/18 23:12:58 accelerator_rocm.go:39: warning: ROCM_PATH is not set. Trying a likely fallback path, but it is recommended to set this variable in the environment.
2023/11/18 23:12:58 accelerator_rocm.go:73: ROCm found 7450 MiB of available VRAM on device "card0"
2023/11/18 23:12:58 accelerator_rocm.go:83: ROCm selecting device "card0"
2023/11/18 23:12:58 llama.go:247: 7450 MB VRAM available, loading up to 48 GPU layers
2023/11/18 23:12:58 llama.go:372: starting llama runner
2023/11/18 23:12:58 llama.go:430: waiting for llama runner to start responding
ggml_init_cublas: found 1 ROCm devices:
  Device 0: AMD Radeon RX 5700, compute capability 10.3
{"timestamp":1700329379,"level":"INFO","function":"main","line":1324,"message":"build info","build":1412,"commit":"9e70cc0"}
{"timestamp":1700329379,"level":"INFO","function":"main","line":1330,"message":"system info","n_threads":8,"n_threads_batch":-1,"total_threads":16,"system_info":"AVX = 1 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0 | NEON = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | "}
llama_model_loader: loaded meta data with 19 key-value pairs and 291 tensors from /home/popoyi/.ollama/models/blobs/sha256:22f7f8ef5f4c791c1b03d7eb414399294764d7cc82c7e94aa81a1feb80a983a2 (version GGUF V2 (latest))
llama_model_loader: - tensor    0:                token_embd.weight q4_0     [  4096, 32000,     1,     1 ]
llama_model_loader: - tensor    1:           blk.0.attn_norm.weight f32      [  4096,     1,     1,     1 ]

With Command HSA_OVERRIDE_GFX_VERSION=1030 ./ollama serve
>$ HSA_OVERRIDE_GFX_VERSION=1030 ./ollama serve

--- ws21-01-ollama/ollama ‹main› » HSA_OVERRIDE_GFX_VERSION=1030 ollama serve
zsh: command not found: ollama
--- ws21-01-ollama/ollama ‹main› » HSA_OVERRIDE_GFX_VERSION=1030 ./ollama serve                                         127 ↵
2023/11/18 23:05:39 images.go:799: total blobs: 6
2023/11/18 23:05:39 images.go:806: total unused blobs removed: 0
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode.  Trying a likely fallback path, but it is recommended to set this variable in the environment.
2023/11/18 23:05:39 accelerator_rocm.go:73: ROCm found 7431 MiB of available VRAM on device "card0"
2023/11/18 23:05:39 accelerator_rocm.go:83: ROCm selecting device "card0"
[GIN] 2023/11/18 - 23:05:58 | 200 |     243.164µs |       <IP_ADDRESS> | GET      "/api/tags"
[GIN] 2023/11/18 - 23:05:58 | 200 |     678.047µs |       <IP_ADDRESS> | POST     "/api/show"
2023/11/18 23:08:12 accelerator_rocm.go:39: warning: ROCM_PATH is not set. Trying a likely fallback path, but it is recommended to set this variable in the environment.
2023/11/18 23:08:12 accelerator_rocm.go:73: ROCm found 7449 MiB of available VRAM on device "card0"
2023/11/18 23:08:12 accelerator_rocm.go:83: ROCm selecting device "card0"
2023/11/18 23:08:12 llama.go:247: 7449 MB VRAM available, loading up to 48 GPU layers
2023/11/18 23:08:12 llama.go:372: starting llama runner
2023/11/18 23:08:12 llama.go:430: waiting for llama runner to start responding

rocBLAS error: Could not initialize Tensile host: No devices found
2023/11/18 23:08:13 llama.go:387: Could not initialize Tensile host: No devices found
2023/11/18 23:08:13 llama.go:395: error starting llama runner: llama runner process has terminated
2023/11/18 23:08:13 llama.go:461: llama runner stopped successfully
2023/11/18 23:08:13 llama.go:372: starting llama runner
2023/11/18 23:08:13 llama.go:430: waiting for llama runner to start responding
{"timestamp":1700329092,"level":"WARNING","function":"server_params_parse","line":871,"message":"Not compiled with GPU offload support, --n-gpu-layers option will be ignored. See main README.md for information on enabling GPU BLAS support","n_gpu_layers":-1}
{"timestamp":1700329093,"level":"INFO","function":"main","line":1323,"message":"build info","build":1412,"commit":"9e70cc0"}
{"timestamp":1700329093,"level":"INFO","function":"main","line":1325,"message":"system info","n_threads":8,"n_threads_batch":-1,"total_threads":16,"system_info":"AVX = 1 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0 | NEON = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | "}

@shamb0 The issue you reported is unrelated to this PR. The rocBLAS library that you installed was not built with your GPU's architecture support, so we can't do anything here. Please use #738 if you need ROCm questions and support.

@purinda I think ollama will pick the 6900xt, but llama won't, which is annoying (I have a similar issue with the iGPU + dGPU on a laptop). Does it work if you run HIP_VISIBLE_DEVICES=1 ollama serve? This is not necessarily ideal, but it might get you out of the edge case. I need to look at how ollama handles this for cuda and see if that can be used here as well...

@65a I have produced a fix to switch the GPU to be used as primary in a multi-GPU environment. PR https://github.com/jmorganca/ollama/pull/1192

We should be able to test this now. I ordered a Radeon 7900 XTX and it just came in, but I still have to pull a machine apart and get it working. Thanks for your patience!

Hi there! It's been a couple of weeks since you mentioned ordering your Radeon 7900 XTX. I'm curious, have you had the chance to test it out yet? I'm particularly interested in knowing how it's performing in terms of stability and speed, especially compared to an NVIDIA card. Looking forward to hearing about your experience!

@tuhochi Still hoping to get this sorted soon, although it's still probably a few weeks out unfortunately. Feel free to ping me on the discord if you want more details.

Note, I will close and delete my branch when #1146 merges.

@ml2s if you haven't sorted it out by now, that's usually a prompting/sampling problem, but there is an issue upstream right now (at llama.cpp) which looks like that. I haven't encountered it on ROCm, but it may be hardware or environment specific.

This would be awesome to have official support, rocm is for sure harder to setup than cuda but I have the gpu I have.

Hi!
This is really an awesome project and I just rebased this pull request to main. And it works with my RX 6800 XT
Is there any specific reason why it's not merged, yet?
And if there are reasons: How could I help?
Thanks in regards!

Fixed merge conflicts on https://github.com/65a/ollama/pull/1

This change is getting carried in #1146 which is just about to go in.

Nice! But one tiny thing I had to add was an additional Environment entry in the service file:
Environment="ROCM_PATH=/opt/rocm"

But other than that it worked out of the box.

For uninitiated like myself, does this mean ollama will support AMD graphics cards like 7900 XTX going forward?

Yes, it should be working in main now. We're seeing > 100 toks/sec on a 7900 xtx w/ the 7b models.

I tried building from source, but got this error (Arch Linux):
❯ ROCM_PATH=/opt/rocm ollama serve
2023/12/24 00:23:11 images.go:828: total blobs: 23
2023/12/24 00:23:11 images.go:835: total unused blobs removed: 0
2023/12/24 00:23:11 routes.go:887: Listening on <IP_ADDRESS>:11434 (version 0.0.0)
2023/12/24 00:23:11 gpu.go:33: Detecting GPU type
2023/12/24 00:23:11 gpu.go:38: CUDA not detected: Unable to load libnvidia-ml.so library to query for Nvidia GPUs: /usr/lib/wsl/lib/libnvidia-ml.so.1: cannot open shared object file: No such file or directory
2023/12/24 00:23:11 gpu.go:47: Radeon GPU detected
[GIN] 2023/12/24 - 00:23:13 | 200 |       31.91µs |       <IP_ADDRESS> | HEAD     "/"
[GIN] 2023/12/24 - 00:23:13 | 200 |     381.366µs |       <IP_ADDRESS> | POST     "/api/show"
[GIN] 2023/12/24 - 00:23:13 | 200 |     279.804µs |       <IP_ADDRESS> | POST     "/api/show"
Lazy loading /tmp/ollama698218904/librocm_server.so library
2023/12/24 00:23:13 shim_ext_server.go:94: Loading Dynamic Shim llm server: /tmp/ollama698218904/librocm_server.so
2023/12/24 00:23:13 gpu.go:131: 11562 MB VRAM available, loading up to 75 ROCM GPU layers out of 32
2023/12/24 00:23:13 ext_server.go:189: Initializing internal llama server
disabling verbose llm logging

# At the time of running the second command below
rocBLAS error: Cannot read /opt/rocm/lib/rocblas/library/TensileLibrary.dat: No such file or directory for GPU arch : gfx1031
 List of available TensileLibrary Files :
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx908.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx1100.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx1030.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx940.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx906.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx90a.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx1102.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx1101.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx942.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx941.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx900.dat"
"/opt/rocm/lib/rocblas/library/TensileLibrary_lazy_gfx803.dat"
[1]    289847 IOT instruction (core dumped)  ROCM_PATH=/opt/rocm ollama serve

❯ ROCM_PATH=/opt/rocm ollama run codellama
Error: Post "http://<IP_ADDRESS>:11434/api/generate": EOF

I ran ls /opt/rocm/lib/rocblas/library and there's a lot of files like TensileLibrary_lazy_gfx1030.dat and TensileLibrary_Type_xxx_xxx_xxxx.dat  but no /opt/rocm/lib/rocblas/library/TensileLibrary.dat.
out.txt

I do not have TensileLibrary.dat in /opt/rocm/lib/rocblas as well.
It's not needed
my outout of ollama serve:
out.txt
There is no mention of TensileLibrary.dat there..
But again I use this branch here rebased onto main (23dc1793500c1e8d9709fb6ed57537f9010a0b84). I don't know what happend on main since then as I haven't checked it out, yet.

After some trial and error (and much appreciated help from the Discord), I got it working! https://discord.com/channels/1128867683291627614/1188401254284669008/1188411154725351485
TL;DR

yay -S git python3 python-virtualenv wget make python-pip rocm-hip-sdk rocm-opencl-sdk gperftools
Add your user to the render and video groups
Reboot!!
Set environment variables HSA_OVERRIDE_GFX_VERSION=10.3.0, HCC_AMDGPU_TARGET=gfx1030, and ROCM_PATH=/opt/rocm
ollama serve and enjoy!

@65a excited to see this get in through #1146. Thanks so much for all of the hard work on ROCm (and the many rebases along the way)

Can someone please tell me how to enable the AMD support? I've installed ollama and it still shows "WARNING: No NVIDIA GPU detected. Ollama will run in CPU-only mode". ollama version is 0.1.19

The pre-release for 0.1.21 is up now, and we've made various improvements to support ROCm cards, covering both v5 and v6 of the ROCm libraries.  You'll have to install ROCm, but then the Ollama binary should work.
Please let us know if you run into any problems by filing new tickets.

Thanks @dhiltgen. Looks like the problem is that ROCm does not support Debian 12.

I have switched to Arch hoping that I could use ollama with AMD support. Posted my issue here:
https://github.com/ollama/ollama/issues/2285
Anyone can help me sort this out?


Not supported on windows insider 17133.1

Hello. This program doesn't work on my windows 10 home insider 17133.1. It's written that: Not listening, [not supported].
I don't know what to do (I'm new here).
Thanks

Duplicate of #442.

Ok thanks. I had problems with permissions, but now I've solved them.


End-to-end implementation user entity

"end-to-end" means code, unit tests, acceptance tests, documentation and submission to terraform registry.
Few notes:

The repo code is just for reference. Please make it right as you see fit.
The github.com/BryanKMorrow/aqua-sdk-go/client referenced from the code is also for reference and if used must be copied to project and refactored as needed.

README is missing some steps. It mentions running go install but the actual provider is built in the Makefile, so without running make install the provider will not be built, just the executable that the provider runs.


Allow user to specify kms key name with nova stash

Currently, a key name of novastash is required.  This should be user configurable with a default value.

Fixed on master


Grafana agent

Add k8s grafana agent installation files
WHAT DOES THIS PR DO?

Adds k8s grafana agent installation files

WHAT JIRA STORY/TASK IS RELATED TO THIS PR?

PLAT-1049

HOW DO I TEST OUT THIS PR?
Assumption: The grafana-agent and grafana-agent-logs config maps have already been created in the cluster(staging) you are testing with

Run kubectl apply -f k8s/grafana/agent/statefulSet.yaml to install the agent statefulSet
Run the k8s/grafana/deploy-kube-state-metrics.sh shell script to deploy the kube-state-metrics
Run k8s/grafana/agent/daemonSet.yaml to install the agent daemonSet

WHICH ENDPOINTS SHOULD BE READY FOR TESTING?:
Kubernetes Integration
IS THERE ANY JENKINS CONSOLE LINK FOR CODE COVERAGE AND BUILD INFO?

N/A

ARE THERE ANY RELATED PRs?

N/A

Hi @123MwanjeMike could you share a link to the sample config maps

Hi @123MwanjeMike could you share a link to the sample config maps

Sure thing @NoahNsimbe
I've updated the description with the link to the config maps

@123MwanjeMike , please add some review comments to your changed files to guide the reviewers. Thanks!

Thanks @Baalmart
Right awaya


Uncaught Error: Could not find module `ember-simple-auth/authenticators/base

Uncaught Error: Could not find module ember-simple-auth/authenticators/base imported from my-auth-test/authenticators/firebase
Any idea how to fix this issue?

I'm having the same issue.