ollama / ollama

Get up and running with Llama 3.2, Mistral, Gemma 2, and other large language models.
https://ollama.com
MIT License
97.8k stars 7.79k forks source link

rx6800xt is 4xfaster as my new rtx4070ti super #5832

Closed konian71 closed 2 months ago

konian71 commented 3 months ago

What is the issue?

I have a setup with the following specifications:

CPU: AMD Ryzen 5700X RAM: 128GB DDR4-3200, CL16 Old GPU: AMD RX6800XT New GPU: Nvidia RTX4070Ti Super

I am running large language models, specifically Gemma2:32b-fp16 and LLaMA3:70b. All drivers are up to date, and the system was cleaned with DDU before installing the new GPU.

I am very confused because the RTX4070Ti Super takes 21 minutes to complete tasks, whereas the RX6800XT only takes 6 minutes for the same task. The VRAM of the RTX4070Ti Super fills up to 16GB, but the GPU load never exceeds 60% and is mostly near zero. The CPU load with the Nvidia GPU never goes above 80%. In contrast, with the AMD GPU, both the CPU and GPU load approach 100%.

Can you help me understand why this is happening? What is going wrong?

2024/07/21 17:05:23 routes.go:1096: INFO server config env="map[CUDA_VISIBLE_DEVICES: GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: OLLAMA_DEBUG:false OLLAMA_FLASH_ATTENTION:false OLLAMA_HOST:http://0.0.0.0:11434 OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE:5m0s OLLAMA_LLM_LIBRARY: OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MAX_VRAM:0 OLLAMA_MODELS:C:\\Users\\xxx\\.ollama\\models OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:0 OLLAMA_ORIGINS:[http://localhost https://localhost http://localhost:* https://localhost:* http://127.0.0.1 https://127.0.0.1 http://127.0.0.1:* https://127.0.0.1:* http://0.0.0.0 https://0.0.0.0 http://0.0.0.0:* https://0.0.0.0:* app://* file://* tauri://*] OLLAMA_RUNNERS_DIR:C:\\Users\\xxx\\AppData\\Local\\Programs\\Ollama\\ollama_runners OLLAMA_SCHED_SPREAD:false OLLAMA_TMPDIR: ROCR_VISIBLE_DEVICES:]"
time=2024-07-21T17:05:23.370+02:00 level=INFO source=images.go:778 msg="total blobs: 10"
time=2024-07-21T17:05:23.380+02:00 level=INFO source=images.go:785 msg="total unused blobs removed: 0"
time=2024-07-21T17:05:23.383+02:00 level=INFO source=routes.go:1143 msg="Listening on [::]:11434 (version 0.2.7)"
time=2024-07-21T17:05:23.389+02:00 level=INFO source=payload.go:44 msg="Dynamic LLM libraries [cpu cpu_avx cpu_avx2 cuda_v11.3 rocm_v6.1]"
time=2024-07-21T17:05:23.389+02:00 level=INFO source=gpu.go:205 msg="looking for compatible GPUs"
time=2024-07-21T17:05:23.732+02:00 level=INFO source=gpu.go:287 msg="detected OS VRAM overhead" id=GPU-a40844ea-c474-77a6-f1f5-c10603b67d2e library=cuda compute=8.9 driver=12.6 name="NVIDIA GeForce RTX 4070 Ti SUPER" overhead="599.7 MiB"
time=2024-07-21T17:05:23.734+02:00 level=INFO source=types.go:105 msg="inference compute" id=GPU-a40844ea-c474-77a6-f1f5-c10603b67d2e library=cuda compute=8.9 driver=12.6 name="NVIDIA GeForce RTX 4070 Ti SUPER" total="16.0 GiB" available="14.7 GiB"
[GIN] 2024/07/21 - 17:13:47 | 200 |     27.7292ms |       127.0.0.1 | GET      "/api/tags"
[GIN] 2024/07/21 - 17:13:47 | 200 |      2.1085ms |       127.0.0.1 | GET      "/api/tags"
[GIN] 2024/07/21 - 17:13:47 | 200 |      1.0491ms |       127.0.0.1 | GET      "/api/tags"
[GIN] 2024/07/21 - 17:13:47 | 200 |      1.0606ms |       127.0.0.1 | GET      "/api/version"
time=2024-07-21T17:14:05.372+02:00 level=INFO source=memory.go:309 msg="offload to cuda" layers.requested=-1 layers.model=47 layers.offload=10 layers.split="" memory.available="[14.4 GiB]" memory.required.full="54.3 GiB" memory.required.partial="13.6 GiB" memory.required.kv="736.0 MiB" memory.required.allocations="[13.6 GiB]" memory.weights.total="49.2 GiB" memory.weights.repeating="47.0 GiB" memory.weights.nonrepeating="2.2 GiB" memory.graph.full="509.0 MiB" memory.graph.partial="1.4 GiB"
time=2024-07-21T17:14:05.383+02:00 level=INFO source=server.go:383 msg="starting llama server" cmd="C:\\Users\\xxx\\AppData\\Local\\Programs\\Ollama\\ollama_runners\\cuda_v11.3\\ollama_llama_server.exe --model C:\\Users\\xxx\\.ollama\\models\\blobs\\sha256-ed43fde1ebff5c14455b8fd478d7ceed87826031a0f0f2b81361b1030c7560c3 --ctx-size 2048 --batch-size 512 --embedding --log-disable --n-gpu-layers 10 --no-mmap --parallel 1 --port 17987"
time=2024-07-21T17:14:05.418+02:00 level=INFO source=sched.go:437 msg="loaded runners" count=1
time=2024-07-21T17:14:05.420+02:00 level=INFO source=server.go:571 msg="waiting for llama runner to start responding"
time=2024-07-21T17:14:05.467+02:00 level=INFO source=server.go:612 msg="waiting for server to become available" status="llm server error"
INFO [wmain] build info | build=3337 commit="a8db2a9c" tid="16936" timestamp=1721574846
INFO [wmain] system info | n_threads=8 n_threads_batch=-1 system_info="AVX = 1 | AVX_VNNI = 0 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | AVX512_BF16 = 0 | FMA = 0 | NEON = 0 | SVE = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | MATMUL_INT8 = 0 | LLAMAFILE = 0 | " tid="16936" timestamp=1721574846 total_threads=16
INFO [wmain] HTTP server listening | hostname="127.0.0.1" n_threads_http="15" port="17987" tid="16936" timestamp=1721574846
llama_model_loader: loaded meta data with 29 key-value pairs and 508 tensors from C:\Users\xxx\.ollama\models\blobs\sha256-ed43fde1ebff5c14455b8fd478d7ceed87826031a0f0f2b81361b1030c7560c3 (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = gemma2
llama_model_loader: - kv   1:                               general.name str              = gemma-2-27b-it
llama_model_loader: - kv   2:                      gemma2.context_length u32              = 8192
llama_model_loader: - kv   3:                    gemma2.embedding_length u32              = 4608
llama_model_loader: - kv   4:                         gemma2.block_count u32              = 46
llama_model_loader: - kv   5:                 gemma2.feed_forward_length u32              = 36864
llama_model_loader: - kv   6:                gemma2.attention.head_count u32              = 32
llama_model_loader: - kv   7:             gemma2.attention.head_count_kv u32              = 16
llama_model_loader: - kv   8:    gemma2.attention.layer_norm_rms_epsilon f32              = 0.000001
llama_model_loader: - kv   9:                gemma2.attention.key_length u32              = 128
llama_model_loader: - kv  10:              gemma2.attention.value_length u32              = 128
llama_model_loader: - kv  11:                          general.file_type u32              = 1
llama_model_loader: - kv  12:              gemma2.attn_logit_softcapping f32              = 50.000000
llama_model_loader: - kv  13:             gemma2.final_logit_softcapping f32              = 30.000000
llama_model_loader: - kv  14:            gemma2.attention.sliding_window u32              = 4096
llama_model_loader: - kv  15:                       tokenizer.ggml.model str              = llama
llama_model_loader: - kv  16:                         tokenizer.ggml.pre str              = default
llama_model_loader: - kv  17:                      tokenizer.ggml.tokens arr[str,256000]  = ["<pad>", "<eos>", "<bos>", "<unk>", ...
time=2024-07-21T17:14:06.220+02:00 level=INFO source=server.go:612 msg="waiting for server to become available" status="llm server loading model"
llama_model_loader: - kv  18:                      tokenizer.ggml.scores arr[f32,256000]  = [0.000000, 0.000000, 0.000000, 0.0000...
llama_model_loader: - kv  19:                  tokenizer.ggml.token_type arr[i32,256000]  = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, ...
llama_model_loader: - kv  20:                tokenizer.ggml.bos_token_id u32              = 2
llama_model_loader: - kv  21:                tokenizer.ggml.eos_token_id u32              = 1
llama_model_loader: - kv  22:            tokenizer.ggml.unknown_token_id u32              = 3
llama_model_loader: - kv  23:            tokenizer.ggml.padding_token_id u32              = 0
llama_model_loader: - kv  24:               tokenizer.ggml.add_bos_token bool             = true
llama_model_loader: - kv  25:               tokenizer.ggml.add_eos_token bool             = false
llama_model_loader: - kv  26:                    tokenizer.chat_template str              = {{ bos_token }}{% if messages[0]['rol...
llama_model_loader: - kv  27:            tokenizer.ggml.add_space_prefix bool             = false
llama_model_loader: - kv  28:               general.quantization_version u32              = 2
llama_model_loader: - type  f32:  185 tensors
llama_model_loader: - type  f16:  323 tensors
llm_load_vocab: special tokens cache size = 364
llm_load_vocab: token to piece cache size = 1.6014 MB
llm_load_print_meta: format           = GGUF V3 (latest)
llm_load_print_meta: arch             = gemma2
llm_load_print_meta: vocab type       = SPM
llm_load_print_meta: n_vocab          = 256000
llm_load_print_meta: n_merges         = 0
llm_load_print_meta: vocab_only       = 0
llm_load_print_meta: n_ctx_train      = 8192
llm_load_print_meta: n_embd           = 4608
llm_load_print_meta: n_layer          = 46
llm_load_print_meta: n_head           = 32
llm_load_print_meta: n_head_kv        = 16
llm_load_print_meta: n_rot            = 128
llm_load_print_meta: n_swa            = 4096
llm_load_print_meta: n_embd_head_k    = 128
llm_load_print_meta: n_embd_head_v    = 128
llm_load_print_meta: n_gqa            = 2
llm_load_print_meta: n_embd_k_gqa     = 2048
llm_load_print_meta: n_embd_v_gqa     = 2048
llm_load_print_meta: f_norm_eps       = 0.0e+00
llm_load_print_meta: f_norm_rms_eps   = 1.0e-06
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: f_logit_scale    = 0.0e+00
llm_load_print_meta: n_ff             = 36864
llm_load_print_meta: n_expert         = 0
llm_load_print_meta: n_expert_used    = 0
llm_load_print_meta: causal attn      = 1
llm_load_print_meta: pooling type     = 0
llm_load_print_meta: rope type        = 2
llm_load_print_meta: rope scaling     = linear
llm_load_print_meta: freq_base_train  = 10000.0
llm_load_print_meta: freq_scale_train = 1
llm_load_print_meta: n_ctx_orig_yarn  = 8192
llm_load_print_meta: rope_finetuned   = unknown
llm_load_print_meta: ssm_d_conv       = 0
llm_load_print_meta: ssm_d_inner      = 0
llm_load_print_meta: ssm_d_state      = 0
llm_load_print_meta: ssm_dt_rank      = 0
llm_load_print_meta: model type       = 27B
llm_load_print_meta: model ftype      = F16
llm_load_print_meta: model params     = 27.23 B
llm_load_print_meta: model size       = 50.72 GiB (16.00 BPW) 
llm_load_print_meta: general.name     = gemma-2-27b-it
llm_load_print_meta: BOS token        = 2 '<bos>'
llm_load_print_meta: EOS token        = 1 '<eos>'
llm_load_print_meta: UNK token        = 3 '<unk>'
llm_load_print_meta: PAD token        = 0 '<pad>'
llm_load_print_meta: LF token         = 227 '<0x0A>'
llm_load_print_meta: EOT token        = 107 '<end_of_turn>'
llm_load_print_meta: max token length = 93
ggml_cuda_init: GGML_CUDA_FORCE_MMQ:    no
ggml_cuda_init: GGML_CUDA_FORCE_CUBLAS: no
ggml_cuda_init: found 1 CUDA devices:
  Device 0: NVIDIA GeForce RTX 4070 Ti SUPER, compute capability 8.9, VMM: yes
llm_load_tensors: ggml ctx size =    0.45 MiB
llm_load_tensors: offloading 10 repeating layers to GPU
llm_load_tensors: offloaded 10/47 layers to GPU
llm_load_tensors:  CUDA_Host buffer size = 43382.55 MiB
llm_load_tensors:      CUDA0 buffer size = 10800.70 MiB
llama_new_context_with_model: n_ctx      = 2048
llama_new_context_with_model: n_batch    = 512
llama_new_context_with_model: n_ubatch   = 512
llama_new_context_with_model: flash_attn = 0
llama_new_context_with_model: freq_base  = 10000.0
llama_new_context_with_model: freq_scale = 1
llama_kv_cache_init:  CUDA_Host KV buffer size =   576.00 MiB
llama_kv_cache_init:      CUDA0 KV buffer size =   160.00 MiB
llama_new_context_with_model: KV self size  =  736.00 MiB, K (f16):  368.00 MiB, V (f16):  368.00 MiB
llama_new_context_with_model:  CUDA_Host  output buffer size =     0.99 MiB
llama_new_context_with_model:      CUDA0 compute buffer size =  2759.00 MiB
llama_new_context_with_model:  CUDA_Host compute buffer size =    17.01 MiB
llama_new_context_with_model: graph nodes  = 1850
llama_new_context_with_model: graph splits = 472
INFO [wmain] model loaded | tid="16936" timestamp=1721574907
time=2024-07-21T17:15:07.935+02:00 level=INFO source=server.go:617 msg="llama runner started in 62.52 seconds"
[GIN] 2024/07/21 - 17:16:00 | 200 |         1m55s |       127.0.0.1 | POST     "/api/chat"

OS

Windows

GPU

Nvidia

CPU

AMD

Ollama version

0.2.7

rick-github commented 3 months ago

Would you happen to have logs from when the RX6800XT was plugged in?

konian71 commented 3 months ago

Would you happen to have logs from when the RX6800XT was plugged in?

I'm sorry, but the old logs were deleted because I tried to fix the problem with a fresh install of Ollama.

dhiltgen commented 3 months ago

There are a lot of variables in your setup, so it's hard to say for certain.

From the log you shared, I see your Nvidia GPU has 14.7G available, and you only were able to load 10/47 layers to GPU. This indicates the vast majority of your inference is taking place on your CPU, not your GPU. If we had logs from the Radeon setup we could compare to see if the number of layers was significantly different, or if there's something else causing a disparity in performance.

Using a smaller model that mostly or completely fits in the GPU should yield significantly better performance. If you really need to use the larger model, you could try forcing it to run exclusively on the CPU and then use the cpu_avx2 runner to see if that performs better.

dhiltgen commented 2 months ago

If you're still seeing performance disparity, please make sure you're running the latest version and share a server log of the AMD GPU and NVIDIA GPU loading the same model so we can try to understand what's going on better.