Strumenti Utente

Strumenti Sito


calcoloscientifico:cluster:softwareapplicativo:conda_user

Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

Entrambe le parti precedenti la revisioneRevisione precedente
Prossima revisione
Revisione precedente
calcoloscientifico:cluster:softwareapplicativo:conda_user [18/03/2021 11:21] fabio.spatarocalcoloscientifico:cluster:softwareapplicativo:conda_user [18/09/2025 16:48] (versione attuale) – [Working with conda] fabio.spataro
Linea 3: Linea 3:
 Users or groups can build their own environments. Users or groups can build their own environments.
  
-==== Template for users or groups ====+==== General template ==== 
 + 
 +General template that can be used to create personal or group environments:
  
 <code bash hpc-make-condaenv-template.sh> <code bash hpc-make-condaenv-template.sh>
Linea 10: Linea 12:
 set -e set -e
  
-module load miniconda3-test+module load miniconda3
  
 source "$CONDA_PREFIX/etc/profile.d/conda.sh" source "$CONDA_PREFIX/etc/profile.d/conda.sh"
Linea 16: Linea 18:
 CONDAENV_NAME='template' CONDAENV_NAME='template'
 CONDAENV_VERSION=$(date '+%Y.%m.%d') CONDAENV_VERSION=$(date '+%Y.%m.%d')
-PYTHON_VERSION='3.6'+PYTHON_VERSION='3.9'
  
 CONDAENV="${CONDAENV_NAME}-${CONDAENV_VERSION}" CONDAENV="${CONDAENV_NAME}-${CONDAENV_VERSION}"
Linea 36: Linea 38:
     CONDAENV_PREFIX="$CONDA_ENVS_PATH/$CONDAENV"     CONDAENV_PREFIX="$CONDA_ENVS_PATH/$CONDAENV"
     CONDAENV_SYMLNK="$CONDA_ENVS_PATH/$CONDAENV_NAME"     CONDAENV_SYMLNK="$CONDA_ENVS_PATH/$CONDAENV_NAME"
 +fi
 +
 +if [ $UID = 0 ]; then
 +    conda --version
 +    conda update conda
 +    conda --version
 +    echo
 fi fi
  
Linea 41: Linea 50:
 echo "CONDAENV_SYMLNK: $CONDAENV_SYMLNK" echo "CONDAENV_SYMLNK: $CONDAENV_SYMLNK"
 echo echo
-echo -n "Should we proceed with the creation of the condaenv '$CONDAENV_NAME' (yes/no)? "+ 
 +if [ -d "$CONDAENV_PREFIX" ]; then 
 +    echo -n "Should we remove the already existing condaenv '$CONDAENV_NAME' (yes/no)? " 
 + 
 +    read ans 
 + 
 +    case "$ans" in 
 +        [yY]|[yY][Ee][Ss]) 
 +        conda env remove --name "$CONDAENV" 
 +        ;; 
 +        [nN]|[nN][oO]) 
 +        ;; 
 +        *) 
 +        echo 
 +        exec "$0" 
 +        exit 
 +        ;; 
 +    esac 
 +fi 
 + 
 +if [ -d "$CONDAENV_PREFIX" ]; then 
 +    echo -n "Should we proceed with the modification of the condaenv '$CONDAENV_NAME' (yes/no)? " 
 +else 
 +    echo -n "Should we proceed with the creation of the condaenv '$CONDAENV_NAME' (yes/no)? " 
 +fi
  
 read ans read ans
Linea 60: Linea 93:
 conda info conda info
  
-if [ $UID = 0 ]; then +if [ -d "$CONDAENV_PREFIX" ]; then 
-    conda --version +    conda create --yes --prefix "$CONDAENV_PREFIXpython${PYTHON_VERSION:+=$PYTHON_VERSION}
-    conda update conda +
-    conda --version +
-fi +
- +
-if [ -d "$CONDAENV_PREFIX" ]; then +
-    conda env remove --name "$CONDAENV"+
 fi fi
- 
-conda create --yes --name "$CONDAENV" python=$PYTHON_VERSION 
  
 conda activate "$CONDAENV" conda activate "$CONDAENV"
  
 conda install --yes --name "$CONDAENV" \ conda install --yes --name "$CONDAENV" \
---channel conda-forge \ +    --channel conda-forge \ 
-7zip+    xz
  
 conda list || true conda list || true
