【转载】Ollama指定特定GPU(s)

Original link: https://mlapi.medium.com/how-to-run-ollama-on-specific-gpu-s-8e1369d75c34

Author: mlapi

In this tutorial we will see how to specify any GPU for ollama or multiple GPUs.

Photo by Bonnie Kittle on Unsplash

This tutorials is only for linux machine.

This is very simple, all we need to do is to set CUDA_VISIBLE_DEVICES to a specific GPU(s).

Head over to /etc/systemd/system

cd /etc/systemd/system
cat ollama.service

After priting the output you will see something like this —

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH="

[Install]
WantedBy=default.target

In this just before we server the ollama model we need to set GPU devices like this, so above will look like this

For single GPU

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
Environment="CUDA_VISIBLE_DEVICES=0"
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH="

[Install]
WantedBy=default.target

For multiple GPUs

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
Environment="CUDA_VISIBLE_DEVICES=0,1,2"
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH="

[Install]
WantedBy=default.target

This is it, now restart your service file like this.

sudo systemctl daemon-reload
sudo systemctl restart ollama.service

作 者:motorbottle
链 接: https://blog.motorbottle.site/archives/580
来 源:Motor's Blog
版 权 声 明:本博客所有文章除特别声明(如【转载】)外,均采用CC BY-NC-SA 4.0许可协议。文章版权归作者所有,未经允许请勿转载!


暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