wsl中ollama不能使用gpu加速

之前还能有gpu加速的, 突然一次发现不能加速了, 启动之后发现只能用cpu了

log

time=2024-04-19T00:05:08.213+08:00 level=INFO source=images.go:806 msg="total blobs: 80"
time=2024-04-19T00:05:08.248+08:00 level=INFO source=images.go:813 msg="total unused blobs removed: 43"
time=2024-04-19T00:05:08.249+08:00 level=INFO source=routes.go:1110 msg="Listening on 127.0.0.1:11434 (version 0.1.29)"
time=2024-04-19T00:05:08.250+08:00 level=INFO source=payload_common.go:112 msg="Extracting dynamic libraries to /tmp/ollama3092358058/runners ..."
time=2024-04-19T00:05:15.442+08:00 level=INFO source=payload_common.go:139 msg="Dynamic LLM libraries [cpu_avx rocm_v60000 cuda_v11 cpu_avx2 cpu]"
time=2024-04-19T00:05:15.442+08:00 level=INFO source=gpu.go:77 msg="Detecting GPU type"
time=2024-04-19T00:05:15.442+08:00 level=INFO source=gpu.go:191 msg="Searching for GPU management library libnvidia-ml.so"
time=2024-04-19T00:05:17.729+08:00 level=INFO source=gpu.go:237 msg="Discovered GPU libraries: [/usr/lib/x86_64-linux-gnu/libnvidia-ml.so.535.171.04 /usr/lib/wsl/lib/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_059948e396d205d5/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_268e85175aa9e991/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_36f8a434e9b7b9f2/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_84b2c943d6816eb7/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_abf7e4e84f20581c/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_d1bd230cd08e7436/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_f52c4b8723f8dd33/libnvidia-ml.so.1]"
time=2024-04-19T00:05:17.758+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/x86_64-linux-gnu/libnvidia-ml.so.535.171.04: nvml vram init failure: 9"
time=2024-04-19T00:05:17.762+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/wsl/lib/libnvidia-ml.so.1: nvml vram init failure: 9"
time=2024-04-19T00:05:17.831+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/wsl/drivers/nv_dispi.inf_amd64_059948e396d205d5/libnvidia-ml.so.1: nvml vram init failure: 3"
time=2024-04-19T00:05:17.881+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/wsl/drivers/nv_dispi.inf_amd64_268e85175aa9e991/libnvidia-ml.so.1: nvml vram init failure: 3"
time=2024-04-19T00:05:17.931+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/wsl/drivers/nv_dispi.inf_amd64_36f8a434e9b7b9f2/libnvidia-ml.so.1: nvml vram init failure: 3"
time=2024-04-19T00:05:17.971+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/wsl/drivers/nv_dispi.inf_amd64_84b2c943d6816eb7/libnvidia-ml.so.1: nvml vram init failure: 3"
time=2024-04-19T00:05:18.038+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/wsl/drivers/nv_dispi.inf_amd64_abf7e4e84f20581c/libnvidia-ml.so.1: nvml vram init failure: 3"
time=2024-04-19T00:05:18.082+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/wsl/drivers/nv_dispi.inf_amd64_d1bd230cd08e7436/libnvidia-ml.so.1: nvml vram init failure: 3"
time=2024-04-19T00:05:18.130+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/wsl/drivers/nv_dispi.inf_amd64_f52c4b8723f8dd33/libnvidia-ml.so.1: nvml vram init failure: 3"
time=2024-04-19T00:05:18.130+08:00 level=INFO source=cpu_common.go:11 msg="CPU has AVX2"
time=2024-04-19T00:05:18.131+08:00 level=INFO source=routes.go:1133 msg="no GPU detected"

导致的原因可能是机器休眠过了, wsl的虚拟机不知道如何重连gpu修改正方法是重启wsl,

wsl --shutdown

修复之后的log如下:

time=2024-04-19T00:07:52.288+08:00 level=INFO source=images.go:806 msg="total blobs: 37"
time=2024-04-19T00:07:52.297+08:00 level=INFO source=images.go:813 msg="total unused blobs removed: 0"
time=2024-04-19T00:07:52.297+08:00 level=INFO source=routes.go:1110 msg="Listening on 127.0.0.1:11434 (version 0.1.29)"
time=2024-04-19T00:07:52.299+08:00 level=INFO source=payload_common.go:112 msg="Extracting dynamic libraries to /tmp/ollama1882281951/runners ..."
time=2024-04-19T00:07:54.749+08:00 level=INFO source=payload_common.go:139 msg="Dynamic LLM libraries [cpu_avx2 rocm_v60000 cpu_avx cuda_v11 cpu]"
time=2024-04-19T00:07:54.749+08:00 level=INFO source=gpu.go:77 msg="Detecting GPU type"
time=2024-04-19T00:07:54.751+08:00 level=INFO source=gpu.go:191 msg="Searching for GPU management library libnvidia-ml.so"
time=2024-04-19T00:07:56.867+08:00 level=INFO source=gpu.go:237 msg="Discovered GPU libraries: [/usr/lib/x86_64-linux-gnu/libnvidia-ml.so.535.171.04 /usr/lib/wsl/lib/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_059948e396d205d5/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_268e85175aa9e991/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_36f8a434e9b7b9f2/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_84b2c943d6816eb7/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_abf7e4e84f20581c/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_d1bd230cd08e7436/libnvidia-ml.so.1 /usr/lib/wsl/drivers/nv_dispi.inf_amd64_f52c4b8723f8dd33/libnvidia-ml.so.1]"
time=2024-04-19T00:07:56.878+08:00 level=INFO source=gpu.go:249 msg="Unable to load CUDA management library /usr/lib/x86_64-linux-gnu/libnvidia-ml.so.535.171.04: nvml vram init failure: 9"
time=2024-04-19T00:07:56.927+08:00 level=INFO source=gpu.go:82 msg="Nvidia GPU detected"
time=2024-04-19T00:07:56.927+08:00 level=INFO source=cpu_common.go:11 msg="CPU has AVX2"
time=2024-04-19T00:07:56.941+08:00 level=INFO source=gpu.go:119 msg="CUDA Compute Capability detected: 8.6"
相关推荐
Martin -Tang20 分钟前
vite和webpack的区别
前端·webpack·node.js·vite
迷途小码农零零发20 分钟前
解锁微前端的优秀库
前端
王解1 小时前
webpack loader全解析,从入门到精通(10)
前端·webpack·node.js
我不当帕鲁谁当帕鲁1 小时前
arcgis for js实现FeatureLayer图层弹窗展示所有field字段
前端·javascript·arcgis
那一抹阳光多灿烂1 小时前
工程化实战内功修炼测试题
前端·javascript
放逐者-保持本心,方可放逐2 小时前
微信小程序=》基础=》常见问题=》性能总结
前端·微信小程序·小程序·前端框架
PcVue China2 小时前
PcVue + SQL Grid : 释放数据的无限潜力
大数据·服务器·数据库·sql·科技·安全·oracle
毋若成4 小时前
前端三大组件之CSS,三大选择器,游戏网页仿写
前端·css
舞动CPU4 小时前
linux c/c++最高效的计时方法
linux·运维·服务器
红中马喽4 小时前
JS学习日记(webAPI—DOM)
开发语言·前端·javascript·笔记·vscode·学习