系统相关
首页 > 系统相关> > ubuntu中CUDA和pytorch的安装

ubuntu中CUDA和pytorch的安装

作者:互联网

---------------------------CUDA及cuDNN的安装
一、下载cuda-10.0的deb安装包并双击进行安装,然后如果有附加的补丁也一并安装
sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
二、配置环境变量
export PATH=/usr/local/cuda-10.0/binKaTeX parse error: Expected '}', got 'EOF' at end of input: {PATH:+:{PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64KaTeX parse error: Expected '}', got 'EOF' at end of input: …LIBRARY_PATH:+:{LD_LIBRARY_PATH}}

三、cudnn的配置
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*

-----------------------pytorch------的安装(cuda10.0版本)
.whl文件安装cuda10.0版本的pytorch1.3.0+torchvision0.4.1
$ python3 -m venv env3
$ source env3/bin/activate
$ cd env3/share/python-wheels

在此找到对应的版本:https://download.pytorch.org/whl/cu100/torch_stable.html
$ wget https://download.pytorch.org/whl/cu100/torch-1.3.0%2Bcu100-cp36-cp36m-linux_x86_64.whl
$ wget https://download.pytorch.org/whl/cu100/torchvision-0.4.1%2Bcu100-cp36-cp36m-linux_x86_64.whl
$ pip install torch-1.3.0+cu100-cp36-cp36m-linux_x86_64.whl torchvision-0.4.1+cu100-cp36-cp36m-linux_x86_64.whl

Processing ./torch-1.3.0+cu100-cp36-cp36m-linux_x86_64.whl
Processing ./torchvision-0.4.1+cu100-cp36-cp36m-linux_x86_64.whl
Collecting numpy (from torch==1.3.0+cu100)

Successfully installed numpy-1.17.3 pillow-6.2.1 six-1.12.0 torch-1.3.0+cu100 torchvision-0.4.1+cu100
$ python
$ import torch

print(torch.version.cuda)
10.0.1

久许 发布了135 篇原创文章 · 获赞 10 · 访问量 5万+ 私信 关注

标签:sudo,cu100,torch,whl,pytorch,cuda,ubuntu,local,CUDA
来源: https://blog.csdn.net/jiuweideqixu/article/details/103943036