clean up, adding "set -e"

This commit is contained in:
Nicolas 2022-05-05 10:41:19 +02:00
parent 0d573fce40
commit a46f685ff2
4 changed files with 144 additions and 98 deletions

View File

@ -1,3 +1,8 @@
c.JupyterHub.bind_url = 'http://:8000/deepserv'
# Configuration file for jupyterhub. # Configuration file for jupyterhub.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -141,7 +146,7 @@
# This is the address on which the proxy will bind. # This is the address on which the proxy will bind.
# Sets protocol, ip, base_url # Sets protocol, ip, base_url
# Default: 'http://:8000' # Default: 'http://:8000'
c.JupyterHub.bind_url = 'http://:8000/deepserv' #c.JupyterHub.bind_url = 'http://:8000'
## Whether to shutdown the proxy when the Hub shuts down. ## Whether to shutdown the proxy when the Hub shuts down.
# #

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
set -e
if [ "$EUID" -ne 0 ] if [ "$EUID" -ne 0 ]
then echo "Please run as root" then echo "Please run as root"
@ -15,32 +16,62 @@ if [ ! -s "~/.ssh/authorized_keys" ]; then
fi fi
echo "" echo ""
echo "Install and config python & jupyter..." echo "Install supermicro system tools..."
apt-get update && \ apt-get update
apt-get install -y ipmitool && modprobe ipmi_devintf && \ apt-get install -y ipmitool && modprobe ipmi_devintf
curl -fsSL https://deb.nodesource.com/setup_current.x | bash - \
apt-get install -y python3-pip nodejs npm git && \ echo "Install a recent notejs for jupyterhub from nodesource..."
apt-add-repository -y ppa:cantera-team/cantera && \ curl -fsSL https://deb.nodesource.com/setup_current.x | bash -
apt-get install -y cantera-python3 && \ apt-get install -y nodejs npm
python3 -m pip install jupyterhub && \
npm install -g configurable-http-proxy && \ echo "Install JupyterHub..."
python3 -m pip install jupyterlab notebook jupyterlab-git tensorflow-gpu && \ apt-get install -y language-pack-de python3-pip
python3 -m pip install h5py tqdm pandas ipywidgets pillow matplotlib && \ python3 -m pip install jupyterhub
python3 -m pip install scipy scikit-learn && \ npm install -g configurable-http-proxy
mkdir /etc/jupyterhub/ && \ python3 -m pip install jupyterlab notebook jupyterlab-git
cp jupyterhub_config.py /etc/jupyterhub/jupyterhub_config.py && \ jupyter labextension install @jupyterlab/server-proxy
cp jupyterhub.service /etc/systemd/system/jupyterhub.service && \
systemctl enable jupyterhub && \ echo "Setup JupyterHub..."
mkdir /etc/jupyterhub/
cp jupyterhub_config.py /etc/jupyterhub/jupyterhub_config.py
cp jupyterhub.service /etc/systemd/system/jupyterhub.service
systemctl enable jupyterhub
systemctl start jupyterhub systemctl start jupyterhub
echo "Install Tensorflow..."
python3 -m pip install tensorflow-gpu
echo "Install cantera..."
apt-add-repository -y ppa:cantera-team/cantera
apt-get install -y cantera-python3
echo "Install common Python libs..."
python3 -m pip install h5py tqdm pandas ipywidgets pillow matplotlib opencv-python
#python3 -m pip install scipy scikit-learn numba
#System monitoring
#echo "Install netdata..."
#wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh
#echo "nvidia_smi: yes" >> /usr/lib/netdata/conf.d/python.d.conf
#service netdata restart
#on http://0.0.0.0:19999
echo "Install gpuview..."
python3 -m pip install gpuview
gpuview service --host 127.0.0.1 --port 9988
echo "Disable services that delays startup by wating for network connectivity..."
systemctl disable cloud-config
systemctl disable cloud-final.service
systemctl disable iscsid.service
systemctl disable open-iscsi.service
if [ $? -eq 0 ]; then echo "show gpu state..."
echo "check nvidia drivers..." nvidia-smi
nvidia-smi
echo ""
echo "Setup successfully finished"
echo ""
echo "Setup successfully finished"
fi

