Prerequisites

Developers can access the power of both Windows and Linux at the same time on a Windows machine. The Windows Subsystem for Linux (WSL) lets developers install a Linux distribution (such as Ubuntu, OpenSUSE, Kali, Debian, Arch Linux, etc) and use Linux applications, utilities, and Bash command-line tools directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

[https://learn.microsoft.com/en-us/windows/wsl/install]

You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11 to use the commands below. If you are on earlier versions please see the manual install page.

Install WSL command

You can now install everything you need to run WSL with a single command. Open PowerShell or Windows Command Prompt in user mode (for CarHab) enter the

wsl --install command, then restart your machine.

If stuck

If the install is stuck at 0%, run wsl --update as admin first.

By default, the installed Linux distribution will be Ubuntu. This can be changed using the -d flag.

  • To change the distribution installed, enter: wsl --install -d <Distribution Name>. Replace <Distribution Name> with the name of the distribution you would like to install.
  • To see a list of available Linux distributions available for download through the online store, enter: wsl --list --online or wsl -l -o.
  • To install additional Linux distributions after the initial install, you may also use the command: wsl --install -d <Distribution Name>.

Configure DNS and Proxy

DNS Config

1. Turn off generation of /etc/resolv.conf

Using your Linux prompt, (I'm using Ubuntu), modify (or create) /etc/wsl.conf with the following content

[network]
generateResolvConf = false

(Apparently there's a bug in the current release where any trailing whitespace on these lines will trip things up.)

2. Restart the WSL2 Virtual Machine

Exit all of your Linux prompts and run the following Powershell command

wsl --shutdown

3. Create a custom /etc/resolv.conf

Open a new Linux prompt and cd to /etc

If resolv.conf is soft linked to another file, remove the link with

rm resolv.conf

Create a new resolv.conf with the following content

nameserver 161.X.X.XX 161.X.X.XX
search univ-st-etienne.fr

Replacing X with the correct server addresses.

4. Restart the WSL2 Virtual Machine

Same as step #2

5. Start a new Linux prompt.

Profit!

Proxy settings

Environnement global

Le fichier /etc/profile est lu au démarrage du système.

Modifiez le fichier /etc/profile ajouter cette ligne à la fin du fichier:

export http_proxy=http://"proxy_address":"port_number"

où "proxy_address" et "port_number" seront adaptés à votre situation

Environnement bash

Le fichier /etc/bash.bashrc est lu au démarrage de votre terminal.

Modifiez le fichier /etc/bash.bashrc Puis ajoutez à la fin du fichier

export http_proxy=http://"proxy_ip":"port_number"

où "proxy_ip" et "port_number" seront adaptés à votre situation

Wget

wget permet à différents scripts de télécharger des données.

modifier le fichier /etc/wgetrc recherchez et décommentez les lignes (enlevez les # en début de lignes)

http_proxy = http://proxy.yoyodyne.com:18023/
use_proxy = on

en remplaçant les paramètres du proxy.

Apt

apt est le programme qui télécharge et installe les mises à jour.

Créer un fichier /etc/apt/apt.conf.d/proxyPerso.conf ajoutez la ligne suivante

Acquire::http::proxy "http://adresse:port/";

en remplaçant adresse par l'adresse du proxy, et port par le port.

Désactiver le proxy

Ponctuellement

Pour désactiver le proxy http ou https pendant la session de travail :

$ unset http_proxy
$ unset https_proxy
ou
$ export http_proxy=''
$ export https_proxy=''
vérifier avec 
$ printenv 
ou 
$ printenv https_proxy

Durablement

suivre la procédure inverse des chapitres précedents expliquant la modification des fichiers, en supprimant les lignes en question.

Install miniconda as package manager

You can check whether you have the correct Ubuntu version installed on your server with the following command:
lsb_release -a

You should get this output:

No LSB modules are available.  
Distributor ID: Ubuntu  
Description: Ubuntu 22.04.1 LTS  
Release: 22.04  
Codename: jammy

Let’s update the package index on our Ubuntu 22.04 system : apt update

Step 2. Download Miniconda Installer

The process is very simple; we need to download the installer script. We have to do this because Miniconda is not available in the default Ubuntu repository. So, let’s get it downloaded.

sudo wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /opt/miniconda-installer.sh

The Miniconda installer script has been downloaded and saved as /opt/miniconda-installer.sh

Step 3. Install Miniconda

The installation will be easy and straightforward. Simply execute the installer file.

bash /opt/miniconda-installer.sh

Follow the instructions shown on the screen. We need to press ENTER to review the license agreement. Keep pressing ENTER or SPACE to finish it. , At the end of the agreement, you will be asked to accept the license terms or not. Type ‘yes’ to accept and continue.

Next, you will be shown this option below.

Miniconda3 will now be installed into this location:
/root/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

Just press ENTER and continue.

Once the installation is finished, you will be prompted to start Miniconda or not.

Do you wish the installer to initialize Miniconda3  
by running conda init? [yes|no]  
[no] >>>

Type ‘yes’, then hit ENTER. You should see this as an output.

no change     /root/miniconda3/condabin/conda
no change     /root/miniconda3/bin/conda
no change     /root/miniconda3/bin/conda-env
no change     /root/miniconda3/bin/activate
no change     /root/miniconda3/bin/deactivate
no change     /root/miniconda3/etc/profile.d/conda.sh
no change     /root/miniconda3/etc/fish/conf.d/conda.fish
no change     /root/miniconda3/shell/condabin/Conda.psm1
no change     /root/miniconda3/shell/condabin/conda-hook.ps1
no change     /root/miniconda3/lib/python3.11/site-packages/xontrib/conda.xsh
no change     /root/miniconda3/etc/profile.d/conda.csh
modified      /root/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

If you'd prefer that conda's base environment not be activated on startup, 
   set the auto_activate_base parameter to false: 

conda config --set auto_activate_base false

Thank you for installing Miniconda3!

That’s it! You have just installed Miniconda.

Step 4. Configure Miniconda

After the Miniconda installation, we need to apply the changes made to ~/.bashrc file. Miniconda installer modified the file during the installation. Let’s execute the command.

source ~/.bashrc
to activate : source /home/brazma/miniconda3/bin/activate

Now, at this point, you can run this command to check your Miniconda information.

conda info

You will see this output:

     active environment : base
    active env location : /root/miniconda3
            shell level : 1
       user config file : /root/.condarc
 populated config files : 
          conda version : 23.5.2
    conda-build version : not installed
         python version : 3.11.4.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.35=0
                          __linux=5.15.0=0
                          __unix=0=0
       base environment : /root/miniconda3  (writable)
      conda av data dir : /root/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /root/miniconda3/pkgs
                          /root/.conda/pkgs
       envs directories : /root/miniconda3/envs
                          /root/.conda/envs
               platform : linux-64
             user-agent : conda/23.5.2 requests/2.29.0 CPython/3.11.4 Linux/5.15.0-76-generic ubuntu/22.04 glibc/2.35
                UID:GID : 0:0
             netrc file : None
           offline mode : False

If you want to update Miniconda, you can run this command:

conda update --all

If updates are available, it will show you a list of packages to update, and you need to answer with yes to proceed with the update.

(base) root@ubuntu22:~# conda update --all
Collecting package metadata (current_repodata.json): done
Solving environment: done


 Package Plan 

  environment location: /root/miniconda3


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2023.7.22          |  py311h06a4308_0         154 KB
    conda-23.7.2               |  py311h06a4308_0         1.3 MB
    conda-libmamba-solver-23.7.0|  py311h06a4308_0          90 KB
    conda-package-handling-2.2.0|  py311h06a4308_0         278 KB
    conda-package-streaming-0.9.0|  py311h06a4308_0          33 KB
    libcurl-8.1.1              |       h251f7ec_2         397 KB
    openssl-3.0.10             |       h7f8727e_0         5.2 MB
    pip-23.2.1                 |  py311h06a4308_0         3.3 MB
    pyopenssl-23.2.0           |  py311h06a4308_0         121 KB
    requests-2.31.0            |  py311h06a4308_0         124 KB
    setuptools-68.0.0          |  py311h06a4308_0         1.2 MB
    ------------------------------------------------------------
                                           Total:        12.2 MB

Press y, then hit ENTER to proceed.

Conda proxy

Use the command line below from version 4.4.x.

conda config --set proxy_servers.http http://cache.univ-st-etienne.fr:port
conda config --set proxy_servers.https http://cache.univ-st-etienne.fr:port

Installing RapidsAI (for GPU AI work) on your WSL2 machine

You can then install (Finally) the rapidsai package , check the official website : Installation guide

Install the packages by typing y when required, and the following message should display :

Proceed ([y]/n)? y


Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: -
done
To activate this environment, use
#
#     $ conda activate rapids-23.10
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Then use the command conda activate rapids-23.10 to activate the rapidsai conda environment ! Then run python3 to test the installation and run the following script :

import cudf
>>> print(cudf.Series([1, 2, 3]))
0    1
1    2
2    3
dtype: int64