Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

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
ソースコードから入れるならこっち。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした