-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): new virtual environments section (#1910)
- Loading branch information
1 parent
4802888
commit 55115ca
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Virtual Environments | ||
|
||
![Virtual Environments](../images/custom-launchers.png) | ||
|
||
When conducting data science experiments, it's a best practice to utilize Python and/or conda virtual environments to manage your project dependencies. It is common to create a dedicated environment for each project or, in some cases, separate environments for different features or aspects of your work (for instance, one environment for general projects and an additional environment tailored for GPU-accelerated deep learning tasks). | ||
|
||
If you find yourself frequently switching between environments and desire a more convenient way to access them within JupyterLab, you can follow these instructions: | ||
|
||
### Creating and Adding Environments to the JupyterLab Launcher | ||
|
||
#### Step 1: Create the Environment | ||
|
||
Open a terminal session and run the following code to create a new virtual environment. You can use either conda or python venv based on your preferences and project requirements. Each has its own advantages: | ||
|
||
#### Using conda: | ||
|
||
```bash | ||
conda create -n torch | ||
``` | ||
|
||
##### Advantages of conda: | ||
|
||
- Manages both Python packages and environments. | ||
- Simplifies package management, including non-Python libraries and dependencies. | ||
|
||
#### Using venv: | ||
|
||
```bash | ||
python -m venv torch | ||
``` | ||
|
||
##### Advantages of venv: | ||
|
||
- Part of the Python standard library (no separate installation required). | ||
- Provides a lightweight, Python-centric virtual environment. | ||
|
||
#### Step 2: Add the Environment to the Launcher | ||
|
||
After creating the environment, add it to the JupyterLab Launcher with the following command: | ||
|
||
```bash | ||
python -m ipykernel install --user --name "torch" --display-name "PyTorch" | ||
``` | ||
|
||
- `--name "torch"` specifies the name of the kernel (replace "torch" as needed). | ||
- `--display-name "PyTorch"` sets the display name for the kernel in the JupyterLab Launcher (customize as necessary). | ||
|
||
#### Step 3: Refresh JupyterLab | ||
|
||
To see the changes in the JupyterLab Launcher, refresh your browser by either clicking the refresh button or using the keyboard shortcut F5. | ||
|
||
These steps enable you to seamlessly manage your Python environments and access them conveniently from the JupyterLab Launcher, fostering a more organized and efficient workflow for your data science experiments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Environnements virtuels | ||
|
||
![Environnements virtuels](../images/custom-launchers.png) | ||
|
||
Lorsque vous effectuez des expériences de science des données, il est recommandé d'utiliser des environnements virtuels Python et/ou conda pour gérer les dépendances de votre projet. Il est courant de créer un environnement dédié pour chaque projet ou, dans certains cas, des environnements distincts pour différentes fonctionnalités ou aspects de votre travail (par exemple, un environnement pour les projets généraux et un environnement supplémentaire adapté aux tâches d'apprentissage en profondeur accélérées par GPU). | ||
|
||
Si vous basculez fréquemment entre les environnements et souhaitez un moyen plus pratique d'y accéder dans JupyterLab, vous pouvez suivre ces instructions : | ||
|
||
### Création et ajout d'environnements au lanceur JupyterLab | ||
|
||
#### Étape 1 : Créer l'environnement | ||
|
||
Ouvrez une session de terminal et exécutez le code suivant pour créer un nouvel environnement virtuel. Vous pouvez utiliser conda ou python venv en fonction de vos préférences et des exigences du projet. Chacun a ses propres avantages : | ||
|
||
#### Utilisation de conda : | ||
|
||
```bash | ||
conda create -n torch | ||
``` | ||
|
||
##### Avantages de conda : | ||
|
||
- Gère à la fois les packages et les environnements Python. | ||
- Simplifie la gestion des packages, y compris les bibliothèques et dépendances non Python. | ||
|
||
#### Utilisation de venv : | ||
|
||
```bash | ||
python -m torch venv | ||
``` | ||
|
||
##### Avantages de venv : | ||
|
||
- Fait partie de la bibliothèque standard Python (aucune installation séparée requise). | ||
- Fournit un environnement virtuel léger et centré sur Python. | ||
|
||
#### Étape 2 : Ajouter l'environnement au lanceur | ||
|
||
Après avoir créé l'environnement, ajoutez-le au lanceur JupyterLab avec la commande suivante : | ||
|
||
```bash | ||
python -m ipykernel install --user --name "torch" --display-name "PyTorch" | ||
``` | ||
|
||
- `--name "torch"` spécifie le nom du noyau (remplacez "torch" si nécessaire). | ||
- `--display-name "PyTorch"` définit le nom d'affichage du noyau dans le lanceur JupyterLab (personnalisez si nécessaire). | ||
|
||
#### Étape 3 : Actualiser JupyterLab | ||
|
||
Pour voir les modifications dans le lanceur JupyterLab, actualisez votre navigateur en cliquant sur le bouton d'actualisation ou en utilisant le raccourci clavier F5. | ||
|
||
Ces étapes vous permettent de gérer de manière transparente vos environnements Python et d'y accéder facilement depuis le lanceur JupyterLab, favorisant ainsi un flux de travail plus organisé et plus efficace pour vos expériences de science des données. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters