From ea4806ccb9d0dd3d2ea5e6fd330c33cc44eeb4f4 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 5 Aug 2022 14:44:50 +0530 Subject: [PATCH] setup files --- Dockerfile | 6 +++++ install.sh | 25 +++++++++++++++++++ python-docker.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ runtime.sh | 16 ++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 Dockerfile create mode 100644 install.sh create mode 100644 python-docker.sh create mode 100644 runtime.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a8e2555 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM nvcr.io/nvidia/cuda:11.6.0-cudnn8-devel-ubuntu20.04 + +LABEL Arthur="Shankar Mounesh" + +RUN apt update && \ + apt install python3-pip -y diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..f430e3b --- /dev/null +++ b/install.sh @@ -0,0 +1,25 @@ +# Run this file as a root user +#This file install docker and nvidia runtime and create a nvidia-driver conatiner + +#! /bin/bash +set -e -x; + +# update apt-cache and install docker +apt update && apt install curl -y; + +#Adding package repository and the GPG key for nvidia conatiner runtime +distribution=$(. /etc/os-release;echo $ID$VERSION_ID); +curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg; +curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \ +sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ +tee /etc/apt/sources.list.d/nvidia-container-toolkit.list; + +#Update cache and install nvidia conatiner runtime +apt-get update && apt install -y nvidia-docker2; +apt-get update && apt-get install -y nvidia-container-toolkit; +systemctl restart docker; + +# create driver conatiner +docker run --name nvidia-driver -d --privileged --pid=host -v /run/nvidia:/run/nvidia -v /var/log:/var/log --restart=always docker.bitsathy.ac.in/driver ; + +service docker restart; diff --git a/python-docker.sh b/python-docker.sh new file mode 100644 index 0000000..d0dff03 --- /dev/null +++ b/python-docker.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Filename: /usr/local/bin/python-docker +# Script to run python:latest inside an ephemeral docker container +# pip install python modules if requirements.txt is preset + +# do not continue script on errors +set -euo pipefail + +# Python version to run from docker hub +X_PYTHON_VERSION="latest" + +# Get current user details so we can run python with this user id later +X_UID=$(id -u) +X_USERNAME=$(id -un) + +# Set docker container name to basename of current working dir + random string +NAME=$(echo $(basename "${PWD}" ).${RANDOM}) + +# Create temporary docker ENTRYPOINT shell script +X_TMPDIR="$(mktemp -d)" +ENTRYPOINT="${X_TMPDIR}/entrypoint.sh" +# Remove temp files on exit +trap "{ rm -rf ${X_TMPDIR}; }" EXIT + +cat > "${ENTRYPOINT}" <