-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Devloped ML images for Alma9; Added a few keras related packages in t…
…he images ml-tensorflow-*
- Loading branch information
Shuwei Ye
authored and
Shuwei Ye
committed
Mar 29, 2024
1 parent
f9afd35
commit 6776ebd
Showing
23 changed files
with
2,648 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 @@ | ||
/home/yesw/Mamba |
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,14 @@ | ||
# This script should never be called directly, only sourced: | ||
|
||
# source _activate_current_env.sh | ||
|
||
# shellcheck shell=bash | ||
|
||
# Initialize Micromamba for the current shell | ||
|
||
# if [[ "X$X_MAMBA" == "X" ]]; then | ||
eval "$("${MAMBA_EXE}" shell hook --shell=bash)" | ||
micromamba activate "${ENV_NAME:-base}" | ||
# export X_MAMBA=$CONDA_DEFAULT_ENV | ||
# export CONDA_PROMPT_MODIFIER="(${ENV_NAME:-base})" | ||
# fi |
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,15 @@ | ||
import tensorflow as tf | ||
print(tf.__version__) | ||
|
||
gpus = tf.config.list_physical_devices('GPU') | ||
if gpus: | ||
print("gpus=",gpus) | ||
# Restrict TensorFlow to only use the first GPU | ||
try: | ||
tf.config.set_visible_devices(gpus[0], 'GPU') | ||
logical_gpus = tf.config.list_logical_devices('GPU') | ||
tf.test.gpu_device_name() | ||
print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPU") | ||
except RuntimeError as e: | ||
# Visible devices must be set before GPUs have been initialized | ||
print(e) |
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,115 @@ | ||
PROGNAME=$BASH_SOURCE | ||
myName="${BASH_SOURCE:-$0}" | ||
myDir=$(dirname $myName) | ||
myDir=$(readlink -f $myDir) | ||
|
||
usage() | ||
{ | ||
cat << EO | ||
Create a new env on top of the existing base env | ||
Usage: source $PROGNAME -h|--help | ||
source $PROGNAME -p|--prefix prefixDir | ||
EO | ||
} | ||
|
||
if [ "$BASH_SOURCE" = "$0" ]; then | ||
echo "DO NOT run this script, please _source_ $PROGNAME instead" | ||
usage | ||
return 1 | ||
fi | ||
|
||
while [ $# -gt 0 ] | ||
do | ||
case "$1" in | ||
-h|--help) | ||
usage | ||
return 0 | ||
;; | ||
-p|--prefix) | ||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then | ||
prefixDir=$2 | ||
shift 2 | ||
else | ||
echo "Error: Argument for $1 is missing" >&2 | ||
return 1 | ||
fi | ||
;; | ||
*) # unsupported flags | ||
echo "Error: Unsupported flag or arg $1" >&2 | ||
return 1 | ||
;; | ||
esac | ||
done | ||
|
||
|
||
CondaRoot=$MAMBA_ROOT_PREFIX | ||
[ "X$CondaRoot" = "X" ] && CondaRoot=$CONDA_PREFIX | ||
if [ "X$CondaRoot" = "X" ]; then | ||
echo "Neither envvar MAMBA_ROOT_PREFIX nor CONDA_PREFIX is found, exit now" | ||
return 1 | ||
fi | ||
|
||
if [ "$prefixDir" = "" ]; then | ||
echo "missing prefixDir" | ||
usage | ||
return 1 | ||
fi | ||
|
||
if [[ "$prefixDir" != */* ]]; then | ||
prefixDir="./$prefixDir" | ||
fi | ||
|
||
|
||
shellName=$(readlink /proc/$$/exe | awk -F "[/-]" '{print $NF}') | ||
typeset -f micromamba >/dev/null || eval "$($MAMBA_EXE shell hook --shell=$shellName)" | ||
|
||
envDir=$prefixDir | ||
micromamba env create -p $prefixDir | ||
if [ $? -ne 0 ]; then | ||
echo "Failure in creating a new env under $envDir/" | ||
fi | ||
envDir=$(readlink -f $envDir) | ||
|
||
|
||
curDir=$PWD | ||
cd $envDir | ||
ln -s $CONDA_PREFIX baseEnv_dir | ||
gtar xfz $CondaRoot/newEnv-base.tgz | ||
|
||
|
||
cat > pyvenv.cfg <<EOF | ||
home = $CONDA_PREFIX/bin | ||
include-system-site-packages = true | ||
version = $(python3 --version | cut -d' ' -f2) | ||
EOF | ||
|
||
prepare_UserEnv_setup() | ||
{ | ||
if [ "$myDir" = "/" ]; then | ||
cp -p /setup-UserEnv-in-container.sh . | ||
BindPaths='$myDir' | ||
if [ "X$SINGULARITY_BIND" != "X" ]; then | ||
BindPaths="$SINGULARITY_BIND"',$myDir' | ||
fi | ||
Image=$SINGULARITY_CONTAINER | ||
sed -i -e "s#BindPaths=.*#BindPaths=$BindPaths#" -e "s#Image=.*#Image=$Image#" setup-UserEnv-in-container.sh | ||
else | ||
cp -p $myDir/setupMe-on-host.sh . | ||
# add the default channel: conda-forge | ||
micromamba config get channels 2>&1 | grep conda-forge >/dev/null || micromamba config append channels conda-forge | ||
fi | ||
} | ||
|
||
prepare_UserEnv_setup | ||
|
||
cd $curDir | ||
|
||
# activate the new new | ||
micromamba activate $envDir | ||
echo "Next time, you can just run the following to activate your extended env" | ||
if [ "$myDir" = "/" ]; then | ||
echo -e "\tsource $envDir/setup-UserEnv-in-container.sh" | ||
else | ||
echo -e "\tsource $envDir/setupMe-on-host.sh" | ||
fi |
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,76 @@ | ||
CondaRoot=/opt/conda | ||
|
||
redCol="\e[1;31;47m" | ||
PROGNAME=$BASH_SOURCE | ||
usage() | ||
{ | ||
cat << EO | ||
Create a new python env on top of the existing base env | ||
Usage: source $PROGNAME -h|--help | ||
source $PROGNAME [-w|--workdir workDir] | ||
If no workDir is specified, the current directory will be used. | ||
EO | ||
} | ||
|
||
if [ $BASH_SOURCE == $0 ]; then | ||
echo -e "DO NOT run this script, please ${redCol} source $PROGNAME \e[0m instead\n" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
workDir="" | ||
while (( "$#" )); do | ||
case "$1" in | ||
-h|--help) | ||
usage | ||
return 0 | ||
;; | ||
-w|--workdir) | ||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then | ||
workDir=$2 | ||
shift 2 | ||
else | ||
echo "Error: Argument for $1 is missing" >&2 | ||
return 1 | ||
fi | ||
;; | ||
*) # unsupported flags | ||
echo "Error: Unsupported flag or arg $1" >&2 | ||
return 1 | ||
;; | ||
esac | ||
done | ||
|
||
isPWD=no | ||
if [ "$workDir" == "" ]; then | ||
workDir=$PWD | ||
isPWD=yes | ||
fi | ||
|
||
if [ "$isPWD" == "no" -a ! -d $workDir ]; then | ||
mkdir -p $workDir | ||
if [ $? -ne 0 ]; then | ||
echo "$workDir does not exist, cannot create it either; exit now" | ||
return 1 | ||
fi | ||
fi | ||
|
||
export PIPENV_VENV_IN_PROJECT=1 | ||
|
||
# [[ $(type -t micromamba) != "function" ]] && source /usr/local/bin/_activate_current_env.sh | ||
|
||
if [ "$isPWD" == "no" ]; then | ||
cd $workDir | ||
fi | ||
|
||
pipenv --site-packages install | ||
sed -i '/^VIRTUAL_ENV=/s#=.*#=$(realpath ${BASH_SOURCE%/*/*})#' .venv/bin/activate | ||
|
||
ln -s $CONDA_PREFIX/lib/*.so* .venv/lib/ | ||
|
||
echo "" | ||
echo -e "To add a package, run ${redCol}pipenv install\e[0m" | ||
echo -e "To activate this project's virtualenv, run ${redCol}pipenv shell\e[0m" | ||
echo -e "Alternatively, run a command inside the virtualenv with ${redCol}pipenv run\e[0m" |
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,14 @@ | ||
#!/bin/bash | ||
|
||
# export LD_LIBRARY_PATH=/usr/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda-11.1/lib64:/usr/local/cuda-11.2/lib64 | ||
|
||
## Do whatever you need with env vars here ... | ||
# source /usr/local/bin/_activate_current_env.sh | ||
source /printme.sh | ||
|
||
# Hand off to the CMD | ||
if [[ "X$1" =~ X.*bash ]]; then | ||
CMD="$@ -rcfile /usr/local/bin/_activate_current_env.sh" | ||
eval "set $CMD" | ||
fi | ||
exec "$@" |
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,57 @@ | ||
#!/bin/sh | ||
|
||
CondaRoot=/opt/conda | ||
listFilename=./list-of-dirs-$$.txt | ||
name_newEnv=newEnv | ||
root_newEnv=/tmp/conda | ||
prefix_envEnv=$root_newEnv/envs/$name_newEnv | ||
|
||
mkdir -p $root_newEnv | ||
micromamba env create -n $name_newEnv -r $root_newEnv | ||
cd $prefix_envEnv | ||
ln -s $CondaRoot baseEnv_dir | ||
|
||
echo -e "conda-meta\nbin\nsbin" > $listFilename | ||
find $CondaRoot/etc -type d | sed "s#$CondaRoot/##" >> $listFilename | ||
find $CondaRoot/ssl -type d | sed "s#$CondaRoot/##" >> $listFilename | ||
find $CondaRoot/share/jupyter -type d | sed "s#$CondaRoot/##" >> $listFilename | ||
find $CondaRoot/x86_64-conda-linux-gnu | sed "s#$CondaRoot/##" >> $listFilename | ||
find $CondaRoot/lib -type d | grep -v "site-packages" | sed "s#$CondaRoot/##" >> $listFilename | ||
|
||
mkdir -p `cat $listFilename` | ||
while read subdir; do | ||
cd $subdir | ||
parentDots=$(echo $subdir | sed 's%[^/]*%..%g') | ||
ln -s $parentDots/baseEnv_dir/$subdir/* ./ 2>/dev/null | ||
cd $prefix_envEnv | ||
done <$listFilename | ||
rm -f $listFilename | ||
|
||
# special activate and deactivate scrpt to handle envvar PYTHONPATH | ||
cat > etc/conda/activate.d/activate-python.sh <<EOF | ||
# save the original PYTHONPATH if set | ||
if ! [ -z "\${PYTHONPATH+_}" ] ; then | ||
CONDA_BACKUP_PYTHONPATH="\$PYTHONPATH" | ||
PYTHONPATH=\$CONDA_PREFIX/lib:\$CONDA_PREFIX/lib/python$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1-2)/site-packages:\${PYTHONPATH} | ||
else | ||
export PYTHONPATH=\$CONDA_PREFIX/lib:\$CONDA_PREFIX/lib/python$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1-2)/site-packages | ||
fi | ||
EOF | ||
|
||
cat > etc/conda/deactivate.d/deactivate-python.sh <<EOF | ||
# restore the original PYTHONPATH if available | ||
if ! [ -z "\${CONDA_BACKUP_PYTHONPATH+_}" ] ; then | ||
export PYTHONPATH=\$CONDA_BACKUP_PYTHONPATH | ||
unset CONDA_BACKUP_PYTHONPATH | ||
else | ||
unset PYTHONPATH | ||
fi | ||
EOF | ||
|
||
# special file and subdir | ||
rm -f conda-meta/history | ||
rm -f baseEnv_dir | ||
rm -f lib/python*/site-packages | ||
|
||
gtar cfz $CondaRoot/newEnv-base.tgz * | ||
rm -rf $root_newEnv |
Oops, something went wrong.