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:24] fabio.spatarocalcoloscientifico:cluster:softwareapplicativo:conda_user [16/01/2025 17:02] (versione attuale) fabio.spataro
Linea 5: Linea 5:
 ==== General template ==== ==== General template ====
  
-General model that can be used to create personal or group environments:+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 12: 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 18: 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 38: 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 43: 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 62: Linea 93:
 conda info conda info
  
-if [ $UID = 0 ]; then +if [ ! -d "$CONDAENV_PREFIX" ]; then 
-    conda --version +    conda create --yes --prefix "$CONDAENV_PREFIX" python${PYTHON_VERSION:+=$PYTHON_VERSION}
-    conda update conda +
-    conda --version+
 fi fi
- 
-if [ -d "$CONDAENV_PREFIX" ]; then 
-    conda env remove --name "$CONDAENV" 
-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 93: 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 108: 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> 
 +newgrp <GROUP> 
 +</code> 
 + 
 +Typical work session with conda:
  
 <code> <code>
Linea 143: Linea 185:
 === 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 151: Linea 193:
 </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.1616063081.txt.gz · Ultima modifica: 18/03/2021 11:24 da fabio.spataro

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki