{"id":21012635,"url":"https://github.com/developersdigest/aws-ec2-cuda-ollama","last_synced_at":"2025-04-12T09:12:14.256Z","repository":{"id":251438769,"uuid":"837422351","full_name":"developersdigest/aws-ec2-cuda-ollama","owner":"developersdigest","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-03T02:17:28.000Z","size":6,"stargazers_count":20,"open_issues_count":1,"forks_count":19,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T09:07:40.547Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/developersdigest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-03T00:19:54.000Z","updated_at":"2025-03-26T00:24:05.000Z","dependencies_parsed_at":"2024-08-03T01:57:48.459Z","dependency_job_id":"4183126b-ecd4-4b81-a7fa-9783446e73c2","html_url":"https://github.com/developersdigest/aws-ec2-cuda-ollama","commit_stats":null,"previous_names":["developersdigest/aws-ec2-cuda-ollama"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developersdigest%2Faws-ec2-cuda-ollama","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developersdigest%2Faws-ec2-cuda-ollama/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developersdigest%2Faws-ec2-cuda-ollama/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developersdigest%2Faws-ec2-cuda-ollama/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developersdigest","download_url":"https://codeload.github.com/developersdigest/aws-ec2-cuda-ollama/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248543850,"owners_count":21121838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T09:37:58.021Z","updated_at":"2025-04-12T09:12:14.231Z","avatar_url":"https://github.com/developersdigest.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS EC2 CUDA Ollama Setup\n\nThis guide outlines the steps to set up an Ollama API service on an AWS EC2 instance with CUDA support.\n\n## 1. Launch EC2 Instance\n\na. Go to EC2 dashboard and click \"Launch instance\"\nb. Name your instance (e.g., \"Ollama-GPU-Server\")\nc. AMI: Search for and select \"Deep Learning Base OSS Nvidia Driver GPU AMI (Ubuntu 22.04)\"\nd. Instance type: g4dn.xlarge (4 vCPUs, 16 GiB Memory, 1 GPU)\ne. Create or select a key pair for SSH access\nf. Network settings: Create a security group with the following rules:\n   - Allow SSH (port 22) from your IP\n   - Allow Custom TCP (port 8080) from anywhere (0.0.0.0/0)\ng. Configure storage: At least 30 GiB\nh. Launch the instance\n\n## 2. Connect to EC2 Instance\n\n```\nssh -i your-key.pem ubuntu@your-ec2-public-ip\n```\n\n## 3. Update System\n\n```\nsudo apt update \u0026\u0026 sudo apt upgrade -y\n```\n\n## 4. Install Go\n\n```\nsudo apt install -y golang-go\n```\n\n## 5. Install Ollama\n\n```\ncurl -fsSL https://ollama.com/install.sh | sh\n```\n\n## 6. Clone Repository\n\n```\ngit clone https://github.com/developersdigest/aws-ec2-cuda-ollama.git\ncd aws-ec2-cuda-ollama\n```\n\n## 7. Start Ollama in Background\n\n```\nollama serve \n```\n\n## 8. Pull Gemma Model\n\n```\nollama pull gemma2:2b\n```\n\n## 9. Run Go Application\n\n```\ngo run main.go\n```\n\n## 10. Set Up Systemd Service (Optional)\n\nCreate service file:\n```\nsudo vim /etc/systemd/system/ollama-api.service\n```\n\nAdd the following content:\n```\n[Unit]\nDescription=Ollama API Service\nAfter=network.target\n\n[Service]\nExecStart=/usr/bin/go run /home/ubuntu/aws-ec2-cuda-ollama/main.go\nWorkingDirectory=/home/ubuntu/aws-ec2-cuda-ollama\nUser=ubuntu\nRestart=always\n\n[Install]\nWantedBy=multi-user.target\n```\n\nEnable and start the service:\n```\nsudo systemctl enable ollama-api.service\nsudo systemctl start ollama-api.service\n```\n\n## 11. Test API\n\nFrom your local machine:\n```\ncurl http://ec2-your-ec2.amazonaws.com:8080/v1/chat/completions \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Bearer demo\" \\\n-d '{\n  \"model\": \"gemma2:2b\",\n  \"messages\": [\n    {\"role\": \"user\", \"content\": \"Tell me a story about a brave knight\"}\n  ],\n  \"stream\": true\n}'\n```\n\n## Troubleshooting\n\n- Ensure EC2 instance is running\n- Verify Go application is running\n- Check port 8080 is open in EC2 security group\n- Confirm Ollama is running and \"gemma2:2b\" model is available\n\nTo check service status:\n```\nsudo systemctl status ollama-api.service\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopersdigest%2Faws-ec2-cuda-ollama","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevelopersdigest%2Faws-ec2-cuda-ollama","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopersdigest%2Faws-ec2-cuda-ollama/lists"}