Linea 91: Linea 116:
 /hpc/share/tools/conda/bin/hpc-make-condaenv-template /hpc/share/tools/conda/bin/hpc-make-condaenv-template
 </code> </code>
 +
 +Customize your script by editing CONDAENV_NAME, PYTHON_VERSION and the "conda install" command.
 +
 +The "conda install" command can be repeated multiple times with different options and parameters.
 +
 +It is also possible to install python packages using the "pip" command.
 +
  
 ==== Creating a user environment ==== ==== Creating a user environment ====
Linea 106: Linea 138:
 Create a script from the template and run it. Create a script from the template and run it.
  
-=== Work session with conda ===+==== Working with conda ===
 + 
 +With conda, you can create, export, list, remove, and update that have different versions of Python and/or packages installed in them. Switching or moving between environments is called activating the environment. 
 + 
 +=== Interactive work session === 
 + 
 +If you want to work at group level change group otherwise skip this step:
  
 <code> <code>
-[<USER>@ui01 ~]$ module load miniconda3 +newgrp <GROUP
-[<USER>@ui01 ~]$ source "$CONDA_PREFIX/etc/profile.d/conda.sh" +</code>
-[<USER>@ui01 ~]$ conda --help +
-[<USER>@ui01 ~]$ conda --version +
-conda 4.9.2+
  
-[<USER>@ui01 ~]$ conda info+Typical work session with conda (CPU):
  
-[<USER>@ui01 ~]$ conda activate+<code> 
 +[<USER>@ui01 ~]$ srun --nodes=1 --ntasks-per-node=2 --partition=cpu --qos=cpu --mem=8G --pty bash
  
-(base) [<USER>@ui01 ~]$ which python+[<USER>@wn80 ~]$ module load miniconda3
  
 +[<USER>@wn80 ~]$ source "$CONDA_PREFIX/etc/profile.d/conda.sh"
 +
 +[<USER>@wn80 ~]$ conda --help
 +
 +[<USER>@wn80 ~]$ conda --version
 +conda 25.7.0
 +
 +[<USER>@wn80 ~]$ conda info
 +
 +[<USER>@wn80 ~]$ conda activate
 +
 +(base) [<USER>@wn80 ~]$ which python
 /hpc/share/tools/miniconda3/bin/python /hpc/share/tools/miniconda3/bin/python
  
-(base) [<USER>@ui01 ~]$ python -V +(base) [<USER>@wn80 ~]$ python -V 
-Python 3.7.4+Python 3.9.18 
 + 
 +(base) [<USER>@wn80 ~]$ conda create --name my_conda_env [...] 
 +(base) [<USER>@wn80 ~]$ conda activate my_conda_env 
 + 
 +(my_conda_env) [<USER>@wn80 ~]$ [...] 
 +(my_conda_env) [<USER>@wn80 ~]$ conda deactivate 
 + 
 +(base) [<USER>@wn80 ~]$ conda deactivate 
 + 
 +[<USER>@wn80 ~]$ exit 
 + 
 +[<USER>@ui01 ~]$ 
 +</code> 
 + 
 +Typical work session with conda (GPU): 
 + 
 +<code> 
 +[<USER>@ui01 ~]$ srun --nodes=1 --ntasks-per-node=2 --partition=gpu --qos=gpu --gres=gpu:p100:1 --mem=8G --pty bash 
 + 
 +[<USER>@wn41 ~]$ module load miniconda3 
 + 
 +[...] 
 + 
 +[<USER>@wn41 ~]$ exit
  
-(base) [<USER>@ui01 ~]$ conda deactivate+[<USER>@ui01 ~]$
 </code> </code>
  
Linea 137: Linea 209:
 === Alternate channels === === Alternate channels ===
  
-To search for alternate channels that may provide the conda package you're looking for, navigate to [[https://anaconda.org]] and use the search bar at the top of the page.+To search for alternate channels that may provide the conda package you're looking for, navigate to [[https://anaconda.org|anaconda.org]] and use the search bar at the top of the page.
  
 To add a new channel: To add a new channel:
Linea 145: Linea 217:
 </code> </code>
  
-=== Environment ===+=== Remove unused packages and caches ===
  
-With conda, you can create, export, list, removeand update [[https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#building-identical-conda-environments|environments]] that have different versions of Python and/or packages installed in them. Switching or moving between environments is called activating the environment.+To remove unused packages and caches 
 + 
 +<code> 
 +conda clean --all 
 +</code>
  
 === Environments list === === Environments list ===
calcoloscientifico/cluster/softwareapplicativo/conda_user.1616062907.txt.gz · Ultima modifica: da fabio.spataro

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki