Ubuntu18.04+Nvidia+cuda10.2+Tensorflow2.0+Anaconda+pytorch环境安装(GPU)

Ubuntu18.04+Nvidia+cuda10.2+Tensorflow2.0+Anaconda


一、Nvidia驱动安装

#更新
sudo apt-get update
#查看自己可安装哪些显卡驱动
ubuntu-drivers devices
#具体选哪个驱动要根据cuda版本和显卡决定
sudo apt install nvidia-driver-440-server
sudo reboot

二、安装Cuda

1.下载Cuda

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu

进去之后选择自己的版本,我这里选择了联网安装

2.安装

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda

 

三、安装cuDNN

download cudnn-10.0-linux-x64-v7.5.0.56.solitairetheme8 or other version

 

tar -zxvf cudnn-10.0-linux-x64-v7.5.0.56.solitairetheme8
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
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

注意:对于不同版本的cudnn,可能cudnn.h和libcudnn*的路径不同,这个地方可以手动查看这些文件的路径,并手动修改位置,安装的路径不用修改(/usr/local/cuda/include/)和(/usr/local/cuda/lib64)

 

四、安装anaconda

安装anaconda后,我们就可以不用安装Python了,conda仓库里包含了很多要用到的库,所以我们直接安装anaconda,然后在anaconda里面安装TensorFlow或者pytorch

下载 Anaconda3-5.2.0-Linux-x86_64 或者 other version

bash Anaconda3-5.2.0-Linux-x86_64.sh

输入 yes for 增加路径到 .bashrc

source ~/.bashrc

选装

TensorFlow:

pip install tensorflow==2.0.0-beta0 # cpu
pip install tensorflow-gpu==2.0.0-beta0 # gpu

pytorch:

pip install torch-1.1.0-cp36-cp36m-linux_x86_64.whl
pip install torchvision-0.3.0-cp36-cp36m-linux_x86_64.whl

 

你可能感兴趣的:(神经网络,tensorflow,anaconda,cuda,gpu)