View File

@ -12,10 +12,15 @@ ssddev=/dev/sdb
#Block device to use with cache: #Block device to use with cache:
hdddev=/dev/sdc hdddev=/dev/sdc
#Cache sequential writes files, no cutoff #Name of the mounted device:
#There is an issue with parsing of prefixes, max 4 GB mountname=/mnt/bcache
#Cache setting for sequential writes
#There is an issue with parsing prefixes, max 4 GB, use 0 for no cutoff
sequential_cutoff=0 sequential_cutoff=0
set -e
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
echo "Please run as root" echo "Please run as root"
exit exit
@ -32,39 +37,42 @@ while [ -b /dev/bcache0 ]; then
exit exit
fi fi
echo
echo "Clean disks and setup bcache... " echo "Clean disks and setup bcache... "
dd if=/dev/zero of=$ssddev bs=512 count=8 && \ dd if=/dev/zero of=$ssddev bs=512 count=8
dd if=/dev/zero of=$hdddev bs=512 count=8 && \ dd if=/dev/zero of=$hdddev bs=512 count=8
wipefs -a $ssddev && \ wipefs -a $ssddev
wipefs -a $hdddev && \ wipefs -a $hdddev
apt-get update && \ apt-get update
apt-get install -y bcache-tools && \ apt-get install -y bcache-tools
make-bcache -C $ssddev -B $hdddev --writeback make-bcache -C $ssddev -B $hdddev --writeback
echo
echo "Wait until device is ready... " echo "Wait until device is ready... "
while [ ! -b /dev/bcache0 ]; do sleep 1; done while [ ! -b /dev/bcache0 ]; do sleep 1; done
if [ $? -eq 0 ]; then echo
echo "Config, format and mount bcache device... " echo "Config bcache device... "
echo $sequential_cutoff > /sys/block/bcache0/bcache/sequential_cutoff && \ echo $sequential_cutoff > /sys/block/bcache0/bcache/sequential_cutoff
echo "ACTION==\"add\", SUBSYSTEM==\"block\", ENV{MAJOR}==\"252\", ATTR{bcache/sequential_cutoff}=\"$sequential_cutoff\"" \ echo "ACTION==\"add\", SUBSYSTEM==\"block\", ENV{MAJOR}==\"252\", ATTR{bcache/sequential_cutoff}=\"$sequential_cutoff\"" \
> /etc/udev/rules.d/99-bcache_sequential_cutoff.rules && \ > /etc/udev/rules.d/99-bcache_sequential_cutoff.rules
udevadm test /sys/block/bcache0 && \ udevadm test /sys/block/bcache0
mkfs.ext4 /dev/bcache0 && \
mkdir /mnt/bcache && \
mount /dev/bcache0 /mnt/bcache && \
echo "/dev/bcache0 /mnt/bcache ext4 rw 0 0" >> /etc/fstab
fi
if [ $? -eq 0 ]; then echo
echo "Config default home directory for new users on bcache partition... " echo "Format and mount bcache device..."
mkdir /mnt/bcache/home && \ mkfs.ext4 /dev/bcache0
echo "#" >> /etc/default/useradd && \ mkdir $mountname
echo "# Modifications:" >> /etc/default/useradd && \ mount /dev/bcache0 $mountname
echo "HOME=/mnt/bcache/home" >> /etc/default/useradd echo "/dev/bcache0 $mountname ext4 rw 0 0" >> /etc/fstab
fi
echo
echo "Config default home directory for new users on bcache partition... "
echo "home path of exising users will not be moved automaticaly"
mkdir $mountname/home
echo "#" >> /etc/default/useradd
echo "# Modifications:" >> /etc/default/useradd
echo "HOME=$mountname/home" >> /etc/default/useradd
echo
echo "Setup successfully finished"
if [ $? -eq 0 ]; then
echo ""
echo "Setup successfully finished"
fi

View File

