我将AWS P2 gpu实例与Tesla K80 GPU和Ubuntu 16.04 LTS一起使用。为CPU安装Tensorflow很容易:
pip install tensorflow
但是无法为GPU安装Tensorflow:
pip install tensorflow-gpu
答案 0 :(得分:3)
sudo apt-get remove nvidia* && sudo apt autoremove
sudo reboot # you will have to wait till reboot completes
sudo apt-get update
sudo apt-get install openjdk-8-jdk
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo dpkg -i ./cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda-9-0
nvidia-smi
wget https://s3.amazonaws.com/open-source-william-falcon/cudnn-9.0-linux-x64-v7.1.tgz
sudo tar -xzvf cudnn-9.0-linux-x64-v7.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*
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
source ~/.bashrc
sudo pip install virtualenv
mkdir ~/virtualenv #creating a folder to store all your virtual env
cd ~/virtualenv/
virtualenv -p python3 venv1 #creates venv1 with new python installed on your ubuntu
source venv1/bin/activate #activates your venv
pip uninstall tensorflow
pip uninstall tensorflow-gpu
pip install jupyter # coz i like jupyter
pip install tensorflow-gpu
python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!') #if no error received, its working
from tensorflow.python.client import device_lib
device_lib.list_local_devices() #this will show all CPU's and GPU's on your system
答案 1 :(得分:0)
自动安装所有推荐的ubuntu驱动程序(包括nvidia驱动程序):
sudo apt-get purge nvidia*
sudo ubuntu-drivers autoinstall
将要求您设置密码以验证安装是否正确。设置该密码后,重新启动计算机。然后不要以正常模式启动,进入MOK模式并输入该密码作为密钥。 重新启动(重新启动)后,请通过以下方法检查驱动程序是否安装成功:
nvidia-smi
然后安装Anaconda link,它将处理所有事情。