Skip to content

Instantly share code, notes, and snippets.

@david30907d
Last active September 28, 2018 02:52
Show Gist options
  • Save david30907d/30778e2e3dfceec21f3a5ce0568ec34d to your computer and use it in GitHub Desktop.
Save david30907d/30778e2e3dfceec21f3a5ce0568ec34d to your computer and use it in GitHub Desktop.

tensorflow GPU docker

nvidia docker照著nvidia的github裝好像會噴錯誤訊息

可以嘗試用這個看看 某部落格

  1. First, you need to install Docker:
    • curl -fsSL get.docker.com -o get-docker.sh
    • sh get-docker.sh
    • Use docker without sudo:sudo usermod -aG docker $USER
    • Now, have the user logout then login again.
  2. Second, install tensorflow docker image:
  3. Create your own container:
    • Python3 + GPU:nvidia-docker run -itd --name <name> -p <port>:8888 tensorflow/tensorflow:nightly-gpu-py3 /run_jupyter.sh --allow-root --ip=0.0.0.0
    • Python2 + GPU:nvidia-docker run -itd --name <name> -p <port>:8888 tensorflow/tensorflow:nightly-gpu /run_jupyter.sh --allow-root --ip=0.0.0.0

銘毅的ssh ubuntu dockerfile

Dockerfile

FROM ubuntu:14.04
MAINTAINER davidtnfsh


RUN sudo apt-get update && \
        sudo apt-get install -y openssh-server \
                                            openjdk-7-jdk \
                                            wget \
                                            vim \


# SSH�K�˙C����֧Ԯ
RUN sudo locale-gen zh_TW zh_TW.UTF-8 
RUN echo "LC_CTYPE=zh_TW.UTF-8" | sudo tee -a /etc/environment

CMD ["sh","-c" ,"/etc/init.d/ssh start; bash"]

create docker sh

#!/bin/bash
read -p "Create UserNmae  : " USER_NAME

read -p "Setting Password  [ default : udiclab@720 ] : " USER_PWD
if [ ${#USER_PWD} == 0 ] ; then
	USER_PWD="udiclab@720"
fi

read -p "Setting SSH's Port  : " USER_PORT

if [ ${#USER_NAME} == 0 -o ${#USER_PORT} == 0 ] ; then
	echo "Please at least enter the user name and the port number"
	exit 0
fi

echo -e "\nYou Setting:"
echo "User: ${USER_NAME}"
echo "Password: ${USER_PWD}"
echo "Port: ${USER_PORT}"

sudo docker run -itd \
                -p $USER_PORT:22 \
                --name $USER_NAME \
                --hostname $USER_NAME \
                udic/ubuntu:1.0 &> /dev/null

# sudo docker exec -ti $USER_NAME sudo sh -c "sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y openssh-server"

sudo docker exec -ti $USER_NAME sudo sh -c "sudo useradd -m $USER_NAME -s /bin/bash;echo \"${USER_NAME}:${USER_PWD}\" | chpasswd;sudo adduser $USER_NAME sudo" &> /dev/null

# sudo docker exec -ti $USER_NAME sudo sh -c "sudo /etc/init.d/ssh start"

# 終端機中文支援
# sudo docker exec -ti $USER_NAME sudo sh -c "sudo locale-gen zh_TW zh_TW.UTF-8;echo \"LC_CTYPE=zh_TW.UTF-8\" | sudo tee -a /etc/environment" &> /dev/null

刪除docker指令

  1. 刪除同一個image創出來的container指令: docker ps -a | awk '{ print $1,$2 }' | grep centos:7 | awk '{print $1 }' | xargs -I {} docker rm {}
  2. 刪除特定名稱的images(通常是建images失敗都會變成none的名稱):docker images | awk '{ print $1,$2,$3 }' | grep "<none>" | awk '{print $3}' | xargs -I {} docker rmi {}
  3. 嘗試建立image的時候,前幾次失敗的都會變成hash值,一口氣刪除的指令:
docker rmi `docker images --filter dangling=true -q` #Removes all those images.
  1. 將container容量排序: docker ps -a --format '{{.Size}}\t{{.Names}}' | sed 's/ //' | sort -h -r
  2. 將image容量做排序: docker images --format '{{.Size}}\t{{.Repository}}' | sed 's/ //' | sort -h -r
  3. remove dangling volume:
    docker volume rm `docker volume ls -q -f dangling=true`
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment