Skip to content

Instantly share code, notes, and snippets.

@theshaneyu
Last active March 26, 2019 10:27
Show Gist options
  • Save theshaneyu/d9eda9f6f4fd9c8f4c75a4546f170a4e to your computer and use it in GitHub Desktop.
Save theshaneyu/d9eda9f6f4fd9c8f4c75a4546f170a4e to your computer and use it in GitHub Desktop.
Tensorflow GPU setup on ubuntu 16.04

Tensorflow GPU setup on ubuntu 16.04

刪除nouveau video driver

(nouveau是一個內建的nvidia驅動,會導致GeForce 1080ti出問題)

  1. 產生檔案 /etc/modprobe.d/nouveau

  2. 以下code貼進該檔案

blacklist nouveau
options nouveau modeset=0
  1. 重開機

更新apt源

> sudo apt-get update

安裝需要的套件

> sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy build-essential python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev

安裝nvidia drivers

> curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
> sudo dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
> sudo apt-get update

安裝cuda

> sudo apt-get install cuda

nvidia docker系統整體架構

Imgur

安裝docker

> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
> sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
> sudo apt-get update
> apt-cache policy docker-ce
> sudo apt-get install -y docker-ce
> sudo systemctl status docker

設定不用sudo就可以使用docker

> sudo usermod -aG docker $USER

登出使用者再登入

安裝nvidia-docker

> wget https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
> sudo dpkg -i nvidia-docker*.deb

確認nvidia-docker安裝成功

> nvidia-smi

如果出現如下畫面即安裝成功

Imgur

建立python3的container

> nvidia-docker run -itd --name <name> --hostname <hostname> -p <port>:8888 tensorflow/tensorflow:nightly-gpu-py3 /run_jupyter.sh --allow-root --ip=0.0.0.0

PS. 注意 -p 參數可開通多個port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment