setup files
This commit is contained in:
@@ -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
|
||||
+25
@@ -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;
|
||||
@@ -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}" <<EOF
|
||||
#!/bin/bash
|
||||
|
||||
# Alternate entrypoint for python docker image
|
||||
# Run pip as root, then run python as X_USERNAME
|
||||
|
||||
# do not continue script on errors
|
||||
set -euo pipefail
|
||||
|
||||
# Optimize pip for docker usage
|
||||
export ENV PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
export ENV PIP_NO_CACHE_DIR=1
|
||||
|
||||
# create the current user in the container
|
||||
useradd -u ${X_UID} -U -s /bin/bash -M ${X_USERNAME}
|
||||
|
||||
# pip install modules if requirements.txt is present
|
||||
[ -f requirements.txt ] && pip install -r requirements.txt
|
||||
|
||||
# run python
|
||||
exec su -c "python $@" ${X_USERNAME}
|
||||
EOF
|
||||
|
||||
chmod 755 ${ENTRYPOINT}
|
||||
|
||||
# Run python in docker with all the containers set
|
||||
|
||||
docker run -it --rm \
|
||||
-v /etc/timezone:/etc/timezone:ro \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v /data:/data -v /home:/home \
|
||||
-v ${X_TMPDIR}:${X_TMPDIR} \
|
||||
-w $(pwd) \
|
||||
--entrypoint "${ENTRYPOINT}" \
|
||||
--name ${NAME} \
|
||||
--net=host \
|
||||
python:X_PYTHON_VERSION "$@"
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x ;
|
||||
|
||||
NAME=$(echo $(basename "${PWD}" ).${RANDOM});
|
||||
|
||||
# must run this file in the projects root folder path
|
||||
|
||||
docker run -it --rm \
|
||||
--gpus all \
|
||||
-v /etc/timezone:/etc/timezone:ro \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v $(pwd):/tf \
|
||||
--name ${NAME} \
|
||||
--net=host \
|
||||
docker.bitsathy.ac.in/tensorflow-gpu bash;
|
||||
Reference in New Issue
Block a user