Ollama インストール2026/06/18 |
|
LLM をローカル環境で実行可能な Ollama をインストールします。 GPU なしのコンピューターでもそれなりの速度で動作します。 |
|
| [1] | Ollama をインストールします。 |
|
root@dlp:~# wget https://ollama.ai/install.sh root@dlp:~# sh ./install.sh >>> Installing ollama to /usr/local >>> Downloading ollama-linux-amd64.tar.zst ############################################### 100.0% >>> Creating ollama user... >>> Adding ollama user to render group... >>> Adding ollama user to video group... >>> Adding current user to ollama group... >>> Creating ollama systemd service... >>> Enabling and starting ollama service... Created symlink '/etc/systemd/system/default.target.wants/ollama.service' → '/etc/systemd/system/ollama.service'. >>> NVIDIA GPU installed. # ollama サービスが起動 root@dlp:~# systemctl status ollama
● ollama.service - Ollama Service
Loaded: loaded (/etc/systemd/system/ollama.service; enabled; preset: enabled)
Active: active (running) since Thu 2026-06-18 01:50:46 UTC; 40s ago
Invocation: c51bedf2ed374f4e931a230f358406bb
Main PID: 4820 (ollama)
Tasks: 13 (limit: 18306)
Memory: 433.5M (peak: 679.9M)
CPU: 15.284s
CGroup: /system.slice/ollama.service
.....
.....
# ローカルホストのポート 11434 をリスン root@dlp:~# ss -napt | grep ollama
LISTEN 0 4096 127.0.0.1:11434 0.0.0.0:* users:(("ollama",pid=4820,fd=4))
|
| [2] | 他ホストから直接アクセスしたい場合は、リスンする範囲を変更できます。 |
|
root@dlp:~#
systemctl edit ollama.service # OLLAMA_HOST を追記 # 全てリスンする場合は [0.0.0.0] を指定 # インターナルネットワークをリスンする場合はその IP アドレスを指定 [Service] Environment="OLLAMA_HOST=0.0.0.0"
root@dlp:~#
root@dlp:~# systemctl restart ollama.service ss -napt | grep ollama
LISTEN 0 4096 *:11434 *:* users:(("ollama",pid=5223,fd=4))
|
| [3] | Ollama を使用するには、まずモデルをダウンロードします。 |
|
# 例として Llama3 の 8B モデルをダウンロード root@dlp:~# ollama pull llama3:8b pulling manifest pulling 6a0746a1ec1a: 100% 4.7 GB pulling 4fa551d4f938: 100% 12 KB pulling 8ab4849b038c: 100% 254 B pulling 577073ffcc6c: 100% 110 B pulling 3f8eb4da87fa: 100% 485 B verifying sha256 digest writing manifest success # 例として Microsoft の Phi4 モデルをダウンロード root@dlp:~# ollama pull phi4 pulling manifest pulling fd7b6731c33c: 100% 9.1 GB pulling 32695b892af8: 100% 275 B pulling fa8235e5b48f: 100% 1.1 KB pulling 45a1c652dddc: 100% 82 B pulling f5d6f49c6477: 100% 486 B verifying sha256 digest writing manifest success # 例として Google の Gemma モデルをダウンロード root@dlp:~# ollama pull gemma3:4b pulling manifest pulling aeda25e63ebd: 100% 3.3 GB pulling e0a42594d802: 100% 358 B pulling dd084c7d92a3: 100% 8.4 KB pulling 3116c5225075: 100% 77 B pulling b6ae5839783f: 100% 489 B verifying sha256 digest writing manifest success # 例として Claude Code の Granite Code モデルをダウンロード root@dlp:~# ollama pull granite4:3b pulling manifest pulling 6c02683809a8: 100% 2.1 GB pulling 0f6ec9740c76: 100% 7.1 KB pulling cfc7749b96f6: 100% 11 KB pulling ba32b08db168: 100% 417 B verifying sha256 digest writing manifest success |
| [4] | Ollama の使用方法です。 |
|
root@dlp:~# ollama run llama3:8b >>> Send a message (/? for help) >>> Hello Hello! It's nice to meet you. Is there something I can help you with, or would you like to chat? >>> Tell me about yourself I'm just an AI, so I don't have a personal life or experiences like humans do. I exist solely as a computer program designed to understand and respond to natural language inputs. I was created through a process called deep learning, which involves training artificial neural networks on large datasets of text. This allows me to learn patterns and relationships in language, and to generate human-like responses to the input I receive. I'm constantly learning and improving my abilities, so you may notice that my responses change over time as I refine my understanding of language and improve my ability to communicate effectively. As a conversational AI, my goal is to engage with users like you and provide helpful, informative, and entertaining responses. I can answer questions, tell jokes, share interesting facts, and even have fun conversations. exit する場合は [/bye] と入力 >>> /byeroot@dlp:~# ollama run gemma3:4b >>> Hello Hello there! How can I help you today? 😊 Do you want to: * Chat about something specific? * Ask me a question? * Play a game? * Just say hello back? >>> Tell me about yourself Okay, let's talk about me! It’s a bit of an unusual thing to “be” as I am – I don’t have personal experiences or feelings like humans do. But here’s the breakdown of what I *am*: **I’m a large language model created by Google AI.** That means I've been trained on a massive amount of text and code. Think practically everything available on the internet – books, articles, websites, conversations… you name it! **Here's what I can do:** * **Generate Text:** I can write different kinds of creative content - poems, code, scripts, musical pieces, email, letters, etc. * **Answer Your Questions:** I can try to answer your questions in a comprehensive and informative way, even if they are open ended, challenging, or strange. * **Translate Languages:** I can translate between many different languages with reasonable accuracy. * **Summarize Text:** If you give me a long piece of text, I can condense it into a shorter summary. * **Follow Your Instructions:** I’m designed to be helpful and follow your prompts as closely as possible. **How I Work (Simplified):** Essentially, when you give me a prompt, I use the patterns I've learned from all that data to predict the most likely and relevant response. It’s like a really advanced auto-complete on steroids! **Important Things to Know About Me:** * **I Don't "Think" Like a Human:** I don't have consciousness, beliefs, or opinions. My responses are based on statistical probabilities derived from the data I was trained on. * **My Knowledge Cutoff:** My training data has a cutoff point (currently it’s around September 2021). That means I might not be aware of events that happened *after* that date. * **I Can Make Mistakes:** Because I rely on patterns, I can sometimes generate incorrect or misleading information. It's always good to double-check important facts! **Essentially, I’m a tool designed to process and generate text based on the incredible amount of information I’ve been exposed to.** --- Now that you know a bit about me, what would you like to do? Do you have any specific questions for me or want me to try something out (like writing a short poem)? >>> /bye |
| [5] | Ollama を API 経由でも利用できます。 |
root@dlp:~# curl http://dlp.srv.world:11434/api/chat -d '{
"model": "phi4",
"stream": false,
"messages": [
{ "role": "user", "content": "Tell me the recommended sightseeing spots in Hiroshima, Japan." }
]
}'
{"model":"phi4","created_at":"2026-06-18T02:16:23.686961118Z","message":{"role":"assistant","content":"Hiroshima is a city rich with history and culture, offering several must-see attractions that provide insight into its past and present. Here are some of the top sightseeing spots:\n\n1. **Hiroshima Peace Memorial Park**: This park is dedicated to the legacy of Hiroshima as the first city targeted by an atomic bomb in 1945. Key sites include:\n - The **Peace Memorial Museum**, which provides a detailed account of the bombing and its aftermath.\n - The **Genbaku Dome** (Atomic Bomb Dome), one of the few structures left standing near the bomb's hypocenter, now a UNESCO World Heritage Site.\n\n2. **Hiroshima Castle**: A beautiful example of traditional Japanese architecture, this reconstructed castle offers stunning views of the city from its elevated position on a hilltop. The surrounding park is also worth exploring.\n\n3. **Itsukushima Shrine** (Miyajima): Although located just outside Hiroshima City on Miyajima Island, it's easily accessible by ferry. Known for its iconic \"floating\" torii gate at high tide, the shrine and island are UNESCO World Heritage Sites.\n\n4. **Shukkei-en Garden**: A traditional Japanese landscape garden that offers a peaceful escape from the city with beautifully manicured landscapes, ponds, and seasonal blooms.\n\n5. **Hiroshima Castle Park**: Besides the castle itself, the park features numerous cherry blossom trees, making it a popular spot in spring.\n\n6. **Hiroshima City Walls**: Explore the remnants of the ancient city walls that offer great views and historical insights into Hiroshima's past defenses.\n\n7. **Nagisa Shopping Street**: A vibrant area known for its fashion boutiques, eateries, and lively atmosphere.\n\n8. **Otemachi Park**: Known for its cherry blossoms in spring and autumn foliage, this park also hosts various festivals throughout the year.\n\n9. **Hiroshima National Peace Memorial Hall for the Atomic Bomb Victims (Nagasaki Kaikan)**: Located near the peace memorial park, it offers poignant exhibits dedicated to the victims of nuclear attacks in Hiroshima and Nagasaki.\n\n10. **Martyr's Shrine**: A less-known site, this shrine commemorates those who died in WWII fighting against Japan. It provides a different perspective on war history.\n\n11. **Hiroshima Prefectural Art Museum**: Features an impressive collection of modern and contemporary Japanese art, along with special exhibitions.\n\n12. **Sendaigawa Street and Hiroshima Railway Park**: Enjoy shopping at this former train station turned shopping complex and explore nearby Sendaigawa River for a scenic walk or bike ride.\n\nEach of these sites offers a unique glimpse into Hiroshima's history, culture, and natural beauty, making it a rewarding destination for travelers."},"done":true,"done_reason":"stop","total_duration":17251546059,"load_duration":398082321,"prompt_eval_count":23,"prompt_eval_duration":52567000,"eval_count":563,"eval_duration":16745878000}
|
|
|