Last active
September 15, 2023 12:11
-
-
Save tomMoral/7a0fee1f1b5e1b7263b49a297b66346e to your computer and use it in GitHub Desktop.
Install conda
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
#!/bin/bash | |
install_conda(){ | |
_USAGE="Usage | |
===== | |
./install_conda.sh <--gpu> <--prefix|-p DIR> | |
Install conda with miniforge on the system. | |
Options | |
------- | |
--gpu: Flag to indicate that there is a GPU on this computer. | |
--prefix; -p DIR: Change the install directory to \$DIR/miniconda | |
" | |
_INSTALL_URL=https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-`uname -m`.sh | |
has_gpu=0 | |
install_dir=$HOME/.local/miniconda | |
# Parse options | |
while [ -n "$1" ]; do # while loop starts | |
case "$1" in | |
--prefix|-p) | |
shift; install_dir=$1;; | |
--gpu) | |
has_gpu=1;; | |
-h) | |
echo "$_USAGE" | |
return 0;; | |
*) | |
echo -e "Option $1 not recognized\n" | |
echo "$_USAGE" | |
return 1;; | |
esac | |
shift | |
done | |
# Install miniconda with miniforge in $HOME/.local/miniconda | |
test ! -f Mambaforge.sh && wget $_INSTALL_URL -O Miniforge3.sh | |
test ! -d $install_dir && bash Miniforge3.sh -b -p $install_dir | |
test $? -eq 0 && rm Miniforge3.sh | |
# Setup conda and mamba | |
__conda_setup="$($install_dir/bin/conda 'shell.bash' 'hook' 2> /dev/null)" | |
eval "$__conda_setup" | |
unset __conda_setup | |
# Install GPu specific packages | |
if [ has_gpu == 1 ]; then | |
mamba install -y gpustat pytorch pytorch-cuda=11.7 -c pytorch -c nvidia | |
else | |
mamba install -y -c pytorch pytorch cpuonly | |
fi | |
mamba install -y scikit-learn jupyter jupyterlab pandas matplotlib\ | |
pytest flake8 numba | |
unset has_gpu install_dir | |
unset _INSTALL_URL _USAGE | |
} | |
install_conda $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment