@@ -41,19 +41,15 @@ def indentString(input_string, indent_level=4):
41
41
if (instanceNameSuffix ):
42
42
instanceNameSuffix = f"-{ instanceNameSuffix } "
43
43
44
- instanceName = "vllm -managed-instance" + instanceNameSuffix
44
+ instanceName = "ollama -managed-instance" + instanceNameSuffix
45
45
serviceName = getRequiredEnv ("OVH_SERVICE_NAME" )
46
46
sshKeyId = getRequiredEnv ("OVH_SSH_KEY_ID" )
47
47
flavorId = getRequiredEnv ("OVH_INSTANCE_FLAVOR_ID" )
48
48
imageId = getRequiredEnv ("OVH_INSTANCE_IMAGE_ID" )
49
49
region = getRequiredEnv ("OVH_REGION" )
50
50
authToken = getRequiredEnv ("AUTH_TOKEN" )
51
- huggingFaceHubToken = getRequiredEnv ("HUGGING_FACE_HUB_TOKEN" )
52
- s3AccessKeyId = getRequiredEnv ("S3_ACCESS_KEY_ID" )
53
- s3SecretAccessKey = getRequiredEnv ("S3_SECRET_ACCESS_KEY" )
54
- s3ModelPath = getRequiredEnv ("S3_MODEL_PATH" )
55
- s3EndpointUrl = getRequiredEnv ("S3_ENDPOINT_URL" )
56
51
users = os .getenv ("USERS" , "" )
52
+ modelName = getRequiredEnv ("MODEL_NAME" )
57
53
58
54
if users :
59
55
users = f"""
@@ -97,33 +93,32 @@ def indentString(input_string, indent_level=4):
97
93
permissions: "0600"
98
94
owner: ubuntu:ubuntu
99
95
content: |
100
- - path: /opt/vllm /init.sh
96
+ - path: /opt/ollama /init.sh
101
97
owner: ubuntu:ubuntu
102
98
permissions: "0775"
103
99
content: |
104
100
#!/bin/bash
105
101
106
102
# init config
107
- sudo mkdir -p /opt/vllm
103
+ sudo mkdir -p /opt/ollama
108
104
sudo chown -R ubuntu:ubuntu /opt
109
105
sudo chmod -R 0775 /opt
110
106
111
- cd /opt/vllm
107
+ cd /opt/ollama
112
108
cat <<'EOF' > docker-compose.yaml
113
109
{ dockerCompose }
114
110
EOF
115
111
echo "TOKEN={ authToken } " >> .env
116
112
echo "HOST=$(curl -4 ifconfig.me)" >> .env
117
113
echo "CREDENTIALS='$(htpasswd -nBb user { authToken } )'" >> .env
118
- echo "HUGGING_FACE_HUB_TOKEN='{ huggingFaceHubToken } '" >> .env
119
- echo "S3_MODEL_PATH='{ s3ModelPath } '" >> .env
120
- echo "S3_ACCESS_KEY_ID='{ s3AccessKeyId } '" >> .env
121
- echo "S3_SECRET_ACCESS_KEY='{ s3SecretAccessKey } '" >> .env
122
- echo "S3_ENDPOINT_URL='{ s3EndpointUrl } '" >> .env
123
-
114
+
115
+ # Configure Docker to use Nvidia driver
116
+ nvidia-ctk runtime configure --runtime=docker
117
+ systemctl restart docker
118
+
124
119
# up docker compose services
125
120
docker compose up -d --build
126
-
121
+ docker exec ollama-ollama-service-1 ollama run { modelName }
127
122
touch /tmp/runcmd_finished
128
123
129
124
- path: /etc/ssh/sshd_config.d/90-custom-settings.conf
@@ -135,7 +130,7 @@ def indentString(input_string, indent_level=4):
135
130
AllowGroups ubuntu
136
131
137
132
runcmd:
138
- - su - ubuntu -c '/opt/vllm /init.sh > /opt/vllm /init.log 2>&1'
133
+ - su - ubuntu -c '/opt/ollama /init.sh > /opt/ollama /init.log 2>&1'
139
134
140
135
{ users }
141
136
"""
@@ -226,27 +221,6 @@ def findStatusInInstance(response):
226
221
sys .exit (1 )
227
222
logger .info (f"Instance domain: { ip } .nip.io" )
228
223
229
- # url = f"https://{ip}.nip.io/v1/models"
230
- # max_attempts = 120
231
- # wait_time = 5
232
- # attempt = 1
233
- # while attempt <= max_attempts:
234
- # try:
235
- # response = requests.get(url)
236
- # if response.status_code == 401:
237
- # logger.info(f"URL {url} is ready.")
238
- # break
239
- # except requests.ConnectionError:
240
- # pass
241
- # logger.info(f"Attempt {attempt}/{max_attempts}: URL not ready (HTTP status code: {response.status_code if 'response' in locals() else 'Connection error'}). Waiting {wait_time} seconds...")
242
- # time.sleep(wait_time)
243
- # attempt += 1
244
- # else:
245
- # logger.info("URL is not ready after maximum attempts.")
246
- # sys.exit(1)
247
-
248
-
249
-
250
224
elif action == "delete" :
251
225
instanceId = findInstance ()
252
226
if not instanceId :
0 commit comments