Compare commits

..

4 Commits

Author SHA1 Message Date
8ccd4bc9c5 Update themes/beautifulhugo digest to fd74af4 2024-09-04 18:37:45 +00:00
f6436f302b Translate article
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-09-04 19:38:40 +02:00
8d949e71ed Add image to previous article
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-09-04 19:14:42 +02:00
19afde8c22 New tutorial on launching LocalAI on OVHcloud
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-09-04 19:09:59 +02:00
20 changed files with 486 additions and 1 deletions

View File

@ -1,6 +1,7 @@
---
title: "Cloud-init to deploy LocalAI in the cloud in 5 minutes"
date: !!timestamp '2024-08-27 13:12:00'
image: /post/cloud-init-to-deploy-localai-in-5-minutes/og.webp
tags:
- ai
- container
@ -41,6 +42,7 @@ I was able to test OVH's various GPU machines, available from €0.70/hr to €2
- NVIDIA L4
- NVIDIA L40S
- NVIDIA A100
- NVIDIA H100
Depending on the graphics card, a different version of CUDA will be used.
The above cards are all compatible with CUDA 12, but for other cards it may be necessary to adapt the version in the cloud-init script.

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

View File

@ -0,0 +1,242 @@
---
title: "Master Your AI: Explore Local AI with OVH for Just 1 Dollar"
date: !!timestamp '2024-09-04 11:12:00'
image: /post/evaluate-local-ai-with-ease-on-ovhcloud/og.webp
toc: true
tags:
- ai
- cloud
- hosting
- privacy
---
Today, generative AIs meet many uses, and it would be a shame not to take advantage of them.
However, in the age of the GDPR, it's legitimate to question the exposure of customer or partner data when relying solely on AI providers whose data processing remains opaque.
Having myself participated in the construction of one of these new virtual assistant services, I offer here a simple guide to starting up a machine and evaluating the performance of your AI application, or [to offering your employees access to sovereign AI](https://nextcloud.com/blog/nextcloud-releases-assistant-2-0-and-pushes-ai-as-a-service/), with the aim of easily comparing the different models available.
<!-- more -->
This tutorial will show you how to migrate your existing application from an external provider to your own AI service in the cloud.
## Requirements
To carry out this test, we'll need :
- an OVHcloud account,
- a domain name (hosted by OVH or not),
- a sub-domain dedicated to this experiment,
- an application to be migrated,
- 1 $.
### Domain Name
In the rest of this tutorial, I'll be using the `example.com` domain.
Within this domain, I've reserved the sub-domain `ia` for experimentation.
When you see `ia.example.com.`, feel free to replace it with your own domain.
### Our Example Application
Here's a very basic example of an application using OpenAI's ChatGPT:
```python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"),
)
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Suggest a travel itinerary to visit Norway",
}
],
model="gpt-4",
)
print(chat_completion.choices[0].message.content)
```
It's a simple script that asks a virtual assistant a question and displays its answer in return, on the standard output.
In the case of a more complex application, we'll see that the changes required are minimal and realistic.
### Costs
It costs €1 to rent a machine for an hour, with a graphics card capable of handling a wide range of scenarios.
If you have a more complex application, this may require more than an hour's testing, but we can see that cost is not a decisive factor in not testing.
Note also that OVHcloud is offering a €200 cloud credit for all new Public Cloud projects, giving you the opportunity to evaluate all their GPU-enabled machines, free of charge.
Ready?
## Creating Our Test Machine
OVHcloud offers to [rent machines with graphics cards by the hour](https://www.ovhcloud.com/en/solutions/nvidia/), in their Public Cloud offer.
This is the basis for our evaluation: prices range from €1 to €3 per hour.
### 1. Public Cloud Project
To get started, we'll need to create a Public Cloud project.
Go to the OVH manager console, in the Public Cloud section, to create a new project.
![Create a new project](project-public-cloud.png)
Enter a name for the project, which will only be useful for finding your way around the OVH console later on.
A second screen will ask you for the payment method to be debited.
As this is a cloud offer, the invoice arrives at the end of the month, depending on what you've used during the month.
If this is your first OVHcloud project, don't forget to enter the promo code to benefit from the €200 in credits.
### 2. Start a New Instance
Once you've created your project, all the cloud offerings are just a click away.
The one we're interested in here is “Compute”.
We're going to “Create an instance”:
![Your project's welcome screen](onboarding.png)
#### Instance Type
We want a machine with a graphics card, so go to the GPU tab.
There's a wide choice of machines, with different characteristics in terms of hardware, amount of RAM and graphics card(s).
The best choice for evaluating models is to use those with NVIDIA L4 or NVIDIA L40S graphics cards: L4-90 or L40S-90 respectively.
The latter type of instance is 2 times more expensive per hour, and is only useful if you intend to evaluate larger models such as [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev.
).
![Let's select an L4-90 instance](select-ia-instance.png)
#### Geographical Location
Next, choose a datacenter in which to start the instance.
There may not be one in every datacenter, but that doesn't matter anyway, as this is a simple evaluation.
#### Operating System Selection and Configuration
Next comes the question of the operating system.
I recommend you choose the latest version of Ubuntu to use [the cloud-init script]({{< relref “cloud-init-to-deploy-localai-in-5-minutes” >}}) which will deploy everything you need automatically.
![Select operating system](select-os.png)
Add an SSH key, even though you probably won't need it today:
![Add SSH key](select-ssh-key.png)
#### Instance Configuration
Now comes the instance configuration.
We're going to pass a post-installation script so that the machine is configured as it should be, without having to connect to it:
![We add a post-installation script](select-config-1.png)
Place the contents of the [`cloud-init` script I shared with you in this article]({{< relref “cloud-init-to-deploy-localai-in-5-minutes#machine-with-graphic-map” >}}), in the *small* dedicated text field:
![The added post-installation script](select-config-2.png)
{{% card color="warning" title="Post-installation script" %}}
**⚠️ Don't forget to change the domain name in the `cloud-init` script!**
{{% /card%}}
The post-installation script will automatically install the [LocalAI](https://localai.io/) service.
This is a service that exposes an API fully compatible with OpenAI, but using AI models directly on the machine.
No data is sent outside the machine.
#### Network Mode
Last question: how is the machine connected?
To keep things simple, we choose Public mode, which assigns a public IP to the machine.
![Public mode provides a public IPv4](select-network.png)
This will enable us to contact our AI service without having to go through another service, such as a load balancer.
In a production setup, we'd obviously want to use a *load-balancer*, but it's superfluous here.
#### We're off!
We're off!
All that's left to do is choose the hourly rate, then validate the form to start creating the instance.
The billing method to choose](select-price.png)
Allow 10 minutes before the machine is fully operational:
- 1 minute for OVH to allocate a machine and start it up,
- 8 minutes to run the cloud-init script: configure and download containers, then download templates.
### 3. Domain Name Configuration
While the instance is starting up, we need to configure our domain name to point our sub-domain `ia.example.com.` to our freshly instantiated machine.
Once the creation has been validated, the OVH robots get to work, allocating a public IP to our machine.
The operation takes a few seconds, so click on the button to refresh the list:
![Refresh instance list to obtain public IP](instances-1.png)
If the instance creation is successful, you should have an IP assigned to you:
![The instance list with the public IP of our machine](instances-2.png)
Now we need to create a new sub-domain pointing to this IP.
In the case of OVH, this takes place in the “Web Cloud” section:
![The list of instances with the public IP of our machine](domain-1.png)
We create the sub-domain `ia`, pointing to the IP given by OVH:
![The list of instances with our machine's public IP](domain-add.png)
{{% card color="info" title="Set the TTL" %}}
The TTL indicates the length of time the record will remain in the DNS servers' cache.
Specify a rather low value, such as 60 or 120 (these are seconds), so that you can change machines without waiting too long.
{{% /card%}}
If your DNS provider isn't OVH (and even if it is), you can use [happyDomain to easily modify your domain](https://www.happydomain.org/).
## AI Evaluation
All that remains now is to modify our application so that it uses our AI service rather than OpenAI :
```patch
client = OpenAI(
- api_key=os.environ.get("OPENAI_API_KEY"),
+ endpoint="https://ia.example.com/v1",
)
```
That's it!
As the LocalAI API is compatible, all the services used will work with the local templates.
We should add, however, that the model names are different.
For example, if we have `gpt-4` in LocalAI, it's actually an alias to `phi-2` or `hermes-2-pro-mistral` models, depending on the hardware configuration.
The LocalAI interface allows you to [install other models](https://models.localai.io/).
It may be necessary to test several of them, as each has its advantages and disadvantages.
Take a look at these in particular:
- [flux.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev) for image generation,
- [hermes-3-llama-3.1-8b](https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B) to generate text with interesting reflections.
----
The rapid evolution of generative AI offers extraordinary opportunities, but it also poses challenges, particularly in terms of data protection.
Adopting a more sovereign approach, like the one proposed in this tutorial, allows you to take advantage of technological advances while retaining full control over sensitive data, cost control and flexibility. This will enable you not only to guarantee the confidentiality of your information, but also to tailor AI performance to your specific needs, without depending entirely on external service providers. Remember that the effectiveness of AI depends not only on its technical capabilities, but also on how it is integrated and managed within your infrastructure. By taking charge of these aspects, you can ensure that you remain competitive while complying with current regulations.

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

View File

@ -1,6 +1,7 @@
---
title: "Cloud-init pour déployer LocalAI dans le cloud en 5 minutes"
date: !!timestamp '2024-08-27 13:12:00'
image: /post/cloud-init-to-deploy-localai-in-5-minutes/og.webp
tags:
- ai
- container
@ -10,7 +11,8 @@ tags:
Utiliser les IA génératives sans partager ses données avec des entreprises ou des États qui raffolent de nos données, c'est possible et accessible.
Le monde des logiciels libres regorge d'applications pour évaluer et utiliser les IA génératives. Après de nombreux tests, je vous présente ici le fichier cloud-init pour déployer votre propre instance de LocalAI en moins de 5 minutes.
Le monde des logiciels libres regorge d'applications pour évaluer et utiliser les IA génératives.
Après de nombreux tests, je vous présente ici le fichier cloud-init pour déployer votre propre instance de LocalAI en moins de 5 minutes.
<!-- more -->
@ -41,6 +43,7 @@ J'ai pu tester les différentes machines GPU d'OVH, disponibles entre 0,70 €/h
- NVIDIA L4
- NVIDIA L40S
- NVIDIA A100
- NVIDIA H100
Selon la carte graphique, la version de CUDA utilisée sera différente.
Les cartes ci-dessus sont toutes compatibles avec CUDA 12, mais pour d'autres cartes, il pourra être nécessaire d'adapter la version dans le script `cloud-init`.

View File

@ -0,0 +1,238 @@
---
title: "Maîtrisez votre IA : explorez l'IA locale grâce à OVH et 1 €"
date: !!timestamp '2024-09-04 11:12:00'
image: /post/evaluate-local-ai-with-ease-on-ovhcloud/og.webp
toc: true
tags:
- ai
- cloud
- hosting
- privacy
---
Les IA génératives répondent aujourdhui à de nombreux usages, et il serait dommage de ne pas en tirer parti.
Cependant, à lheure du RGPD, il est légitime de se questionner sur lexposition des données de ses clients ou partenaires lorsquon se repose uniquement sur des prestataires d'IA dont le traitement des données reste opaque.
Ayant moi-même participé à la construction de lun de ces nouveaux services dassistant virtuel, je vous propose ici un guide simple pour démarrer une machine et évaluer les performances de votre application IA, ou [pour offrir à vos employés un accès à une IA souveraine](https://nextcloud.com/blog/nextcloud-releases-assistant-2-0-and-pushes-ai-as-a-service/), dans le but de comparer facilement les différents modèles disponibles.
<!-- more -->
Ce tutoriel vous expliquera comment migrer votre application existante dun prestataire externe vers votre propre service dIA dans le cloud.
## Prérequis
Pour mener à bien ce test, nous allons avoir besoin :
- d'un compte OVHcloud,
- d'un nom de domaine (hébergé par OVH ou non),
- d'un sous-domaine dédié à cette expérimentation,
- d'une application à migrer,
- 1€.
### Nom de domaine
Dans la suite de ce tutoriel, je vais utiliser le domaine `example.com`.
Au sein de ce domaine, j'ai réservé le sous-domaine `ia` à l'expérience.
Lorsque vous verrez `ia.example.com.`, n'hésitez pas à remplacer par votre propre domaine.
### Notre application exemple
Voici un exemple très basique d'application utilisant ChatGPT d'OpenAI :
```python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"),
)
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Propose-moi un itinéraire de voyage pour visiter la Norvège",
}
],
model="gpt-4",
)
print(chat_completion.choices[0].message.content)
```
Il s'agit d'un banal script posant une question à un assistant virtuel et affichant sa réponse en retour, sur la sortie standard.
Dans le cas d'une application plus complexe, nous verrons que les changements à apporter sont minimes et réalistes.
### Coûts
Comptez 1 € pour louer une heure une machine avec une carte graphique suffisante pour gérer de très nombreux cas de figure.
Si vous avez une application plus complexe, cela pourra nécessiter plus d'une heure de test, mais on voit que le coût n'est pas décisif pour ne pas faire ce test.
Notez aussi qu'OVHcloud offre 200 € de crédit cloud pour tout nouveau projet Public Cloud, ce qui laisse la possibilité d'évaluer toutes leurs machines avec GPU, sans frais.
## Création de notre machine de test
OVHcloud propose de [louer des machines avec cartes graphiques à l'heure](https://www.ovhcloud.com/fr/solutions/nvidia/), dans leur offre Public Cloud.
C'est ce sur quoi nous allons nous baser pour faire notre évaluation : les prix vont de 1 à 3 € par heure.
### 1. Projet Public Cloud
Pour commencer, nous allons devoir créer un projet Public Cloud.
Rendez-vous dans la console manager OVH, dans la rubrique Public Cloud, pour créer un nouveau projet.
![Créez un nouveau projet](project-public-cloud.png)
Indiquez un nom pour le projet, il ne sera utile que pour se repérer plus tard dans la console OVH.
Un second écran vous demandera le moyen de paiement à débiter.
S'agissant d'une offre cloud, la facture arrive à la fin du mois selon ce que vous avez consommé dans le mois.
Si c'est votre premier projet OVHcloud, n'oubliez pas d'indiquer le code promo pour bénéficier des 200 € de crédits.
### 2. Démarrer une nouvelle instance
Une fois le projet créé, toutes les offres cloud sont à porté de clic.
Celle qui nous intéressera ici est « Compute ».
Nous allons « Créer une instance » :
![L'écran d'accueil de votre projet](onboarding.png)
#### Le type d'instance
Nous voulons une machine avec une carte graphique, rendez-vous donc dans l'onglet GPU.
Un large choix de machine s'offre à nous, avec différentes caractéristiques en terme de matériel, quantité de RAM et carte(s) graphique(s).
Le meilleur choix pour évaluer les modèles est d'utiliser les modèles avec des cartes graphiques NVIDIA L4 ou NVIDIA L40S : respectivement L4-90 ou L40S-90.
Ce dernier type d'instance est 2 fois plus chère à l'heure et ne se révèle utile uniquement si vous comptez évaluer les modèles les plus gros comme [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev).
![Sélectionnons une instance L4-90](select-ia-instance.png)
#### Emplacement géographique
Choisissez ensuite un datacentre dans lequel démarrer l'instance.
Il n'y en a pas forcément dans tous les datacentres, cela n'a de toute façon pas d'importance s'agissant pour le moment d'une simple évaluation.
#### Choix et configuration du système d'exploitation
Vient ensuite la question du système d'exploitation.
Je vous recommande de choisir la dernière version d'Ubuntu pour utiliser [le script cloud-init]({{< relref "cloud-init-to-deploy-localai-in-5-minutes" >}}) qui déploiera tout le nécessaire automatiquement.
![Sélectionnons le système d'exploitation](select-os.png)
Ajoutez une clef SSH, même si vous n'en aurez vraisemblablement pas besoin aujourd'hui :
![Ajouter une clef SSH](select-ssh-key.png)
#### Configuration de l'instance
Viens maintenant la configuration de l'instance.
Nous allons passer un script de post-installation afin que la machine soit configurée comme il faut, sans avoir à s'y connecter :
![On ajoute un script de post-installation](select-config-1.png)
Placez le contenu du [script `cloud-init` que je vous ai partagé dans cet article]({{< relref "cloud-init-to-deploy-localai-in-5-minutes#machine-avec-carte-graphique" >}}), dans le *petit* champs de texte dédié :
![Le script de post-installation ajouté](select-config-2.png)
{{% card color="warning" title="Script post-installation" %}}
**⚠️ N'oubliez pas de changer le nom de domaine dans le script `cloud-init` !**
{{% /card%}}
Le script de post-installation va automatiquement installer le service [LocalAI](https://localai.io/).
C'est un service qui expose une API entièrement compatible avec OpenAI, mais en utilisant des modèles d'IA directement sur la machine.
Aucune données n'est envoyée en dehors de la machine.
#### Mode réseau
Dernière question, comment la machine est-elle connectée.
Pour aller au plus simple, on choisit le mode Public, qui attribuera une IP publique à la machine.
![Le mode public permet d'avoir une IPv4 publique](select-network.png)
Ceci permettra de contacter notre service d'IA sans besoin de passer par un autre service, tel un répartisseur de charge.
Dans un montage de production, on souhaitera évidemment passer par un *load-balancer*, mais c'est ici superflu.
#### C'est parti !
Il ne reste plus qu'à choisir la tarification à l'heure, puis validez le formulaire pour lancer la création de l'instance.
![Le mode de facturation à choisir](select-price.png)
Comptez 10 minutes à ce stade avant que la machine ne soit pleinement opérationnelle :
- 1 minute pour qu'OVH vous alloue une machine et la démarre,
- 8 minutes pour exécuter le script cloud-init : configuration et téléchargement des conteneurs puis téléchargement des modèles.
### 3. Configurer le nom de domaine
Pendant que l'instance démarre, il faut configurer notre nom de domaine pour faire pointer notre sous-domaine `ia.example.com.` vers notre machine fraîchement instanciée.
Après avoir validé la création, les robots d'OVH se mettent à travailler et vont notamment allouer une IP publique à notre machine.
L'opération prend quelques secondes, cliquez sur le bouton pour rafraîchir la liste :
![Actualisez la liste des instances pour obtenir l'IP publique](instances-1.png)
Si la création de l'instance se passe correctement, vous devriez avoir une IP qui vous est attribuée :
![La liste des instances avec l'IP publique de notre machine](instances-2.png)
Il faut maintenant créer un nouveau sous-domaine pointant vers cette IP.
Dans le cas d'OVH, ça se passe dans la partie « Web Cloud » :
![La liste des instances avec l'IP publique de notre machine](domain-1.png)
On crée le sous-domaine `ia`, pointant sur l'IP donnée par OVH :
![La liste des instances avec l'IP publique de notre machine](domain-add.png)
{{% card color="info" title="Fixer le TTL" %}}
Le TTL indique la durée durant laquelle l'enregistrement restera dans le cache des serveurs DNS.
Indiquez une valeur plutôt basse, comme 60 ou 120 (c'est des secondes), pour pouvoir changer de la machine sans attendre trop longtemps.
{{% /card%}}
Si votre hébergeur DNS n'est pas OVH (et même si c'est OVH d'ailleurs), vous pouvez utiliser [happyDomain pour modifier facilement et sans crainte votre domaine](https://www.happydomain.org/).
## Évaluer l'IA
Reste maintenant à modifier notre application pour qu'elle utilise notre service d'IA et non plus OpenAI :
```patch
client = OpenAI(
- api_key=os.environ.get("OPENAI_API_KEY"),
+ endpoint="https://ia.example.com/v1",
)
```
Eh oui, c'est tout !
L'API de LocalAI étant compatible, tous les services employés fonctionneront avec les modèles locaux.
Ajoutons tout de même que le nom des modèles différents.
Ainsi, si nous avons bien `gpt-4` dans LocalAI, il s'agit en fait d'un alias vers les modèles `phi-2` ou `hermes-2-pro-mistral` selon la configuration matérielle.
L'interface de LocalAI permet [d'installer d'autres modèles](https://models.localai.io/).
Il peut être nécessaire d'en tester plusieurs, car chacun a des avantages et des inconvénients.
Jetez un œil à ceux-ci notamment :
- [flux.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev) pour la génération d'image,
- [hermes-3-llama-3.1-8b](https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B) pour générer du texte avec une réflexion intéressante.
----
L'évolution rapide des IA génératives offre des opportunités extraordinaires, mais elle pose également des défis, notamment en matière de protection des données.
Adopter une approche plus souveraine, comme celle proposée dans ce tutoriel, permet de tirer parti des avancées technologiques tout en gardant un contrôle total sur les données sensibles, de maîtrise des coûts ou encore de flexibilité. Cela vous permettra non seulement de garantir la confidentialité de vos informations, mais aussi dadapter les performances de lIA à vos besoins spécifiques, sans dépendre entièrement de prestataires externes. N'oubliez pas que l'efficacité d'une IA ne repose pas seulement sur ses capacités techniques, mais aussi sur la manière dont elle est intégrée et gérée au sein de votre infrastructure. En prenant en main ces aspects, vous vous assurez de rester compétitif tout en respectant les régulations en vigueur.