Notes on how to use SWE-Agent with Apptainer (because for some HPC, docker is not available).
Like a DockerFile, we can configure a container using a definition file. Save the snippet below as sweagent.def.
Bootstrap: docker
From: python:3.12
Notes on how to use SWE-Agent with Apptainer (because for some HPC, docker is not available).
Like a DockerFile, we can configure a container using a definition file. Save the snippet below as sweagent.def.
Bootstrap: docker
From: python:3.12
| # Model dir to save logs, ckpts, etc. in "gs://model_dir" format. | |
| MODEL_DIR="gs://bigscience/experiment_d/multilingual_t0/test-run/model" | |
| # Data dir to save the processed dataset in "gs://data_dir" format. | |
| TFDS_DATA_DIR="gs://bigscience/experiment_d/multilingual_t0/test-run/data" | |
| T5X_DIR=${HOME}"/t5x" # directory where the T5X repo is cloned. | |
| python3 ${T5X_DIR}/t5x/train.py \ | |
| --gin_file=${T5X_DIR}"/t5x/examples/t5/t5_1_1/examples/t5_1_1_base_wmt_finetune.gin" \ | |
| --gin.MODEL_DIR="'${MODEL_DIR}'" \ |
| git clone --branch=main https://github.com/google-research/t5x | |
| cd t5x | |
| python3 -m pip install -e . |
| # Run flax mnist example (optional) | |
| pip install --user tensorflow-datasets==3.1.0 ml_collections clu | |
| git clone https://github.com/google/flax.git | |
| pip install --user -e flax | |
| cd flax/examples/mnist | |
| mkdir /tmp/mnist | |
| python3 main.py --workdir=/tmp/mnist --config=configs/default.py --config.learning_rate=0.05 --config.num_epochs=5 |
| sudo apt-add-repository -r ppa:graphics-drivers/ppa | |
| sudo apt update | |
| sudo apt remove nvidia* | |
| sudo apt autoremove | |
| sudo apt-get install ubuntu-drivers-common | |
| sudo ubuntu-drivers autoinstall | |
| # sudo apt -f install | |
| sudo apt install aptitude | |
| sudo aptitude install nvidia-440 |
| # Instructions for installing GCC 4.9 on various platforms. | |
| # The commands show instructions for GCC 4.9, but any higher version will also work! | |
| # Ubuntu (https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu/581497#581497) | |
| sudo apt-get install software-properties-common | |
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
| sudo apt-get update | |
| sudo apt-get install gcc-4.9 g++-4.9 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 |
| import torch | |
| import torch.nn.functional as F | |
| # Inspired from Understanding and Improving Convolutional Neural Networks via Concatenated Rectified Linear Units | |
| # https://arxiv.org/pdf/1603.05201.pdf | |
| class CReLU(nn.Module): | |
| def __init__(self, inplace=False): | |
| super(CReLU, self).__init__() |
| import json | |
| import base64 | |
| IMAGE_FILE = "example.png" | |
| with open(IMAGE_FILE, "rb") as image_file: | |
| encoded_string = base64.b64encode(image_file.read()) | |
| base64_string = encoded_string.decode('utf-8') | |
| json_data = dumps({'image': base64_string}, indent=2) |