[2024 Summer GeekPie HPC Lecture Notes] Week 1 Exercise


[2024 Summer GeekPie HPC Lecture Notes] Catalog of Notes


The task of this exercise is to build a Singularity container for CS110 HW3. Suppose we have installed Singularity on our local machine.

General Steps

  1. Create a Singularity definition file named singularity.def;
  2. Write the definition file for Singularity;
  3. Build the Singularity container: sudo singularity build cs110-hw3.sif singularity.def;
  4. Run the Singularity container: singularity run cs110-hw3.sif.
  5. Test the Singularity container: singularity exec cs110-hw3.sif python3 test.py.

Singularity Definition File

Bootstrap: localimage
From: /tmp/ubuntu # docker 无法下载的时候

# docker如果有用
# Bootstrap: docker
# From: ubuntu:22.04

%post
    # 安装必要的软件包
    apt-get update && apt-get install -y \
        build-essential \
        make \
        gcc \
        g++


    # 复制项目文件到容器中
    mkdir -p /hw3
    cp -r ~/work/homework-3-itsuitsuki/* /hw3/

    # 进入项目目录
    cd /hw3

    # 运行 make clean 和 make test_fks
    make clean
    make test_fks

%runscript
    # 运行项目
    cd /hw3
    ./build/test_fks