/
สร้าง Singularity Container อย่างง่ายใน 5 ขั้นตอน

สร้าง Singularity Container อย่างง่ายใน 5 ขั้นตอน

บทความนี้ตั้งใจรวบรวม 5 ขั้นตอนอย่างง่ายในการสร้าง Singularity Container โดยท่านสามารถเตรียมความพร้อมล่วงหน้าได้ ดังแสดงในส่วน Requirements

Requirements

  1. เครื่องคอมพิวเตอร์ในระบบปฏิบัติการลีนุกซ์ (Linux machine) โดยท่านต้องมีสิทธิ์ root เพื่อทำการ build container

  2. ติดตั้ง Singularity software ใน linux machine เสร็จสิ้น https://thaisc.atlassian.net/l/c/13FtNZ8d

  3. recipe ของ environment ที่ท่านใช้ เช่น

    1. requirement.txt

    2. docker image ที่มีส่วนผสมที่ถูกต้องกับงานของท่าน

    3. Singularity image

Instructions การสร้าง Singularity Container บน local linux machine ของท่าน

step-by-step อย่างง่าย 5 ขั้นตอน

  1. ให้ singularity เรียก pull docker image หรือ singularity image ที่ต้องการจาก registry จะได้ไฟล์ .sif

    1. ตัวอย่างคำสั่ง $ singularity pull docker://nvcr.io/nvidia/tensorflow:21.04-tf2-py3

  2. สร้าง sandbox จากไฟล์ .sif หรือก็คือสร้างโฟลเดอร์ของ container ขึ้นมาเพื่อเข้าไปติดตั้งเพิ่มเติมได้

    1. ตัวอย่างคำสั่ง $ sudo singularity build --sandbox mysandbox/ tensorflow_21.04-tf2-py3.sif

  3. เข้าสู่ sandbox container แบบ writable และ bind directory ข้างนอกและข้างใน container ไว้ด้วย

    1. ตัวอย่างคำสั่ง $ sudo singularity shell -B /home/apiyatum:/root --writable mysandbox/

    2. option -B ถูกใช้เพื่อ bind directory <my machine directory>:<container directory>

  4. ทำการติดตั้งซอฟแวร์หรือ packages เพิ่มเติมจาก recipe environment ที่ต้องการลงใน sandbox

  5. เมื่อเตรียม environment ใน sandbox เสร็จ ทำการ build sandbox ให้เป็นไฟล์ .sif อีกครั้ง

    1. ตัวอย่างคำสั่ง $ sudo singularity build newsif.sif mysandbox/

    2. สิ่งที่ได้คือ Singularity file ใหม่ที่ชื่อ newsif.sif ไปใช้งานต่อใน HPC cluster ได้


SCP ไปใช้งานบน HPC

เมื่อได้ newsif.sif ที่มี environment การใช้งานตามต้องการแล้วสามารถทำสำเนาขึ้นไปยัง HPC เพื่อใช้งานได้ทันที

$ scp newsif.sif username@tara.nstda.or.th:/<user home หรือ project home directory>/

การใช้งาน Singularity Container บน HPC

สามารถดูตัวอย่างการใช้งานเบื้องต้นร่วมกับภาษา Python ได้ที่นี่ หรือตัวอย่างการใช้งาน Jupyter Notebook ผ่าน Singularity container ได้ที่นี่


Related articles

 

 

 



Related content

การติดตั้งและการใช้งาน conda หรือ mamba
การติดตั้งและการใช้งาน conda หรือ mamba
Read with this
การสร้างไฟล์ Container โดยใช้โปรแกรม Apptainer
การสร้างไฟล์ Container โดยใช้โปรแกรม Apptainer
More like this
Creating an environment using Mamba on LANTA-HPC
Creating an environment using Mamba on LANTA-HPC
Read with this
การใช้งาน Jupyter Notebook กับ Singularity
การใช้งาน Jupyter Notebook กับ Singularity
More like this
Container (Singularity)
Container (Singularity)
Read with this
การติดตั้ง Singularity ลง Linux machine ของท่าน
การติดตั้ง Singularity ลง Linux machine ของท่าน
More like this