在Ubuntu 16.04上安装pytorch gpu和tensorflow gpu版[Anaconda]

Install NVIDIA

sudo vim /etc/modprobe.d/blacklist.conf

add the following lines to the end of the file blacklist.conf

blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist rivatv
blacklist nvidiafb
sudo update-initramfs -u
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-418

Install CUDA

cuda 10.0

  1. Download cuda 10
  2. 装的时候看着点,第二个要你装驱动的选择,回答N,不装。
sudo sh cuda_10.0.130_410.48_linux.run
sudo vim ~/.bashrc

add the following lines to the end of the file ~/.bashrc

export PATH=/usr/bin:/usr/local/cuda-10.0/bin${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:${LD_LIBRARY_PATH}

source ~/.bashrc

cuda 11.1
百度网盘链接
密码: bo6f

sudo sh cuda_11.1.0_455.23.05_linux.run

安装成功后跳出

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-11.1/
Samples:  Not Selected

Please make sure that
 -   PATH includes /usr/local/cuda-11.1/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-11.1/lib64, or, add /usr/local/cuda-11.1/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.1/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least .00 is required for CUDA 11.1 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run --silent --driver

Logfile is /var/log/cuda-installer.log

修改 ~/.bashrc 文件

sudo vim ~/.bashrc

add the following lines to the end of the file ~/.bashrc

export PATH=/usr/local/cuda-11.1/bin${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64:${LD_LIBRARY_PATH}

source ~/.bashrc

Install cudnn

https://developer.nvidia.com/rdp/cudnn-archive

  1. Download cudnn 7
tar xvzf cudnn-10.0-linux-x64-v7.6.4.38.tgz
sudo cp -rp cuda/include/cudnn.h /usr/local/cuda-10.0/include
sudo cp -rp cuda/lib64/libcudnn* /usr/local/cuda-10.0/lib64
sudo chmod a+r /usr/local/cuda-10.0/include/cudnn.h /usr/local/cuda-10.0/lib64/libcudnn*

cudnn 8.0.5
百度网盘
密码: 935g

tar xvzf cudnn-10.0-linux-x64-v7.6.4.38.tgz
sudo cp -rp cuda/include/cudnn.h /usr/local/cuda-10.0/include
sudo cp -rp cuda/lib64/libcudnn* /usr/local/cuda-10.0/lib64
sudo chmod a+r /usr/local/cuda-10.0/include/cudnn.h /usr/local/cuda-10.0/lib64/libcudnn*

Install Anaconda

  1. Download Anaconda
sha256sum Anaconda3-2019.10-Linux-x86_64.sh
bash Anaconda3-2019.10-Linux-x86_64.sh
source ~/.bashrc

Install PyTorch

conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch

Install Tensorflow

conda install -c anaconda tensorflow-gpu

Test

import torch
torch.cuda.is_available()
>>> True
import tensorflow as tf
tf.test.is_gpu_available()
>>> True
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值