@ -15,6 +15,8 @@
#sudo apt-get autoremove #sudo apt-get autoremove
#------------------------------------ #------------------------------------
set -e
if [ "$EUID" -ne 0 ] if [ "$EUID" -ne 0 ]
then echo "Please run as root" then echo "Please run as root"
exit exit
@ -23,56 +25,56 @@ fi
distribution=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g') distribution=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g')
architecture="x86_64" architecture="x86_64"
echo "" #echo
echo "Disable cloud-init..." #echo "Disable cloud-init..."
#this is optional, not a requirement #this is optional, not a requirement
touch /etc/cloud/cloud-init.disabled #touch /etc/cloud/cloud-init.disabled
echo "" echo
echo "Install requirements..." echo "Install pre-requirements..."
apt-get update && \ apt-get update
apt-get install -y linux-headers-$(uname -r) software-properties-common apt-get install -y linux-headers-$(uname -r) software-properties-common
if [ $? -eq 0 ]; then
echo ""
echo "Setup the CUDA repository public GPG key..."
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/$distribution/$architecture/7fa2af80.pub && \
wget https://developer.download.nvidia.com/compute/cuda/repos/$distribution/$architecture/cuda-$distribution.pin && \
mv cuda-$distribution.pin /etc/apt/preferences.d/cuda-repository-pin-600
#add-apt-repository contrib
fi
if [ $? -eq 0 ]; then echo
echo "" echo "Setup the CUDA repository public GPG key..."
echo "Setup the CUDA network repository..." apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/$distribution/$architecture/7fa2af80.pub
add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/$distribution/$architecture/ /" wget https://developer.download.nvidia.com/compute/cuda/repos/$distribution/$architecture/cuda-$distribution.pin
fi mv cuda-$distribution.pin /etc/apt/preferences.d/cuda-repository-pin-600
#add-apt-repository contrib
if [ $? -eq 0 ]; then
echo ""
echo "install CUDA..."
#Installs CUDA Toolkit and Driver packages.
#Use the --no-install-recommends option should prevent install any dependencies on X packages
#It still installes alot of dependencies, but fortunately it seams not to setup x-server
apt-get update && \
apt-get install -y --no-install-recommends cuda-11-2
fi
if [ $? -eq 0 ]; then
echo ""
echo "install libcudnn8..."
#Latest available version from nvidia ubuntu1804 repo
#For the current Ubuntu version it was not available. But it seams to work anyway.
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/libcudnn8_8.1.1.33-1+cuda11.2_amd64.deb && \
apt-get install -y ./libcudnn8_8.1.1.33-1+cuda11.2_amd64.deb && \
rm ./libcudnn8_8.1.1.33-1+cuda11.2_amd64.deb && \
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/libcudnn8-dev_8.1.1.33-1+cuda11.2_amd64.deb && \
apt-get install -y ./libcudnn8-dev_8.1.1.33-1+cuda11.2_amd64.deb && \
rm ./libcudnn8-dev_8.1.1.33-1+cuda11.2_amd64.deb
fi
if [ $? -eq 0 ]; then echo
echo "" echo "Setup the CUDA network repository..."
echo "Setup successfully finished" add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/$distribution/$architecture/ /"
echo "Type \"sudo systemctl reboot\" to reboot system for loading GPU drivers)"
fi
echo
echo "Install CUDA..."
#Installs CUDA Toolkit and Driver packages.
#Use the --no-install-recommends option should prevent install any dependencies on X packages
#It still installes alot of dependencies, but fortunately it seams not to setup x-server
apt-get update
apt-get install -y --no-install-recommends cuda-11-2
echo
echo "Install libcudnn..."
apt-get install -y libcudnn8_8.1.1.33-1+cuda11.2 libcudnn8-dev_8.1.1.33-1+cuda11.2
#get an other version:
#wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/libcudnn8_8.1.1.33-1+cuda11.2_amd64.deb
#apt-get install -y ./libcudnn8_8.1.1.33-1+cuda11.2_amd64.deb
#rm ./libcudnn8_8.1.1.33-1+cuda11.2_amd64.deb
#wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/libcudnn8-dev_8.1.1.33-1+cuda11.2_amd64.deb
#apt-get install -y ./libcudnn8-dev_8.1.1.33-1+cuda11.2_amd64.deb
#rm ./libcudnn8-dev_8.1.1.33-1+cuda11.2_amd64.deb
echo
echo "Setup successfully finished"
echo "Type \"sudo systemctl reboot\" to reboot system for loading GPU drivers)"