Created
June 28, 2023 18:30
-
-
Save HernandoR/3b71f522f7aa8483155df70b35b7e9a9 to your computer and use it in GitHub Desktop.
Cloudlab profile
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
""" | |
Ubuntu 22 for arm | |
ubuntu 20 OSCN for PCC | |
ubuntu 20 for x86-64 | |
Instructions: | |
## brief | |
This profile creates a single node with/without latest cuda and conda installation | |
anaconda will use install version on date of 2023-01 | |
## NV driver | |
if disable_nouveau is set to True, the node should be manually rebooted after installation | |
unless you are using ibm8335, i have customized the image to disable nouveau and install nvidia driver | |
It's not promised that the image will be available forever, so you may need to create your own image. | |
""" | |
# | |
# NOTE: This code was machine converted. An actual human would not | |
# write code like this! | |
# | |
# Import the Portal object. | |
import geni.portal as portal | |
# Import the ProtoGENI library. | |
import geni.rspec.pg as pg | |
# Import the Emulab specific extensions. | |
import geni.rspec.emulab as emulab | |
# Create a portal object, | |
pc = portal.Context() | |
# Create a Request object to start building the RSpec. | |
request = pc.makeRequestRSpec() | |
# Params | |
pc.defineParameter("type", "Hardware type of the node", | |
portal.ParameterType.NODETYPE, "ibm8335", advanced=False, groupId=None) | |
pc.defineParameter("Extend_root", "Extend root disk to maximum size", | |
portal.ParameterType.BOOLEAN, True, advanced=False, groupId=None) | |
pc.defineParameter("install_cuda", "Install CUDA", | |
portal.ParameterType.BOOLEAN, True, advanced=False, groupId=None) | |
pc.defineParameter("disable_nouveau", "Disable nouveau", | |
portal.ParameterType.BOOLEAN, True, advanced=False, groupId=None) | |
pc.defineParameter("install_Conda", "Install Conda", | |
portal.ParameterType.STRING, "None", | |
[ 'None','Mambaforge', 'Miniconda', 'Anaconda'], | |
advanced=False, groupId=None) | |
pc.defineParameter("LoadRemoteDataset", "Load remote dataset on the node", | |
portal.ParameterType.BOOLEAN, True, advanced=False, groupId=None) | |
pc.defineParameter("RemteDatasetUrl", "Remote Dataset to be mounted on the node", | |
portal.ParameterType.STRING, "urn:publicid:IDN+clemson.cloudlab.us:ntu-cloud-pg0+ltdataset+vesuvius_kaggle_Clemson", advanced=False, groupId=None) | |
params = pc.bindParameters() | |
pc.verifyParameters() | |
# Node node-0 | |
node = request.RawPC('node') | |
# node_0.routable_control_ip = True | |
node.hardware_type = params.type | |
use_run_file = False | |
if params.type == "ibm8335": | |
# PCC64LE | |
if params.disable_nouveau: | |
# USE YOUR OWN IMAGE IF THIS ONE IS NOT AVAILABLE | |
node.disk_image = 'urn:publicid:IDN+clemson.cloudlab.us+image+ntu-cloud-PG0:PPC_OSCN' | |
params.disable_nouveau = False | |
else: | |
node.disk_image = 'urn:publicid:IDN+clemson.cloudlab.us+image+emulab-ops:UBUNTU20-PPC-OSCN-U' | |
elif params.type in ['m400']: | |
# ARM | |
node.disk_image = 'urn:publicid:IDN+utah.cloudlab.us+image+emulab-ops:UBUNTU22-64-ARM' | |
else: | |
node.disk_image = 'urn:publicid:IDN+emulab.net+image+emulab-ops//UBUNTU22-64-STD' | |
if params.Extend_root: | |
# Grow the root fs to the maximum. Note that saving the image is not possible with that! | |
node.addService(pg.Execute(shell="bash", command="curl -sL https://gist.githubusercontent.com/ustiugov/e38be6bca34a87a10cf0f68e04dd25a3/raw/cloudlab-grow-rootfs.sh | sudo bash")) | |
if params.install_cuda: | |
# NVIDIA GPU driver by apt | |
node.addService(pg.Execute(shell="bash", | |
command="sudo add-apt-repository ppa:graphics-drivers/ppa --yes")) | |
node.addService(pg.Execute(shell="bash", | |
command="sudo apt-get update")) | |
# NVIDIA GPU cuda | |
if params.type in ['ibm8335']: | |
node.addService(pg.Execute(shell="bash", | |
command="curl -sL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/ppc64el/cuda-keyring_1.0-1_all.deb -o /local/cuda-keyring_1._all.deb")) | |
elif params.type in ['m400']: | |
node.addService(pg.Execute(shell="bash", | |
command="curl -sL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/arm64/cuda-keyring_1.1-1_all.deb -o /local/cuda-keyring_1._all.deb")) | |
else: | |
node.addService(pg.Execute(shell="bash", | |
command="curl -sL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.1-1_all.deb -o /local/cuda-keyring_1._all.deb")) | |
node.addService(pg.Execute(shell="bash", | |
command="sudo dpkg -i /local/cuda-keyring_1._all.deb")) | |
node.addService(pg.Execute(shell="bash", | |
command='sudo apt update')) | |
node.addService(pg.Execute(shell="bash", | |
command="sudo apt-get install -y cuda")) | |
node.addService(pg.Execute(shell="bash", | |
command="echo 'export PATH=/usr/local/cuda/bin:\$PATH' | sudo tee -a /etc/profile.d/cuda.sh")) | |
if params.disable_nouveau: | |
# disable nouveau | |
node.addService(pg.Execute(shell="bash", | |
command="echo 'blacklist nouveau' | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf")) | |
node.addService(pg.Execute(shell="bash", | |
command="echo 'blacklist nvidiafb' | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf")) | |
node.addService(pg.Execute(shell="bash", | |
command="echo 'options nouveau modeset=0' | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf")) | |
node.addService(pg.Execute(shell="bash", | |
command="sudo update-initramfs -u -k $(uname -r)")) | |
if params.install_Conda == 'None': | |
pass | |
else: | |
if params.install_Conda == 'Mambaforge': | |
CONDA_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh" | |
PREFIX="/local/" | |
CONDA_SH=PREFIX+"mambaforge.sh" | |
CONDA_DIR=PREFIX+"mambaforge3" | |
INIT_CMD="mamba init" | |
elif params.install_Conda == 'Miniconda': | |
CONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-$(uname)-$(uname -m).sh" | |
PREFIX="/local/" | |
CONDA_SH=PREFIX+"miniconda.sh" | |
CONDA_DIR=PREFIX+"miniconda3" | |
INIT_CMD="conda init" | |
elif params.install_Conda == 'Anaconda': | |
CONDA_URL="https://repo.anaconda.com/archive/Anaconda3-2023.03-1-$(uname)-$(uname -m).sh" | |
PREFIX="/local/" | |
CONDA_SH=PREFIX+"anaconda.sh" | |
CONDA_DIR=PREFIX+"anaconda3" | |
INIT_CMD="conda init" | |
else: | |
pass | |
node.addService(pg.Execute(shell="bash", | |
command='curl -sL "'+CONDA_URL+'" -o '+CONDA_SH)) | |
node.addService(pg.Execute(shell="bash", | |
command="chmod +x "+CONDA_SH)) | |
node.addService(pg.Execute(shell="bash", | |
command=CONDA_SH+" -b -p "+CONDA_DIR)) | |
node.addService(pg.Execute(shell="bash", | |
command="echo 'export PATH="+CONDA_DIR+"/condabin:\$PATH' | sudo tee -a /etc/profile.d/conda.sh")) | |
node.addService(pg.Execute(shell="bash", | |
command="sudo sudo chmod 770 -R "+CONDA_DIR)) | |
node.addService(pg.Execute(shell="bash", | |
command="echo '"+INIT_CMD+"' | sudo tee -a /etc/profile.d/conda.sh")) | |
if params.type == 'ibm8335': | |
node.addService(pg.Execute(shell="bash", | |
command="source /etc/profile.d/conda.sh")) | |
node.addService(pg.Execute(shell="bash", | |
command="curl -sL https://gist.githubusercontent.com/HernandoR/3b139c9614093efca3f8702e32f7d61e/raw/PPC64_condarc.rc -o "+CONDA_DIR+"/.condarc")) | |
node.addService(pg.Execute(shell="bash", | |
command="curl -sL https://gist.github.com/HernandoR/3f13f82d075173e77a42c8845a12096f/raw/using_IBM_Powerai.sh | bash")) | |
else: | |
pass | |
# node.addService(pg.Execute(shell="bash", | |
# command="curl -sL https://gist.githubusercontent.com/HernandoR/3b139c9614093efca3f8702e32f7d61e/raw/PPC64_condarc.rc -o "+CONDA_DIR+"/.condarc")) | |
if params.LoadRemoteDataset: | |
iface=node.addInterface() | |
fsnode=request.RemoteBlockstore('fsnode', '/vesuvius_kaggle') | |
fsnode.dataset=params.RemteDatasetUrl | |
# Now we add the link between the node and the special node | |
fslink=request.Link("fslink") | |
fslink.addInterface(iface) | |
fslink.addInterface(fsnode.interface) | |
# Special attributes for this link that we must use. | |
fslink.best_effort=True | |
fslink.vlan_tagging=True | |
# Print the generated rspec | |
pc.printRequestRSpec(request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment