10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

P2インスタンスにpip3でTensorFlowを入れる

Posted at

p2インスタンスにPython3を入れてpipでTensorFlowを入れるだけです。
Tesla K80で遊ぼう。

要件

TensorFlowは例によって

  • Python 2.7 and Python 3.3+
  • Cuda toolkit >= 7.0
  • cuDNN >= v3

compute capabilityもTesla K80は3.7あるので安心。
CUDA GPUs | NVIDIA Developer

導入方法

インスタンスを立てる

TensorFlowはUbuntuがお好きのようなのでUbuntu公式からAMIを探してきた。
Ubuntu Amazon EC2 AMI Finder

わたしはUbuntu16.10のhvm:ebs-ssdのやつにしてみた。

必要なものを入れる

定番

sudo apt-get update
sudo apt-get upgrade

Python3(3.5.2+が入った)

sudo apt-get install python3-pip python3-dev

CUDAは最新が8。wgetで持って来れるしコマンドはCUDA 8.0 Downloads | NVIDIA Developerのフローに従えばわかる。

sudo apt-get wget
wget https://developer.nvidia.com/compute/cuda/8.0/prod/local_installers/cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64-deb
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64-deb
sudo apt-get update
rm cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64-deb
sudo apt-get install cuda

cuDNNはアカウントつくってcuDNN Download | NVIDIA DeveloperからcuDNN Library for Linuxを持ってきてアップしないといけない。

tar xvzf cudnn-8.0-linux-x64-v5.1-tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

cd /usr/local/cuda/lib64
sudo ln -s libcudart.so libcudart.so.7.5

最後の2行は ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory がでてしまったときの対策。CUDA 7.5 fails with pip install and docker (Ubuntu 14.04) · Issue #20 · tensorflow/tensorflowの下の方。

パスを通しておく。

export CUDA_HOME=/usr/local/cuda
export CUDA_ROOT=/usr/local/cuda
export PATH=$PATH:$CUDA_ROOT/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_ROOT/lib64

GPUありのほうのTensorFlow本体を入れておしまい。

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc0-cp35-cp35m-linux_x86_64.whl
pip3 install --ignore-installed --upgrade $TF_BINARY_URL

参考文献

Installing TensorFlow on an AWS EC2 P2 GPU Instance - ExpressionFlowExpressionFlow
ソースコードから入れるならこっち。

10
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?